diff --git a/src/hardware/configuration.rs b/src/hardware/configuration.rs index dfaf4df..c8104f6 100644 --- a/src/hardware/configuration.rs +++ b/src/hardware/configuration.rs @@ -22,6 +22,8 @@ use super::{ pub struct NetStorage { pub ip_addrs: [smoltcp::wire::IpCidr; 1], + + // Note: There is an additional socket set item required for the DHCP socket. pub sockets: [Option>; NUM_SOCKETS + 1], pub socket_storage: [SocketStorage; NUM_SOCKETS], @@ -38,15 +40,15 @@ pub struct NetStorage { #[derive(Copy, Clone)] pub struct SocketStorage { - rx_storage: [u8; 4096], - tx_storage: [u8; 4096], + rx_storage: [u8; 1024], + tx_storage: [u8; 1024], } impl SocketStorage { const fn new() -> Self { Self { - rx_storage: [0; 4096], - tx_storage: [0; 4096], + rx_storage: [0; 1024], + tx_storage: [0; 1024], } } } @@ -167,8 +169,8 @@ pub fn setup( system_timer::SystemTimer::initialize(tim15); } - let mut delay = asm_delay::AsmDelay::new(asm_delay::bitrate::MegaHertz( - ccdr.clocks.c_ck().0 / 1_000_000, + let mut delay = asm_delay::AsmDelay::new(asm_delay::bitrate::Hertz( + ccdr.clocks.c_ck().0, )); let gpioa = device.GPIOA.split(ccdr.peripheral.GPIOA); diff --git a/src/net/mod.rs b/src/net/mod.rs index fb7d0f3..38499ca 100644 --- a/src/net/mod.rs +++ b/src/net/mod.rs @@ -126,24 +126,8 @@ fn get_client_id( client: &str, mac: smoltcp_nal::smoltcp::wire::EthernetAddress, ) -> String { - let mac_string = { - let mut mac_string: String = String::new(); - let mac = mac.as_bytes(); - - // Note(unwrap): 32-bytes is guaranteed to be valid for any mac address, as the address has - // a fixed length. - write!( - &mut mac_string, - "{:02x}-{:02x}-{:02x}-{:02x}-{:02x}-{:02x}", - mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] - ) - .unwrap(); - - mac_string - }; - let mut identifier = String::new(); - write!(&mut identifier, "{}-{}-{}", app, mac_string, client).unwrap(); + write!(&mut identifier, "{}-{}-{}", app, mac, client).unwrap(); identifier } @@ -159,26 +143,10 @@ pub fn get_device_prefix( app: &str, mac: smoltcp_nal::smoltcp::wire::EthernetAddress, ) -> String { - let mac_string = { - let mut mac_string: String = String::new(); - let mac = mac.as_bytes(); - - // Note(unwrap): 32-bytes is guaranteed to be valid for any mac address, as the address has - // a fixed length. - write!( - &mut mac_string, - "{:02x}-{:02x}-{:02x}-{:02x}-{:02x}-{:02x}", - mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] - ) - .unwrap(); - - mac_string - }; - // Note(unwrap): The mac address + binary name must be short enough to fit into this string. If // they are defined too long, this will panic and the device will fail to boot. let mut prefix: String = String::new(); - write!(&mut prefix, "dt/sinara/{}/{}", app, mac_string).unwrap(); + write!(&mut prefix, "dt/sinara/{}/{}", app, mac).unwrap(); prefix }