Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions examples/companion_radio/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,25 @@ MyMesh the_mesh(radio_driver, fast_rng, rtc_clock, tables, store

/* END GLOBAL OBJECTS */

void halt() {
while (1) ;
void delayedReboot(const char *msg, const uint32_t delayms) {
char tmp[32];
sprintf(tmp, "Rebooting in %3.1fs", delayms/1000.0);
#ifdef DISPLAY_CLASS
display.startFrame();
display.drawTextCentered(display.width() / 2, 24, msg);
display.drawTextCentered(display.width() / 2, 32, tmp);
display.endFrame();
#endif
MESH_DEBUG_PRINTLN(msg);
MESH_DEBUG_PRINTLN(tmp);
delay(delayms);
board.reboot();
}

void setup() {
Serial.begin(115200);

board.begin();

#ifdef DISPLAY_CLASS
DisplayDriver* disp = NULL;
if (display.begin()) {
Expand All @@ -123,7 +133,8 @@ void setup() {
}
#endif

if (!radio_init()) { halt(); }
if (!radio_init())
delayedReboot("Radio Init Failed!", 5000);

fast_rng.begin(radio_get_rng_seed());

Expand Down
20 changes: 15 additions & 5 deletions examples/simple_repeater/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,19 @@ SimpleMeshTables tables;

MyMesh the_mesh(board, radio_driver, *new ArduinoMillis(), fast_rng, rtc_clock, tables);

void halt() {
while (1) ;
void delayedReboot(const char *msg, const uint32_t delayms) {
char tmp[32];
sprintf(tmp, "Rebooting in %3.1fs", delayms/1000.0);
#ifdef DISPLAY_CLASS
display.startFrame();
display.drawTextCentered(display.width() / 2, 24, msg);
display.drawTextCentered(display.width() / 2, 32, tmp);
display.endFrame();
#endif
MESH_DEBUG_PRINTLN(msg);
MESH_DEBUG_PRINTLN(tmp);
delay(delayms);
board.reboot();
}

static char command[160];
Expand All @@ -34,9 +45,8 @@ void setup() {
}
#endif

if (!radio_init()) {
halt();
}
if (!radio_init())
delayedReboot("Radio Init Failed!", 5000);

fast_rng.begin(radio_get_rng_seed());

Expand Down
19 changes: 16 additions & 3 deletions examples/simple_room_server/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,19 @@ StdRNG fast_rng;
SimpleMeshTables tables;
MyMesh the_mesh(board, radio_driver, *new ArduinoMillis(), fast_rng, rtc_clock, tables);

void halt() {
while (1) ;
void delayedReboot(const char *msg, const uint32_t delayms) {
char tmp[32];
sprintf(tmp, "Rebooting in %3.1fs", delayms/1000.0);
#ifdef DISPLAY_CLASS
display.startFrame();
display.drawTextCentered(display.width() / 2, 24, msg);
display.drawTextCentered(display.width() / 2, 32, tmp);
display.endFrame();
#endif
MESH_DEBUG_PRINTLN(msg);
MESH_DEBUG_PRINTLN(tmp);
delay(delayms);
board.reboot();
}

static char command[MAX_POST_TEXT_LEN+1];
Expand All @@ -33,7 +44,9 @@ void setup() {
}
#endif

if (!radio_init()) { halt(); }

if (!radio_init())
delayedReboot("Radio Init Failed!", 5000);

fast_rng.begin(radio_get_rng_seed());

Expand Down
20 changes: 16 additions & 4 deletions examples/simple_secure_chat/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,16 +550,28 @@ StdRNG fast_rng;
SimpleMeshTables tables;
MyMesh the_mesh(radio_driver, fast_rng, rtc_clock, tables);

void halt() {
while (1) ;
void delayedReboot(const char *msg, const uint32_t delayms) {
char tmp[32];
sprintf(tmp, "Rebooting in %3.1fs", delayms/1000.0);
#ifdef DISPLAY_CLASS
display.startFrame();
display.drawTextCentered(display.width() / 2, 24, msg);
display.drawTextCentered(display.width() / 2, 32, tmp);
display.endFrame();
#endif
MESH_DEBUG_PRINTLN(msg);
MESH_DEBUG_PRINTLN(tmp);
delay(delayms);
board.reboot();
}

void setup() {
Serial.begin(115200);

board.begin();

if (!radio_init()) { halt(); }
if (!radio_init())
delayedReboot("Radio Init Failed!", 5000);

fast_rng.begin(radio_get_rng_seed());

Expand Down
18 changes: 15 additions & 3 deletions examples/simple_sensor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,19 @@ SimpleMeshTables tables;

MyMesh the_mesh(board, radio_driver, *new ArduinoMillis(), fast_rng, rtc_clock, tables);

void halt() {
while (1) ;
void delayedReboot(const char *msg, const uint32_t delayms) {
char tmp[32];
sprintf(tmp, "Rebooting in %3.1fs", delayms/1000.0);
#ifdef DISPLAY_CLASS
display.startFrame();
display.drawTextCentered(display.width() / 2, 24, msg);
display.drawTextCentered(display.width() / 2, 32, tmp);
display.endFrame();
#endif
MESH_DEBUG_PRINTLN(msg);
MESH_DEBUG_PRINTLN(tmp);
delay(delayms);
board.reboot();
}

static char command[160];
Expand All @@ -66,7 +77,8 @@ void setup() {
}
#endif

if (!radio_init()) { halt(); }
if (!radio_init())
delayedReboot("Radio Init Failed!", 5000);

fast_rng.begin(radio_get_rng_seed());

Expand Down