From 01a1f40ad2e59a8f04ca3f5b0f3e4296af60617b Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 17 Aug 2022 12:00:53 -0500 Subject: [PATCH] Cleanup --- src/platform/esp32/main-esp32.cpp | 14 +------------- src/platform/nrf52/NRF52Bluetooth.cpp | 8 +++++--- src/platform/nrf52/main-nrf52.cpp | 8 ++++---- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/platform/esp32/main-esp32.cpp b/src/platform/esp32/main-esp32.cpp index 3ac9dce06..cd370e9ac 100644 --- a/src/platform/esp32/main-esp32.cpp +++ b/src/platform/esp32/main-esp32.cpp @@ -21,20 +21,9 @@ void getMacAddr(uint8_t *dmac) assert(esp_efuse_mac_get_default(dmac) == ESP_OK); } -/* -static void printBLEinfo() { - int dev_num = esp_ble_get_bond_device_num(); - - esp_ble_bond_dev_t *dev_list = (esp_ble_bond_dev_t *)malloc(sizeof(esp_ble_bond_dev_t) * dev_num); - esp_ble_get_bond_device_list(&dev_num, dev_list); - for (int i = 0; i < dev_num; i++) { - // esp_ble_remove_bond_device(dev_list[i].bd_addr); - } - -} */ void setBluetoothEnable(bool on) { - if (!isWifiAvailable()) { + if (!isWifiAvailable() && config.bluetooth.enabled == true) { if (!nimbleBluetooth) { nimbleBluetooth = new NimbleBluetooth(); } @@ -114,7 +103,6 @@ Periodic axpDebugOutput(axpDebugRead); void esp32Loop() { esp_task_wdt_reset(); // service our app level watchdog - //loopBLE(); // for debug printing // radio.radioIf.canSleep(); diff --git a/src/platform/nrf52/NRF52Bluetooth.cpp b/src/platform/nrf52/NRF52Bluetooth.cpp index ede288b27..60eca5072 100644 --- a/src/platform/nrf52/NRF52Bluetooth.cpp +++ b/src/platform/nrf52/NRF52Bluetooth.cpp @@ -168,9 +168,6 @@ void setupMeshService(void) // any characteristic(s) within that service definition.. Calling .begin() on // a BLECharacteristic will cause it to be added to the last BLEService that // was 'begin()'ed! - - fromNum.setProperties(CHR_PROPS_NOTIFY | CHR_PROPS_READ); - fromNum.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS); // FIXME, secure this!!! fromNum.setFixedLen(0); // Variable len (either 0 or 4) FIXME consider changing protocol so it is fixed 4 byte len, where 0 means empty fromNum.setMaxLen(4); fromNum.setCccdWriteCallback(cccd_callback); // Optionally capture CCCD updates @@ -199,6 +196,11 @@ void setupMeshService(void) toRadio.begin(); } +void setPairingMode() { + +} + + // FIXME, turn off soft device access for debugging static bool isSoftDeviceAllowed = true; diff --git a/src/platform/nrf52/main-nrf52.cpp b/src/platform/nrf52/main-nrf52.cpp index 668565650..589e4ae59 100644 --- a/src/platform/nrf52/main-nrf52.cpp +++ b/src/platform/nrf52/main-nrf52.cpp @@ -7,6 +7,7 @@ #include #include // #include +#include "NodeDB.h" #include "NRF52Bluetooth.h" #include "error.h" @@ -68,7 +69,7 @@ static const bool useSoftDevice = true; // Set to false for easier debugging void setBluetoothEnable(bool on) { - if (on != bleOn) { + if (on != bleOn && config.bluetooth.enabled == true) { if (on) { if (!nrf52Bluetooth) { if (!useSoftDevice) @@ -81,9 +82,8 @@ void setBluetoothEnable(bool on) initBrownout(); } } - } else { - if (nrf52Bluetooth) - nrf52Bluetooth->shutdown(); + } else if (nrf52Bluetooth) { + nrf52Bluetooth->shutdown(); } bleOn = on; }