NimBLE enhanced logging (do not merge) (#1629)

* Change log level to debug

* Don't reinit active bluetooth services

* Chmod +x before zip and adding to release
This commit is contained in:
Ben Meadors 2022-08-14 15:27:21 -05:00 committed by GitHub
parent ca9113ad05
commit 80e3cee006
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 4 deletions

View File

@ -426,6 +426,11 @@ jobs:
name: firmware-${{ steps.version.outputs.version }} name: firmware-${{ steps.version.outputs.version }}
path: ./output path: ./output
- name: permissions
- run: |
chmod +x ./output/device-install.sh
chmod +x ./output/device-update.sh
- name: Zip firmware - name: Zip firmware
run: zip -j -r ./firmware-${{ steps.version.outputs.version }}.zip ./output run: zip -j -r ./firmware-${{ steps.version.outputs.version }}.zip ./output

View File

@ -56,7 +56,8 @@ class ESP32BluetoothToRadioCallback : public NimBLECharacteristicCallbacks
} }
}; };
class ESP32BluetoothFromRadioCallback : public NimBLECharacteristicCallbacks { class ESP32BluetoothFromRadioCallback : public NimBLECharacteristicCallbacks
{
virtual void onRead(NimBLECharacteristic *pCharacteristic) { virtual void onRead(NimBLECharacteristic *pCharacteristic) {
DEBUG_MSG("From Radio onread\n"); DEBUG_MSG("From Radio onread\n");
uint8_t fromRadioBytes[FromRadio_size]; uint8_t fromRadioBytes[FromRadio_size];
@ -91,7 +92,8 @@ class ESP32BluetoothServerCallback : public NimBLEServerCallbacks
return passkey; return passkey;
} }
virtual void onAuthenticationComplete(ble_gap_conn_desc *desc) { virtual void onAuthenticationComplete(ble_gap_conn_desc *desc)
{
DEBUG_MSG("BLE authentication complete\n"); DEBUG_MSG("BLE authentication complete\n");
if (passkeyShowing) { if (passkeyShowing) {
@ -100,7 +102,8 @@ class ESP32BluetoothServerCallback : public NimBLEServerCallbacks
} }
} }
virtual void onDisconnect(NimBLEServer* pServer, ble_gap_conn_desc *desc) { virtual void onDisconnect(NimBLEServer* pServer, ble_gap_conn_desc *desc)
{
DEBUG_MSG("BLE disconnect\n"); DEBUG_MSG("BLE disconnect\n");
} }
}; };
@ -118,6 +121,12 @@ void ESP32Bluetooth::shutdown()
pAdvertising->stop(); pAdvertising->stop();
} }
bool ESP32Bluetooth::isActive()
{
NimBLEAdvertising *pAdvertising = NimBLEDevice::getAdvertising();
return bleServer && (bleServer->getConnectedCount() > 0 || pAdvertising->isAdvertising());
}
void ESP32Bluetooth::setup() void ESP32Bluetooth::setup()
{ {
DEBUG_MSG("Initialise the ESP32 bluetooth module\n"); DEBUG_MSG("Initialise the ESP32 bluetooth module\n");

View File

@ -8,6 +8,7 @@ class ESP32Bluetooth
void setup(); void setup();
void shutdown(); void shutdown();
void clearBonds(); void clearBonds();
bool isActive();
private: private:
void setupService(); void setupService();

View File

@ -46,7 +46,7 @@ void setBluetoothEnable(bool on) {
if (!esp32Bluetooth) { if (!esp32Bluetooth) {
esp32Bluetooth = new ESP32Bluetooth(); esp32Bluetooth = new ESP32Bluetooth();
} }
if (on) { if (on && !esp32Bluetooth->isActive()) {
esp32Bluetooth->setup(); esp32Bluetooth->setup();
} else { } else {
esp32Bluetooth->shutdown(); esp32Bluetooth->shutdown();