Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating miniconf/minimq to utilize pings #441

Merged
merged 5 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ shared-bus = {version = "0.2.2", features = ["cortex-m"] }
serde-json-core = "0.4"
mcp23017 = "1.0"
mutex-trait = "0.2"
minimq = "0.3"
minimq = "0.4"

# rtt-target bump
[dependencies.rtt-logger]
Expand Down Expand Up @@ -78,6 +78,10 @@ branch = "feature/assume-init"
git = "https://github.com/quartiq/smoltcp-nal.git"
rev = "0634188"

[patch.crates-io.miniconf]
git = "https://github.com/quartiq/miniconf.git"
rev = "3fec7db"

[features]
nightly = ["cortex-m/inline-asm", "dsp/nightly"]
pounder_v1_1 = [ ]
Expand Down
6 changes: 4 additions & 2 deletions src/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub mod network_processor;
pub mod shared;
pub mod telemetry;

use crate::hardware::{EthernetPhy, NetworkStack};
use crate::hardware::{system_timer::SystemTimer, EthernetPhy, NetworkStack};
use data_stream::{DataStream, FrameGenerator};
use minimq::embedded_nal::IpAddr;
use network_processor::NetworkProcessor;
Expand Down Expand Up @@ -46,7 +46,8 @@ pub enum NetworkState {
}
/// A structure of Stabilizer's default network users.
pub struct NetworkUsers<S: Default + Miniconf, T: Serialize> {
pub miniconf: miniconf::MqttClient<S, NetworkReference>,
pub miniconf:
miniconf::MqttClient<S, NetworkReference, SystemTimer, 512, 1>,
pub processor: NetworkProcessor,
stream: DataStream,
generator: Option<FrameGenerator>,
Expand Down Expand Up @@ -90,6 +91,7 @@ where
&get_client_id(app, "settings", mac),
&prefix,
broker,
SystemTimer::default(),
)
.unwrap();

Expand Down
14 changes: 11 additions & 3 deletions src/net/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ use minimq::QoS;
use serde::Serialize;

use super::NetworkReference;
use crate::hardware::{adc::AdcCode, afe::Gain, dac::DacCode};
use crate::hardware::{
adc::AdcCode, afe::Gain, dac::DacCode, system_timer::SystemTimer,
};
use minimq::embedded_nal::IpAddr;

/// The telemetry client for reporting telemetry data over MQTT.
pub struct TelemetryClient<T: Serialize> {
mqtt: minimq::Minimq<NetworkReference, 256>,
mqtt: minimq::Minimq<NetworkReference, SystemTimer, 256, 1>,
telemetry_topic: String<128>,
_telemetry: core::marker::PhantomData<T>,
}
Expand Down Expand Up @@ -106,7 +108,13 @@ impl<T: Serialize> TelemetryClient<T> {
prefix: &str,
broker: IpAddr,
) -> Self {
let mqtt = minimq::Minimq::new(broker, client_id, stack).unwrap();
let mqtt = minimq::Minimq::new(
broker,
client_id,
stack,
SystemTimer::default(),
)
.unwrap();

let mut telemetry_topic: String<128> = String::from(prefix);
telemetry_topic.push_str("/telemetry").unwrap();
Expand Down