From fae59fa9c98fa94fb15bfbc48f691fa2ef146cd6 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 18 Aug 2022 14:21:05 -0500 Subject: [PATCH] Fixes --- src/graphics/Screen.cpp | 2 +- src/modules/AdminModule.cpp | 9 +++++---- src/nimble/NimbleBluetooth.cpp | 4 ++++ src/platform/nrf52/NRF52Bluetooth.cpp | 5 +++-- src/shutdown.h | 1 - 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 4298b1578..40b8fe5ed 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -1051,7 +1051,7 @@ int32_t Screen::runOnce() handleShutdownScreen(); break; case Cmd::START_REBOOT_SCREEN: - handleShutdownScreen(); + handleRebootScreen(); break; default: DEBUG_MSG("BUG: invalid cmd\n"); diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 29c8518b9..b1f5cc928 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -211,11 +211,12 @@ void AdminModule::handleSetConfig(const Config &c) break; } - bool didSave = service.reloadConfig(); - + service.reloadConfig(); // Reboot 5 seconds after a config that requires rebooting is set - if (didSave && requiresReboot) { - rebootAtMsec = millis() + 5 * 1000; + if (requiresReboot) { + DEBUG_MSG("Rebooting due to config changes\n"); + screen->startRebootScreen(); + rebootAtMsec = millis() + (5 * 1000); } } diff --git a/src/nimble/NimbleBluetooth.cpp b/src/nimble/NimbleBluetooth.cpp index c96f9f77e..4ef21c45e 100644 --- a/src/nimble/NimbleBluetooth.cpp +++ b/src/nimble/NimbleBluetooth.cpp @@ -98,6 +98,7 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks passkeyShowing = false; screen->stopBluetoothPinScreen(); } + bluetoothPhoneAPI->setInitalState(); } virtual void onDisconnect(NimBLEServer* pServer, ble_gap_conn_desc *desc) @@ -127,6 +128,9 @@ bool NimbleBluetooth::isActive() void NimbleBluetooth::setup() { + // Uncomment for testing + // NimbleBluetooth::clearBonds(); + DEBUG_MSG("Initialise the NimBLE bluetooth module\n"); NimBLEDevice::init(getDeviceName()); diff --git a/src/platform/nrf52/NRF52Bluetooth.cpp b/src/platform/nrf52/NRF52Bluetooth.cpp index 415cdb231..d9201fa22 100644 --- a/src/platform/nrf52/NRF52Bluetooth.cpp +++ b/src/platform/nrf52/NRF52Bluetooth.cpp @@ -209,8 +209,9 @@ void NRF52Bluetooth::shutdown() void NRF52Bluetooth::setup() { - Bluefruit.Periph.clearBonds(); - Bluefruit.Central.clearBonds(); + // Uncomment for testing + // Bluefruit.Periph.clearBonds(); + // Bluefruit.Central.clearBonds(); // Initialise the Bluefruit module DEBUG_MSG("Initialise the Bluefruit nRF52 module\n"); diff --git a/src/shutdown.h b/src/shutdown.h index 43094a120..306f84d22 100644 --- a/src/shutdown.h +++ b/src/shutdown.h @@ -8,7 +8,6 @@ void powerCommandsCheck() { if (rebootAtMsec && millis() > rebootAtMsec) { DEBUG_MSG("Rebooting\n"); - screen->startRebootScreen(); #if defined(ARCH_ESP32) ESP.restart(); #elif defined(ARCH_NRF52)