Merge branch 'feature/nal-update' into feature/livestream
This commit is contained in:
commit
aaef0e9913
|
@ -42,6 +42,15 @@ dependencies = [
|
|||
"embedded-hal",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atomic-polyfill"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30302dda7a66f8c55932ebf208f7def840743ff64d495e9ceffcd97c18f11d39"
|
||||
dependencies = [
|
||||
"cortex-m 0.7.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.0.1"
|
||||
|
@ -240,11 +249,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "embedded-nal"
|
||||
version = "0.1.0"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae46eb1b02de5a76d9d0ea21d657ff5b0ad2cc47f3a7723608227b1dd1b3eb18"
|
||||
checksum = "db9efecb57ab54fa918730f2874d7d37647169c50fa1357fecb81abee840b113"
|
||||
dependencies = [
|
||||
"heapless 0.5.6",
|
||||
"heapless 0.7.1",
|
||||
"nb 1.0.0",
|
||||
"no-std-net",
|
||||
]
|
||||
|
@ -317,24 +326,21 @@ dependencies = [
|
|||
"byteorder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hash32"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
|
||||
|
||||
[[package]]
|
||||
name = "heapless"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74911a68a1658cfcfb61bc0ccfbd536e3b6e906f8c2f7883ee50157e3e2184f1"
|
||||
dependencies = [
|
||||
"as-slice",
|
||||
"generic-array 0.13.3",
|
||||
"hash32",
|
||||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heapless"
|
||||
version = "0.6.1"
|
||||
|
@ -343,11 +349,22 @@ checksum = "634bd4d29cbf24424d0a4bfcbf80c6960129dc24424752a7d1d1390607023422"
|
|||
dependencies = [
|
||||
"as-slice",
|
||||
"generic-array 0.14.4",
|
||||
"hash32",
|
||||
"hash32 0.1.1",
|
||||
"serde",
|
||||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heapless"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c7ee8a997d259962217f40279f34201fdf06e669bafa69d7c1f4c7ff1893b5f6"
|
||||
dependencies = [
|
||||
"atomic-polyfill",
|
||||
"hash32 0.2.1",
|
||||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.6.2"
|
||||
|
@ -409,13 +426,12 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "minimq"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/quartiq/minimq.git?rev=d2ec3e8#d2ec3e8351fa403ea96defd98c0b4410cbaa18a4"
|
||||
source = "git+https://github.com/quartiq/minimq.git?branch=feature/nal-update#98c1dffc4b0eeeaadf696320e1ce4234d5b52de0"
|
||||
dependencies = [
|
||||
"bit_field",
|
||||
"embedded-nal",
|
||||
"enum-iterator",
|
||||
"generic-array 0.14.4",
|
||||
"heapless 0.6.1",
|
||||
"heapless 0.7.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -454,9 +470,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "no-std-net"
|
||||
version = "0.4.0"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2178127478ae4ee9be7180bc9c3bffb6354dd7238400db567102f98c413a9f35"
|
||||
checksum = "1bcece43b12349917e096cddfa66107277f123e6c96a5aea78711dc601a47152"
|
||||
|
||||
[[package]]
|
||||
name = "num"
|
||||
|
@ -762,10 +778,10 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "smoltcp-nal"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/quartiq/smoltcp-nal.git?rev=4a1711c#4a1711c54cdf79f5ee8c1c99a1e8984f5944270c"
|
||||
source = "git+https://github.com/quartiq/smoltcp-nal.git?branch=feature/nal-update#65d94c4ab9e06d2e5c48547a0c9cd6836591e355"
|
||||
dependencies = [
|
||||
"embedded-nal",
|
||||
"heapless 0.6.1",
|
||||
"heapless 0.7.1",
|
||||
"nanorand",
|
||||
"smoltcp",
|
||||
]
|
||||
|
|
|
@ -64,13 +64,12 @@ git = "https://github.com/quartiq/miniconf.git"
|
|||
rev = "c6f2b28"
|
||||
|
||||
[dependencies.smoltcp-nal]
|
||||
path = "../smoltcp-nal"
|
||||
# git = "https://github.com/quartiq/smoltcp-nal.git"
|
||||
# rev = "4a1711c"
|
||||
git = "https://github.com/quartiq/smoltcp-nal.git"
|
||||
branch = "feature/udp-support"
|
||||
|
||||
[dependencies.minimq]
|
||||
git = "https://github.com/quartiq/minimq.git"
|
||||
rev = "d2ec3e8"
|
||||
branch = "feature/nal-update"
|
||||
|
||||
[features]
|
||||
nightly = ["cortex-m/inline-asm", "dsp/nightly"]
|
||||
|
|
|
@ -21,7 +21,7 @@ where
|
|||
S: miniconf::Miniconf + Default + Clone,
|
||||
{
|
||||
default_response_topic: String<consts::U128>,
|
||||
mqtt: minimq::MqttClient<minimq::consts::U256, NetworkReference>,
|
||||
mqtt: minimq::Minimq<NetworkReference, 256>,
|
||||
settings: S,
|
||||
subscribed: bool,
|
||||
settings_prefix: String<consts::U64>,
|
||||
|
@ -39,8 +39,7 @@ where
|
|||
/// * `prefix` - The MQTT device prefix to use for this device.
|
||||
pub fn new(stack: NetworkReference, client_id: &str, prefix: &str) -> Self {
|
||||
let mqtt =
|
||||
minimq::MqttClient::new(MQTT_BROKER.into(), client_id, stack)
|
||||
.unwrap();
|
||||
minimq::Minimq::new(MQTT_BROKER.into(), client_id, stack).unwrap();
|
||||
|
||||
let mut response_topic: String<consts::U128> = String::from(prefix);
|
||||
response_topic.push_str("/log").unwrap();
|
||||
|
@ -62,7 +61,7 @@ where
|
|||
/// # Returns
|
||||
/// An option containing an action that should be completed as a result of network servicing.
|
||||
pub fn update(&mut self) -> UpdateState {
|
||||
let mqtt_connected = match self.mqtt.is_connected() {
|
||||
let mqtt_connected = match self.mqtt.client.is_connected() {
|
||||
Ok(connected) => connected,
|
||||
Err(minimq::Error::Network(
|
||||
smoltcp_nal::NetworkError::NoIpAddress,
|
||||
|
@ -88,7 +87,7 @@ where
|
|||
|
||||
// We do not currently handle or process potential subscription failures. Instead, this
|
||||
// failure will be logged through the stabilizer logging interface.
|
||||
self.mqtt.subscribe(&settings_topic, &[]).unwrap();
|
||||
self.mqtt.client.subscribe(&settings_topic, &[]).unwrap();
|
||||
self.subscribed = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,25 +47,25 @@ impl<'a, S> NetworkStackProxy<'a, S> {
|
|||
// proxy structure.
|
||||
macro_rules! forward {
|
||||
($func:ident($($v:ident: $IT:ty),*) -> $T:ty) => {
|
||||
fn $func(&self, $($v: $IT),*) -> $T {
|
||||
fn $func(&mut self, $($v: $IT),*) -> $T {
|
||||
self.mutex.lock(|stack| stack.$func($($v),*))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Implement a TCP stack for the proxy if the underlying network stack implements it.
|
||||
impl<'a, S> embedded_nal::TcpStack for NetworkStackProxy<'a, S>
|
||||
impl<'a, S> embedded_nal::TcpClientStack for NetworkStackProxy<'a, S>
|
||||
where
|
||||
S: embedded_nal::TcpStack,
|
||||
S: embedded_nal::TcpClientStack,
|
||||
{
|
||||
type TcpSocket = S::TcpSocket;
|
||||
type Error = S::Error;
|
||||
|
||||
forward! {open(mode: embedded_nal::Mode) -> Result<S::TcpSocket, S::Error>}
|
||||
forward! {connect(socket: S::TcpSocket, remote: embedded_nal::SocketAddr) -> Result<S::TcpSocket, S::Error>}
|
||||
forward! {socket() -> Result<S::TcpSocket, S::Error>}
|
||||
forward! {connect(socket: &mut S::TcpSocket, remote: embedded_nal::SocketAddr) -> embedded_nal::nb::Result<(), S::Error>}
|
||||
forward! {is_connected(socket: &S::TcpSocket) -> Result<bool, S::Error>}
|
||||
forward! {write(socket: &mut S::TcpSocket, buffer: &[u8]) -> embedded_nal::nb::Result<usize, S::Error>}
|
||||
forward! {read(socket: &mut S::TcpSocket, buffer: &mut [u8]) -> embedded_nal::nb::Result<usize, S::Error>}
|
||||
forward! {send(socket: &mut S::TcpSocket, buffer: &[u8]) -> embedded_nal::nb::Result<usize, S::Error>}
|
||||
forward! {receive(socket: &mut S::TcpSocket, buffer: &mut [u8]) -> embedded_nal::nb::Result<usize, S::Error>}
|
||||
forward! {close(socket: S::TcpSocket) -> Result<(), S::Error>}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ use crate::hardware::{
|
|||
|
||||
/// The telemetry client for reporting telemetry data over MQTT.
|
||||
pub struct TelemetryClient<T: Serialize> {
|
||||
mqtt: minimq::MqttClient<minimq::consts::U256, NetworkReference>,
|
||||
mqtt: minimq::Minimq<NetworkReference, 256>,
|
||||
telemetry_topic: String<consts::U128>,
|
||||
_telemetry: core::marker::PhantomData<T>,
|
||||
}
|
||||
|
@ -97,8 +97,7 @@ impl<T: Serialize> TelemetryClient<T> {
|
|||
/// A new telemetry client.
|
||||
pub fn new(stack: NetworkReference, client_id: &str, prefix: &str) -> Self {
|
||||
let mqtt =
|
||||
minimq::MqttClient::new(MQTT_BROKER.into(), client_id, stack)
|
||||
.unwrap();
|
||||
minimq::Minimq::new(MQTT_BROKER.into(), client_id, stack).unwrap();
|
||||
|
||||
let mut telemetry_topic: String<consts::U128> = String::from(prefix);
|
||||
telemetry_topic.push_str("/telemetry").unwrap();
|
||||
|
@ -122,6 +121,7 @@ impl<T: Serialize> TelemetryClient<T> {
|
|||
let telemetry: Vec<u8, consts::U256> =
|
||||
serde_json_core::to_vec(telemetry).unwrap();
|
||||
self.mqtt
|
||||
.client
|
||||
.publish(&self.telemetry_topic, &telemetry, QoS::AtMostOnce, &[])
|
||||
.ok();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue