Browse Source

If radio_init() fails on the first attempt, currently the board will halt immediately with no feedback. This commit changes the behaviour to make 3 attempts to call the init. After 3 failures, the board will reboot.

pull/3058/head
entr0p1 1 day ago
parent
commit
9395d54735
  1. 11
      examples/companion_radio/main.cpp
  2. 11
      examples/kiss_modem/main.cpp
  3. 12
      examples/simple_repeater/main.cpp
  4. 11
      examples/simple_room_server/main.cpp
  5. 11
      examples/simple_secure_chat/main.cpp
  6. 11
      examples/simple_sensor/main.cpp

11
examples/companion_radio/main.cpp

@ -135,7 +135,16 @@ void setup() {
}
#endif
if (!radio_init()) { halt(); }
int radioinit_attempts = 0;
while (!radio_init()) {
++radioinit_attempts;
MESH_DEBUG_PRINTLN("Radio init failed! (attempt %d)", radioinit_attempts);
if (radioinit_attempts >= 3) {
MESH_DEBUG_PRINTLN("Radio init failed 3x - rebooting");
board.reboot();
}
delay(500);
}
fast_rng.begin(radio_driver.getRngSeed());

11
examples/kiss_modem/main.cpp

@ -78,8 +78,15 @@ void onGetStats(uint32_t* rx, uint32_t* tx, uint32_t* errors) {
void setup() {
board.begin();
if (!radio_init()) {
halt();
int radioinit_attempts = 0;
while (!radio_init()) {
++radioinit_attempts;
MESH_DEBUG_PRINTLN("Radio init failed! (attempt %d)", radioinit_attempts);
if (radioinit_attempts >= 3) {
MESH_DEBUG_PRINTLN("Radio init failed 3x - rebooting");
board.reboot();
}
delay(500);
}
radio_driver.begin();

12
examples/simple_repeater/main.cpp

@ -60,9 +60,15 @@ void setup() {
}
#endif
if (!radio_init()) {
MESH_DEBUG_PRINTLN("Radio init failed!");
halt();
int radioinit_attempts = 0;
while (!radio_init()) {
++radioinit_attempts;
MESH_DEBUG_PRINTLN("Radio init failed! (attempt %d)", radioinit_attempts);
if (radioinit_attempts >= 3) {
MESH_DEBUG_PRINTLN("Radio init failed 3x - rebooting");
board.reboot();
}
delay(500);
}
fast_rng.begin(radio_driver.getRngSeed());

11
examples/simple_room_server/main.cpp

@ -45,7 +45,16 @@ void setup() {
}
#endif
if (!radio_init()) { halt(); }
int radioinit_attempts = 0;
while (!radio_init()) {
++radioinit_attempts;
MESH_DEBUG_PRINTLN("Radio init failed! (attempt %d)", radioinit_attempts);
if (radioinit_attempts >= 3) {
MESH_DEBUG_PRINTLN("Radio init failed 3x - rebooting");
board.reboot();
}
delay(500);
}
fast_rng.begin(radio_driver.getRngSeed());

11
examples/simple_secure_chat/main.cpp

@ -564,7 +564,16 @@ void setup() {
external_watchdog.begin();
#endif
if (!radio_init()) { halt(); }
int radioinit_attempts = 0;
while (!radio_init()) {
++radioinit_attempts;
MESH_DEBUG_PRINTLN("Radio init failed! (attempt %d)", radioinit_attempts);
if (radioinit_attempts >= 3) {
MESH_DEBUG_PRINTLN("Radio init failed 3x - rebooting");
board.reboot();
}
delay(500);
}
fast_rng.begin(radio_driver.getRngSeed());

11
examples/simple_sensor/main.cpp

@ -70,7 +70,16 @@ void setup() {
}
#endif
if (!radio_init()) { halt(); }
int radioinit_attempts = 0;
while (!radio_init()) {
++radioinit_attempts;
MESH_DEBUG_PRINTLN("Radio init failed! (attempt %d)", radioinit_attempts);
if (radioinit_attempts >= 3) {
MESH_DEBUG_PRINTLN("Radio init failed 3x - rebooting");
board.reboot();
}
delay(500);
}
fast_rng.begin(radio_driver.getRngSeed());

Loading…
Cancel
Save