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

Feature/network refactor #168

Merged
merged 12 commits into from
Jan 24, 2022
Prev Previous commit
Next Next commit
Adding WIP updates
ryan-summers committed Jan 20, 2022
commit 65b022bc18b7caf77fcf89fad30775f1f0d9adff
2 changes: 1 addition & 1 deletion .cargo/config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
runner = "gdb-multiarch -q -x openocd.gdb"
runner = "gdb-multiarch -q -x probers.gdb"

rustflags = [
# LLD (shipped with the Rust toolchain) is used as the default linker
1 change: 0 additions & 1 deletion Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -40,8 +40,9 @@ git = "https://github.com/stm32-rs/stm32f4xx-hal"
features = ["stm32f407", "rt", "usb_fs"]

[dependencies.w5500]
git = "https://github.com/quartiq/w5500"
branch = "feature/tcp-nal"
path = "../w5500"
#git = "https://github.com/quartiq/w5500"
#branch = "feature/tcp-nal"
optional = true

[dependencies.enc424j600]
5 changes: 4 additions & 1 deletion src/hardware/setup.rs
Original file line number Diff line number Diff line change
@@ -136,6 +136,9 @@ pub fn setup(
.require_pll48clk()
.freeze();

// Set up the system timer.
super::clock::SystemTimer::initialize(device.TIM2, &clocks);

// Start the watchdog during the initialization process.
let mut watchdog = hal::watchdog::IndependentWatchdog::new(device.IWDG);
watchdog.start(30_000_u32.ms());
@@ -367,7 +370,7 @@ pub fn setup(
ChassisFans::new([fan1, fan2, fan3])
};

assert!(fans.self_test(&mut delay));
//assert!(fans.self_test(&mut delay));

// Set up the USB bus.
let (usb_device, usb_serial) = {
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -307,7 +307,6 @@ const APP: () = {
.lock(|watchdog| watchdog.check_in(WatchdogClient::IdleTask));

// Handle the MQTT control interface.
// TODO: Handle this ownership inversion issue.
let main_bus = &mut c.resources.main_bus;
c.resources
.net_devices
16 changes: 13 additions & 3 deletions src/net/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::hardware::{clock::EpochClock, Channel, NetworkStack};
use crate::hardware::{clock::SystemTimer, Channel, NetworkStack};
use core::fmt::Write;
use heapless::String;
use serde::Serialize;
@@ -12,7 +12,7 @@ use mqtt_control::ControlState;

use shared::NetworkManager;
type NetworkStackProxy = shared::NetworkStackProxy<'static, NetworkStack>;
type MqttClient = minimq::Minimq<NetworkStackProxy, EpochClock, 128, 1>;
type MqttClient = minimq::Minimq<NetworkStackProxy, SystemTimer, 128, 1>;

pub struct NetworkDevices {
pub controller: mqtt_control::ControlState,
@@ -39,6 +39,8 @@ impl NetworkDevices {
}

pub fn process(&mut self) -> bool {
self.telemetry.process();

#[cfg(feature = "phy_enc424j600")]
return self
.stack
@@ -69,7 +71,7 @@ impl TelemetryClient {
broker,
&get_client_id(identifier, "tlm"),
stack,
EpochClock::new(),
SystemTimer::default(),
)
.unwrap(),
prefix: prefix,
@@ -94,6 +96,14 @@ impl TelemetryClient {
)
.ok();
}

// Update the telemetry client.
//
// # Note
// This must be called periodically to advance the MQTT state machine.
fn process(&mut self) {
self.mqtt.poll(|_client, _topic, _message, _properties| {}).ok();
}
}

/// Get an MQTT client ID for a client.
4 changes: 2 additions & 2 deletions src/net/mqtt_control.rs
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ use crate::{
delay::AsmDelay,
hardware::{
booster_channels::BoosterChannels,
clock::EpochClock,
clock::SystemTimer,
rf_channel::{Property as ChannelProperty, PropertyId as ChannelPropertyId},
},
Channel, Error, MainBus,
@@ -242,7 +242,7 @@ impl ControlState {
broker,
&super::get_client_id(id, "ctrl"),
stack,
EpochClock::new(),
SystemTimer::default(),
)
.unwrap(),
subscribed: false,