diff --git a/crates/stela-boot-core/src/wifi_page.rs b/crates/stela-boot-core/src/wifi_page.rs index 0436eceb2e..68f0763ec4 100644 --- a/crates/stela-boot-core/src/wifi_page.rs +++ b/crates/stela-boot-core/src/wifi_page.rs @@ -28,16 +28,29 @@ const CARD: usize = 244; /// The startup menu's Wi-Fi line: the network this boot joins first, the /// one the page chose (`prefer`) or else stela.cfg's `--wifi` one /// (`configured`), and the key that changes it. With no `--wifi` the boot -/// joins nothing, and saved networks (`saved`) can still be managed. `None` -/// when this boot has neither. No password reaches it. -pub fn status_line(configured: Option<&str>, prefer: Option<&str>, saved: bool) -> Option { +/// joins nothing, and saved networks (`saved`) can still be managed. With +/// neither, the line says how to choose one: Wi-Fi works only once a +/// network is chosen, and testers missed the key. No password reaches it. +pub fn status_line(configured: Option<&str>, prefer: Option<&str>, saved: bool) -> String { let network = match (configured, prefer) { (Some(_), Some(prefer)) => prefer, (Some(configured), None) => configured, (None, _) if saved => "not set up", - (None, _) => return None, + (None, _) => return String::from(CHOOSE), }; - Some(format!("Wi-Fi: {network} \u{b7} press W to change")) + format!("Wi-Fi: {network} \u{b7} press W to change") +} + +/// The startup menu's Wi-Fi line when no network is set up. +pub const CHOOSE: &str = "Wi-Fi: press W to choose a network"; + +/// The boot log's line for a menu that offers Wi-Fi with no network set up +/// (`configured` none and nothing `saved`): the hint the menu shows. +pub fn hint_line(configured: Option<&str>, saved: bool) -> Option<&'static str> { + (configured.is_none() && !saved).then_some( + "CHOICE Wi-Fi: no network is set up; press W in this menu to choose one, or Wi-Fi \ + stays off\n", + ) } /// One network the page lists. diff --git a/crates/stela-boot-core/src/wifi_page/tests.rs b/crates/stela-boot-core/src/wifi_page/tests.rs index ed7413b5f9..d345106921 100644 --- a/crates/stela-boot-core/src/wifi_page/tests.rs +++ b/crates/stela-boot-core/src/wifi_page/tests.rs @@ -71,27 +71,44 @@ fn has_text(scene: &Scene, wanted: &str) -> bool { #[test] fn the_status_line_names_the_network_this_boot_joins_first() { assert_eq!( - status_line(Some("home"), None, false).as_deref(), - Some("Wi-Fi: home \u{b7} press W to change") + status_line(Some("home"), None, false), + "Wi-Fi: home \u{b7} press W to change" ); assert_eq!( - status_line(Some("home"), Some("cafe"), true).as_deref(), - Some("Wi-Fi: cafe \u{b7} press W to change") + status_line(Some("home"), Some("cafe"), true), + "Wi-Fi: cafe \u{b7} press W to change" ); } #[test] fn the_status_line_shows_not_set_up_only_with_saved_networks() { assert_eq!( - status_line(None, None, true).as_deref(), - Some("Wi-Fi: not set up \u{b7} press W to change") + status_line(None, None, true), + "Wi-Fi: not set up \u{b7} press W to change" ); // A preference without `--wifi` joins nothing, as `with_prefer` adds none. assert_eq!( - status_line(None, Some("cafe"), true).as_deref(), - Some("Wi-Fi: not set up \u{b7} press W to change") + status_line(None, Some("cafe"), true), + "Wi-Fi: not set up \u{b7} press W to change" ); - assert_eq!(status_line(None, None, false), None); +} + +/// Testers with a Wi-Fi chip the driver starts missed that a network is +/// chosen with W: with none set up the menu and the log both say so. +#[test] +fn with_no_network_set_up_the_line_and_the_log_say_to_press_w() { + assert_eq!( + status_line(None, None, false), + "Wi-Fi: press W to choose a network" + ); + let hint = hint_line(None, false).unwrap(); + assert_eq!( + hint, + "CHOICE Wi-Fi: no network is set up; press W in this menu to choose one, or Wi-Fi \ + stays off\n" + ); + assert_eq!(hint_line(Some("home"), false), None); + assert_eq!(hint_line(None, true), None); } // The rows. @@ -560,7 +577,7 @@ fn no_other_screen_draws_the_password() { }; assert_eq!(save.password, b"password"); assert!(!has_text(&page.scene(SCREEN), "password")); - let status = status_line(Some("home"), Some("cafe"), true).unwrap_or_default(); + let status = status_line(Some("home"), Some("cafe"), true); assert!(!status.contains("password")); } diff --git a/crates/stela-boot-core/src/wifi_page/tests/render.rs b/crates/stela-boot-core/src/wifi_page/tests/render.rs index 71277afef5..1918ad13b9 100644 --- a/crates/stela-boot-core/src/wifi_page/tests/render.rs +++ b/crates/stela-boot-core/src/wifi_page/tests/render.rs @@ -177,7 +177,7 @@ fn main_menu() -> Painter { painter.text(left + 20, y + 8, name, 1, rgb(Tone::Text)); y += 36; } - let line = status_line(Some("GarvitRoom_5G"), None, true).unwrap_or_default(); + let line = status_line(Some("GarvitRoom_5G"), None, true); painter.centred(640, 720 - 24, &line, rgb(Tone::Dim)); painter.centred(640, 720 - 56, "macOS Tahoe in 5", rgb(Tone::Dim)); painter diff --git a/crates/stela-boot/src/choice.rs b/crates/stela-boot/src/choice.rs index 406fea1f20..3358d377ce 100644 --- a/crates/stela-boot/src/choice.rs +++ b/crates/stela-boot/src/choice.rs @@ -500,13 +500,12 @@ impl<'a> Menu<'a> { } // The network this boot joins first and the Wi-Fi page's key, on // the bottom line. - if self.wifi_offered - && let Some(line) = wifi_page::status_line( + if self.wifi_offered { + let line = wifi_page::status_line( self.wifi.as_deref(), self.wifi_prefer.as_deref(), self.wifi_saved, - ) - { + ); canvas.text_centred(width / 2, height.saturating_sub(24), &line, 1, ui::DIM); } let (status, colour) = match (self.notice, self.countdown, self.held) { @@ -640,6 +639,11 @@ fn asked() -> bool { fn menu(volume: &mut FileSystem, choices: &Choices, mut menu: Menu<'_>) -> Option { menu.wifi_saved = crate::wifi_menu::saved(volume); menu.wifi_offered = crate::wifi_menu::offered(); + if menu.wifi_offered + && let Some(hint) = wifi_page::hint_line(menu.wifi.as_deref(), menu.wifi_saved) + { + output::arguments(format_args!("{hint}")); + } loop { let index = match menu.run()? { Pick::Item(index) => index, diff --git a/crates/stela-drivers/src/probe.rs b/crates/stela-drivers/src/probe.rs index cbcb9219b4..7b5ae26767 100644 --- a/crates/stela-drivers/src/probe.rs +++ b/crates/stela-drivers/src/probe.rs @@ -1042,7 +1042,8 @@ const XHCI_DIED_AGAIN: &str = "xHCI: the controller stopped answering again afte its devices are out of reach for this boot"; /// Why a Wi-Fi adapter is left alone. -const NO_WIFI_NETWORK: &str = "Wi-Fi adapter stays off: no --wifi network"; +const NO_WIFI_NETWORK: &str = + "Wi-Fi adapter stays off: no network is chosen (press W at the boot menu to choose one)"; /// Said when an RTL8852CE's MAC was found powered on. const RTW89_WAS_ON: &str =