Skip to content

Commit

Permalink
[RSDK-7439] chore: better wifi errors (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjperez authored Apr 30, 2024
1 parent a97e6ea commit 47d0f02
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
11 changes: 9 additions & 2 deletions examples/esp32-with-cred/esp32-server-with-cred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,15 @@ mod esp32 {
&nvs_vars.wifi_ssid,
&nvs_vars.wifi_pwd,
)
.unwrap();
(wifi.wifi().sta_netif().get_ip_info().unwrap().ip, wifi)
.expect("failed to start wifi");
(
wifi.wifi()
.sta_netif()
.get_ip_info()
.expect("failed to get ip info")
.ip,
wifi,
)
};

let webrtc_certificate = WebRtcCertificate::new(
Expand Down
17 changes: 12 additions & 5 deletions examples/esp32/esp32-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,15 @@ mod esp32 {
#[allow(clippy::redundant_clone)]
#[cfg(not(feature = "qemu"))]
let (ip, _wifi) = {
let wifi = start_wifi(periph.modem, sys_loop_stack).unwrap();
(wifi.wifi().sta_netif().get_ip_info().unwrap().ip, wifi)
let wifi = start_wifi(periph.modem, sys_loop_stack).expect("failed to start wifi");
(
wifi.wifi()
.sta_netif()
.get_ip_info()
.expect("failed to get ip info")
.ip,
wifi,
)
};

let cfg = AppClientConfig::new(
Expand Down Expand Up @@ -149,13 +156,13 @@ mod esp32 {

wifi.set_configuration(&wifi_configuration)?;

wifi.start().unwrap();
wifi.start()?;
info!("Wifi started");

wifi.connect().unwrap();
wifi.connect()?;
info!("Wifi connected");

wifi.wait_netif_up().unwrap();
wifi.wait_netif_up()?;
info!("Wifi netif up");

micro_rdk::esp32::esp_idf_svc::sys::esp!(unsafe {
Expand Down
17 changes: 12 additions & 5 deletions templates/project/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,15 @@ fn main() {
}

let (ip, _wifi) = {
let wifi = start_wifi(periph.modem, sys_loop_stack).unwrap();
(wifi.wifi().sta_netif().get_ip_info().unwrap().ip, wifi)
let wifi = start_wifi(periph.modem, sys_loop_stack).expect("failed to start wifi");
(
wifi.wifi()
.sta_netif()
.get_ip_info()
.expect("failed to get ip info'")
.ip,
wifi,
)
};
let cfg = AppClientConfig::new(
ROBOT_SECRET.to_owned(),
Expand Down Expand Up @@ -114,13 +121,13 @@ fn start_wifi(

wifi.set_configuration(&wifi_configuration)?;

wifi.start().unwrap();
wifi.start()?;
info!("Wifi started");

wifi.connect().unwrap();
wifi.connect()?;
info!("Wifi connected");

wifi.wait_netif_up().unwrap();
wifi.wait_netif_up()?;

micro_rdk::esp32::esp_idf_svc::sys::esp!(unsafe {
esp_wifi_set_ps(micro_rdk::esp32::esp_idf_svc::sys::wifi_ps_type_t_WIFI_PS_NONE)
Expand Down

0 comments on commit 47d0f02

Please sign in to comment.