Skip to content

Commit

Permalink
Updating CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-summers committed Dec 4, 2023
1 parent f9705ec commit eeef036
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
* Network stack is randomly seeded on startup so that random ports are used.
* Serial terminal replaced with `menu` for simplicity
* The broker can now be specified using DNS

## [0.5.0] - 03-07-2023

Expand Down
5 changes: 2 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,9 @@ mod app {
SharedResources {
main_bus: booster.main_bus,
net_devices: net::NetworkDevices::new(
// TODO: Replace with hostname-based broker.
booster.settings.properties.broker(),
&booster.settings.properties.broker,
booster.network_stack,
&booster.settings.properties.id.0,
&booster.settings.properties.id,
settings,
clock,
booster.metadata,
Expand Down
15 changes: 9 additions & 6 deletions src/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ pub struct NetworkDevices {
crate::RuntimeSettings,
NetworkStackProxy,
SystemTimer,
minireq::minimq::broker::IpBroker,
minireq::minimq::broker::NamedBroker<NetworkStackProxy>,
4,
>,
pub control: minireq::Minireq<
'static,
MainBus,
NetworkStackProxy,
SystemTimer,
minireq::minimq::broker::IpBroker,
minireq::minimq::broker::NamedBroker<NetworkStackProxy>,
mqtt_control::Error,
>,
stack: NetworkStackProxy,
Expand All @@ -61,7 +61,7 @@ impl NetworkDevices {
/// * `stack` - The network stack to use for communications.
/// * `identifier` - The unique identifier of this device.
pub fn new(
broker: minimq::embedded_nal::IpAddr,
broker: &str,
stack: NetworkStack,
identifier: &str,
settings: crate::RuntimeSettings,
Expand All @@ -81,7 +81,8 @@ impl NetworkDevices {
let mut client_id: String<128> = String::new();
write!(&mut client_id, "booster-{}-req", identifier).unwrap();

let broker = minireq::minimq::broker::IpBroker::new(broker);
let broker =
minireq::minimq::broker::NamedBroker::new(broker, shared.acquire_stack()).unwrap();
let config = minireq::minimq::ConfigBuilder::new(broker, &mut store.settings)
.client_id(&client_id)
.unwrap();
Expand All @@ -104,7 +105,8 @@ impl NetworkDevices {
let mut client_id: String<64> = String::new();
write!(&mut client_id, "booster-{}-tlm", identifier).unwrap();

let broker = minireq::minimq::broker::IpBroker::new(broker);
let broker =
minireq::minimq::broker::NamedBroker::new(broker, shared.acquire_stack()).unwrap();
let config = miniconf::minimq::ConfigBuilder::new(broker, &mut store.telemetry)
// The telemetry client doesn't do much in terms of receiving data, so reserve the
// buffer for transmission.
Expand All @@ -122,7 +124,8 @@ impl NetworkDevices {
let mut client_id: String<128> = String::new();
write!(&mut client_id, "booster-{}-settings", identifier).unwrap();

let broker = minireq::minimq::broker::IpBroker::new(broker);
let broker =
minireq::minimq::broker::NamedBroker::new(broker, shared.acquire_stack()).unwrap();
let config = miniconf::minimq::ConfigBuilder::new(broker, &mut store.control)
.client_id(&client_id)
.unwrap();
Expand Down
14 changes: 12 additions & 2 deletions src/net/mqtt_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ struct ChannelBiasResponse {

/// Represents a means of handling MQTT-based control interface.
pub struct TelemetryClient {
mqtt: minimq::Minimq<'static, NetworkStackProxy, SystemTimer, minimq::broker::IpBroker>,
mqtt: minimq::Minimq<
'static,
NetworkStackProxy,
SystemTimer,
minimq::broker::NamedBroker<NetworkStackProxy>,
>,
prefix: String<128>,
telemetry_period: u64,
meta_published: bool,
Expand All @@ -84,7 +89,12 @@ pub struct TelemetryClient {
impl TelemetryClient {
/// Construct the MQTT control manager.
pub fn new(
mqtt: minimq::Minimq<'static, NetworkStackProxy, SystemTimer, minimq::broker::IpBroker>,
mqtt: minimq::Minimq<
'static,
NetworkStackProxy,
SystemTimer,
minimq::broker::NamedBroker<NetworkStackProxy>,
>,
metadata: &'static ApplicationMetadata,
prefix: &str,
) -> Self {
Expand Down
31 changes: 15 additions & 16 deletions src/settings/global_settings.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Booster NGFW NVM settings
use crate::{hardware::Eeprom, Error};
use core::str::FromStr;
use encdec::{Decode, DecodeOwned, Encode};
use heapless::String;
use smoltcp_nal::smoltcp;
Expand Down Expand Up @@ -137,25 +138,30 @@ impl From<BoosterMainBoardData> for SerializedMainBoardData {
Self {
version: d.version,
ip: d.ip,
broker: d.broker,
broker: d
.broker
.parse()
.unwrap_or_else(|_| IpAddr::new(&[10, 0, 0, 2])),
gateway: d.gateway,
netmask: d.netmask,
id: d.id,
id: MqttIdentifier(d.id),
fan_speed: d.fan_speed,
}
}
}

impl SerializedMainBoardData {
fn with_mac(self, eui48: &[u8; 6]) -> BoosterMainBoardData {
let mut broker = String::new();
write!(&mut broker, "{}", self.broker.0).unwrap();
BoosterMainBoardData {
mac: smoltcp_nal::smoltcp::wire::EthernetAddress(*eui48),
version: self.version,
ip: self.ip,
broker: self.broker,
broker,
gateway: self.gateway,
netmask: self.netmask,
id: self.id,
id: self.id.0,
fan_speed: self.fan_speed,
}
}
Expand All @@ -172,10 +178,10 @@ pub struct BoosterMainBoardData {
pub mac: smoltcp_nal::smoltcp::wire::EthernetAddress,

pub ip: IpAddr,
pub broker: IpAddr,
pub broker: heapless::String<255>,
pub gateway: IpAddr,
pub netmask: IpAddr,
pub id: MqttIdentifier,
pub id: heapless::String<23>,
pub fan_speed: f32,
}

Expand Down Expand Up @@ -206,10 +212,10 @@ impl BoosterMainBoardData {
mac: smoltcp_nal::smoltcp::wire::EthernetAddress(*eui48),
version: EXPECTED_VERSION,
ip: IpAddr::new(&[0, 0, 0, 0]),
broker: IpAddr::new(&[10, 0, 0, 2]),
broker: String::from_str("10.0.0.2").unwrap(),
gateway: IpAddr::new(&[0, 0, 0, 0]),
netmask: IpAddr::new(&[0, 0, 0, 0]),
id: MqttIdentifier(name),
id: name,
fan_speed: DEFAULT_FAN_SPEED,
}
}
Expand Down Expand Up @@ -263,7 +269,7 @@ impl BoosterMainBoardData {
}

pub fn validate(&self) -> bool {
if !identifier_is_valid(&self.id.0) {
if !identifier_is_valid(&self.id) {
log::error!("The ID must be 23 or less alpha-numeric characters (or '-')");
return false;
}
Expand Down Expand Up @@ -299,13 +305,6 @@ impl BoosterMainBoardData {

smoltcp::wire::IpCidr::new(smoltcp::wire::IpAddress::Ipv4(ip_addr), prefix)
}

pub fn broker(&self) -> minimq::embedded_nal::IpAddr {
let octets = self.broker.0 .0;
minimq::embedded_nal::IpAddr::V4(minimq::embedded_nal::Ipv4Addr::new(
octets[0], octets[1], octets[2], octets[3],
))
}
}

/// Booster device-wide configurable settings.
Expand Down

0 comments on commit eeef036

Please sign in to comment.