kopia lustrzana https://github.com/meshtastic/firmware
Clear bluetooth bonds on multi-press and factory_reset (#1176)
* Clear bluetooth bonds on multi-press and factory_resetpull/1177/head^2
rodzic
dd31a829fb
commit
b21b7de04b
|
@ -340,6 +340,9 @@ class ButtonThread : public OSThread
|
|||
{
|
||||
#ifndef NO_ESP32
|
||||
clearNVS();
|
||||
#endif
|
||||
#ifdef NRF52_SERIES
|
||||
clearBonds();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -27,4 +27,4 @@ extern uint32_t shutdownAtMsec;
|
|||
// This will supress the current delay and instead try to run ASAP.
|
||||
extern bool runASAP;
|
||||
|
||||
void nrf52Setup(), esp32Setup(), nrf52Loop(), esp32Loop();
|
||||
void nrf52Setup(), esp32Setup(), nrf52Loop(), esp32Loop(), clearBonds();
|
||||
|
|
|
@ -26,6 +26,11 @@
|
|||
#include <nvs_flash.h>
|
||||
#endif
|
||||
|
||||
#ifdef NRF52_SERIES
|
||||
#include <bluefruit.h>
|
||||
#include <utility/bonding.h>
|
||||
#endif
|
||||
|
||||
NodeDB nodeDB;
|
||||
|
||||
// we have plenty of ram so statically alloc this tempbuf (for now)
|
||||
|
@ -90,6 +95,16 @@ bool NodeDB::resetRadioConfig()
|
|||
#ifndef NO_ESP32
|
||||
// This will erase what's in NVS including ssl keys, persistant variables and ble pairing
|
||||
nvs_flash_erase();
|
||||
#endif
|
||||
#ifdef NRF52_SERIES
|
||||
Bluefruit.begin();
|
||||
|
||||
DEBUG_MSG("Clearing bluetooth bonds!\n");
|
||||
bond_print_list(BLE_GAP_ROLE_PERIPH);
|
||||
bond_print_list(BLE_GAP_ROLE_CENTRAL);
|
||||
|
||||
Bluefruit.Periph.clearBonds();
|
||||
Bluefruit.Central.clearBonds();
|
||||
#endif
|
||||
didFactoryReset = true;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "mesh/PhoneAPI.h"
|
||||
#include "mesh/mesh-pb-constants.h"
|
||||
#include <bluefruit.h>
|
||||
#include <utility/bonding.h>
|
||||
|
||||
static BLEService meshBleService = BLEService(BLEUuid(MESH_SERVICE_UUID_16));
|
||||
static BLECharacteristic fromNum = BLECharacteristic(BLEUuid(FROMNUM_UUID_16));
|
||||
|
@ -266,3 +267,13 @@ void updateBatteryLevel(uint8_t level)
|
|||
{
|
||||
blebas.write(level);
|
||||
}
|
||||
|
||||
void NRF52Bluetooth::clearBonds()
|
||||
{
|
||||
DEBUG_MSG("Clearing bluetooth bonds!\n");
|
||||
bond_print_list(BLE_GAP_ROLE_PERIPH);
|
||||
bond_print_list(BLE_GAP_ROLE_CENTRAL);
|
||||
|
||||
Bluefruit.Periph.clearBonds();
|
||||
Bluefruit.Central.clearBonds();
|
||||
}
|
|
@ -5,5 +5,6 @@ class NRF52Bluetooth
|
|||
public:
|
||||
void setup();
|
||||
void shutdown();
|
||||
void clearBonds();
|
||||
};
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ void setBluetoothEnable(bool on)
|
|||
else {
|
||||
nrf52Bluetooth = new NRF52Bluetooth();
|
||||
nrf52Bluetooth->setup();
|
||||
|
||||
|
||||
// We delay brownout init until after BLE because BLE starts soft device
|
||||
initBrownout();
|
||||
}
|
||||
|
@ -185,4 +185,12 @@ void cpuDeepSleep(uint64_t msecToWake)
|
|||
delay(5000);
|
||||
DEBUG_MSG(".");
|
||||
}
|
||||
}
|
||||
|
||||
void clearBonds() {
|
||||
if (!nrf52Bluetooth) {
|
||||
nrf52Bluetooth = new NRF52Bluetooth();
|
||||
nrf52Bluetooth->setup();
|
||||
}
|
||||
nrf52Bluetooth->clearBonds();
|
||||
}
|
Ładowanie…
Reference in New Issue