File tree 1 file changed +10
-5
lines changed
1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -361,12 +361,17 @@ impl<'a> DeepSleep<'a> {
361
361
Ok ( ( ) )
362
362
}
363
363
364
+ // In esp idf version 5.x the esp_deep_sleep_start() function CAN return
365
+ // if deep sleep was rejected. So in order for this function to return !
366
+ // it needs to panic. This cause unreachable code for v4.4 and earlier,
367
+ // thus the warning is disabled.
368
+ #[ allow( unreachable_code) ]
364
369
pub fn sleep ( & self ) -> ! {
365
- unsafe { esp_deep_sleep_start ( ) } ;
366
-
367
- // Ensure that funciton never returns for esp idf version 5.x
368
- # [ cfg ( esp_idf_version_major = "5" ) ]
369
- panic ! ( ) ;
370
+ unsafe { esp_deep_sleep_start ( ) }
371
+ // Normally not reached, but if it is, then panic will restart the
372
+ // chip, which is similar to what would happen with a very short deep
373
+ // sleep.
374
+ panic ! ( "Failed to deep sleep, will panic instead" ) ;
370
375
}
371
376
372
377
pub fn prepare_and_sleep ( & self ) -> Result < ( ) , EspError > {
You can’t perform that action at this time.
0 commit comments