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

Replacing serial terminal with menu #336

Merged
merged 4 commits into from
Oct 12, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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

## [0.5.0] - 03-07-2023

Expand Down
103 changes: 69 additions & 34 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ exclude = [
]

[dependencies]
serde_with = { version = "3.3", default-features = false, features = ["macros"] }
serde-json-core = "0.5"
cortex-m = "0.7.7"
cortex-m-rt = "0.7"
Expand All @@ -38,7 +39,7 @@ heapless = { version = "0.7", features = ["serde"] }
bit_field = "0.10.2"
debounced-pin = "0.3.0"
serde = {version = "1.0", features = ["derive"], default-features = false }
logos = { version = "0.12.1", default-features = false, features = ["export_derive"] }
menu = "0.3"
rtt-logger = "0.2"
bbqueue = "0.5"
usbd-serial = "0.1.0"
Expand Down
6 changes: 3 additions & 3 deletions src/hardware/net_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ pub fn setup(
) {
let net_store = cortex_m::singleton!(: NetStorage = NetStorage::new()).unwrap();

let ip_address = settings.ip_address();
let ip_address = settings.properties.ip_cidr();

let mut config =
smoltcp::iface::Config::new(smoltcp::wire::HardwareAddress::Ethernet(settings.mac()));
smoltcp::iface::Config::new(smoltcp::wire::HardwareAddress::Ethernet(settings.mac));
config.random_seed = random_seed;

let mut interface =
smoltcp::iface::Interface::new(config, device, smoltcp::time::Instant::ZERO);

interface
.routes_mut()
.add_default_ipv4_route(settings.gateway())
.add_default_ipv4_route(settings.properties.gateway.0)
.unwrap();

let mut sockets = smoltcp::iface::SocketSet::new(&mut net_store.sockets[..]);
Expand Down
12 changes: 8 additions & 4 deletions src/hardware/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,15 +342,15 @@ pub fn setup(

let w5500 = w5500::UninitializedDevice::new(w5500::bus::FourWire::new(spi, cs))
.initialize_macraw(w5500::MacAddress {
octets: settings.mac().0,
octets: settings.mac.0,
})
.unwrap();

Mac::W5500(w5500)
} else {
let mut mac = enc424j600::Enc424j600::new(spi, cs).cpu_freq_mhz(CPU_FREQ / 1_000_000);
mac.init(&mut delay).expect("PHY initialization failed");
mac.write_mac_addr(settings.mac().as_bytes()).unwrap();
mac.write_mac_addr(settings.mac.as_bytes()).unwrap();

Mac::Enc424j600(mac)
}
Expand Down Expand Up @@ -409,7 +409,11 @@ pub fn setup(
max6639::Max6639::new(i2c_bus_manager.acquire_i2c(), max6639::AddressPin::Pullup)
.unwrap();

ChassisFans::new([fan1, fan2, fan3], main_board_leds, settings.fan_speed())
ChassisFans::new(
[fan1, fan2, fan3],
main_board_leds,
settings.properties.fan_speed,
)
};

assert!(fans.self_test(&mut delay));
Expand Down Expand Up @@ -442,7 +446,7 @@ pub fn setup(
{
let mut serial_string: String<64> = String::new();

let octets = settings.mac().0;
let octets = settings.mac.0;

write!(
&mut serial_string,
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ mod app {
let mut settings = RuntimeSettings::default();

// Load the default fan speed
settings.fan_speed = booster.settings.fan_speed();
settings.fan_speed = booster.settings.properties.fan_speed;

for idx in enum_iterator::all::<Channel>() {
settings.channel[idx as usize] = booster
Expand All @@ -97,9 +97,9 @@ mod app {
main_bus: booster.main_bus,
net_devices: net::NetworkDevices::new(
// TODO: Replace with hostname-based broker.
minimq::embedded_nal::IpAddr::V4(booster.settings.broker()),
booster.settings.properties.broker(),
booster.network_stack,
booster.settings.id(),
&booster.settings.properties.id,
settings,
clock,
booster.metadata,
Expand Down
Loading