Skip to content

Commit a4b3074

Browse files
committed
feat: restart esp while ws disconnect on update
1 parent 26ceae6 commit a4b3074

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ async fn main(spawner: Spawner) {
9292
}
9393
}
9494

95+
#[cfg(feature = "e2e")]
96+
log::info!("This firmware is E2E! (HIL TESTING)");
97+
9598
let nvs =
9699
esp_hal_wifimanager::Nvs::new_from_part_table().expect("Wrong partition configuration!");
97100

src/ws.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{
22
consts::WS_RETRY_MS,
3-
state::{GlobalState, Scene},
3+
state::{ota_state, GlobalState, Scene},
44
structs::{ApiError, FromPacket, TimerPacket, TimerPacketInner},
55
};
66
use alloc::{rc::Rc, string::ToString};
@@ -198,6 +198,14 @@ async fn ws_loop(
198198
.await;
199199

200200
if let Err(e) = res {
201+
if ota_state() {
202+
global_state.state.lock().await.custom_message =
203+
Some(("Connection lost".to_string(), "during update".to_string()));
204+
205+
Timer::after_millis(5000).await;
206+
esp_hal::reset::software_reset();
207+
}
208+
201209
log::error!("ws_rw_error: {e:?}");
202210
Timer::after_millis(WS_RETRY_MS).await;
203211
break;

0 commit comments

Comments
 (0)