diff --git a/src/bin/dual-iir.rs b/src/bin/dual-iir.rs index 84ce8e2..62de6a7 100644 --- a/src/bin/dual-iir.rs +++ b/src/bin/dual-iir.rs @@ -200,7 +200,7 @@ const APP: () = { stabilizer.cycle_counter, env!("CARGO_BIN_NAME"), stabilizer.net.mac_address, - net::parse_or_default_broker(option_env!("BROKER")), + net::parse_ipv4(option_env!("BROKER").unwrap_or("10.34.16.10")), ); let generator = network diff --git a/src/bin/lockin.rs b/src/bin/lockin.rs index 5fd66b1..f3489ad 100644 --- a/src/bin/lockin.rs +++ b/src/bin/lockin.rs @@ -241,7 +241,7 @@ const APP: () = { stabilizer.cycle_counter, env!("CARGO_BIN_NAME"), stabilizer.net.mac_address, - net::parse_or_default_broker(option_env!("BROKER")), + net::parse_ipv4(option_env!("BROKER").unwrap_or("10.34.16.10")), ); let generator = network.configure_streaming( diff --git a/src/net/mod.rs b/src/net/mod.rs index 2e41695..683d77e 100644 --- a/src/net/mod.rs +++ b/src/net/mod.rs @@ -209,29 +209,17 @@ pub fn get_device_prefix( prefix } -/// Determine the broker IP address -/// -/// # Note -/// If the broker IP is unspecified or unparseable, the default IP is returned. +/// Parse a string containing an IPv4 address. +/// This is a convenience wrapper around the `no_std_net` parser. /// /// # Args -/// * `input` - The optionally-specified command-line broker IP address as a string. +/// * `input` - The IP address as a string. /// /// # Returns -/// The broker IP address. -pub fn parse_or_default_broker(input: Option<&str>) -> IpAddr { - input.and_then(|data| { - data.parse::().map_or_else( - |err| { - log::error!( - "{:?}: Failed to parse broker IP ({:?}) - Falling back to default", - err, - data - ); - None - }, - Some, - ) - }) - .unwrap_or_else(|| DEFAULT_MQTT_BROKER.into()) +/// The IP address. +/// +/// # Panic +/// This panics if parsing fails. +pub fn parse_ipv4(input: &str) -> IpAddr { + input.parse::().unwrap() }