From eb29994db15edc3c5e9e9f45f2fa866acb2e6136 Mon Sep 17 00:00:00 2001 From: Sam Kent Date: Fri, 5 Oct 2018 16:30:44 +0100 Subject: [PATCH] Moved restart into pairing mode code --- inc/bluetooth/MicroBitBLEManager.h | 6 ------ inc/core/MicroBitComponent.h | 2 ++ source/bluetooth/MicroBitBLEManager.cpp | 14 -------------- .../bluetooth/MicroBitPartialFlashingService.cpp | 7 +------ 4 files changed, 3 insertions(+), 26 deletions(-) diff --git a/inc/bluetooth/MicroBitBLEManager.h b/inc/bluetooth/MicroBitBLEManager.h index 5645d548..8b9f6635 100644 --- a/inc/bluetooth/MicroBitBLEManager.h +++ b/inc/bluetooth/MicroBitBLEManager.h @@ -282,12 +282,6 @@ class MicroBitBLEManager : MicroBitComponent int advertiseEddystoneUid(const char* uid_namespace, const char* uid_instance, int8_t calibratedPower = MICROBIT_BLE_EDDYSTONE_DEFAULT_POWER, bool connectable = true, uint16_t interval = MICROBIT_BLE_EDDYSTONE_ADV_INTERVAL); #endif - /** - * Restarts in BLE Mode - * - */ - void restartInBLEMode(); - /** * Get current BLE mode; application, pairing * #define MICROBIT_MODE_PAIRING 0x00 diff --git a/inc/core/MicroBitComponent.h b/inc/core/MicroBitComponent.h index 62661e0c..f69f1feb 100644 --- a/inc/core/MicroBitComponent.h +++ b/inc/core/MicroBitComponent.h @@ -73,6 +73,8 @@ DEALINGS IN THE SOFTWARE. #define MICROBIT_ID_IO_INT3 35 //INT3 #define MICROBIT_ID_PARTIAL_FLASHING 36 +#define MICROBIT_ID_RESET_INTO_PAIRING 37 + #define MICROBIT_ID_MESSAGE_BUS_LISTENER 1021 // Message bus indication that a handler for a given ID has been registered. #define MICROBIT_ID_NOTIFY_ONE 1022 // Notfication channel, for general purpose synchronisation #define MICROBIT_ID_NOTIFY 1023 // Notfication channel, for general purpose synchronisation diff --git a/source/bluetooth/MicroBitBLEManager.cpp b/source/bluetooth/MicroBitBLEManager.cpp index 07a517f1..52fb8db1 100644 --- a/source/bluetooth/MicroBitBLEManager.cpp +++ b/source/bluetooth/MicroBitBLEManager.cpp @@ -842,20 +842,6 @@ void MicroBitBLEManager::showNameHistogram(MicroBitDisplay &display) } } -/** - * Restarts into BLE Mode - * - */ - void MicroBitBLEManager::restartInBLEMode(){ - KeyValuePair* RebootMode = storage->get("RebootMode"); - if(RebootMode == NULL){ - uint8_t RebootModeValue = MICROBIT_MODE_PAIRING; - storage->put("RebootMode", &RebootModeValue, sizeof(RebootMode)); - delete RebootMode; - } - microbit_reset(); - } - /** * Get BLE mode. Returns the current mode: application, pairing mode */ diff --git a/source/bluetooth/MicroBitPartialFlashingService.cpp b/source/bluetooth/MicroBitPartialFlashingService.cpp index b0f1c42a..8f736eb2 100644 --- a/source/bluetooth/MicroBitPartialFlashingService.cpp +++ b/source/bluetooth/MicroBitPartialFlashingService.cpp @@ -146,7 +146,7 @@ void MicroBitPartialFlashingService::onDataWritten(const GattWriteCallbackParams switch(data[1]) { case MICROBIT_MODE_PAIRING: { - MicroBitEvent evt(MICROBIT_ID_PARTIAL_FLASHING, MICROBIT_RESET ); + MicroBitEvent evt(MICROBIT_ID_PARTIAL_FLASHING, MICROBIT_ID_RESET_INTO_PAIRING ); break; } case MICROBIT_MODE_APPLICATION: @@ -316,11 +316,6 @@ void MicroBitPartialFlashingService::partialFlashingEvent(MicroBitEvent e) microbit_reset(); break; } - case MICROBIT_RESET: - { - MicroBitBLEManager::manager->restartInBLEMode(); - break; - } } }