Esp32 NimBLE experiments (#1613)

* Delete callbacks on bleServer on destruct

* Trying things
This commit is contained in:
Ben Meadors 2022-08-10 12:44:52 -05:00 committed by GitHub
parent 1d1ccd6b19
commit 7d0411cd15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 8 deletions

@ -1 +1 @@
Subproject commit addd11766c2e76d4f84e715aa7f0d4e061b925a8
Subproject commit c473ed7a6aa83c4be80382aa9abf8f8258be40a3

View File

@ -257,10 +257,10 @@ typedef struct _Location {
uint32_t expire;
/* If true, only allow the original sender to update the location. */
bool locked;
/* Name of the location - max 40 chars */
/* Name of the location - max 30 chars */
char name[30];
/* *
Description of the location - max 160 chars */
Description of the location - max 100 chars */
char description[100];
} Location;

View File

@ -109,9 +109,11 @@ class ESP32BluetoothServerCallback : public NimBLEServerCallbacks {
screen->stopBluetoothPinScreen();
}
}
virtual void onDisconnect(NimBLEServer* pServer, ble_gap_conn_desc *desc) {
DEBUG_MSG("BLE disconnect\n");
}
};
static ESP32BluetoothToRadioCallback *toRadioCallbacks;
static ESP32BluetoothFromRadioCallback *fromRadioCallbacks;
@ -120,6 +122,9 @@ void ESP32Bluetooth::shutdown()
// Shutdown bluetooth for minimum power draw
DEBUG_MSG("Disable bluetooth\n");
//Bluefruit.Advertising.stop();
NimBLEAdvertising *pAdvertising = NimBLEDevice::getAdvertising();
pAdvertising->reset();
pAdvertising->stop();
}
void ESP32Bluetooth::setup()
@ -175,7 +180,7 @@ void ESP32Bluetooth::setup()
bleServer = NimBLEDevice::createServer();
ESP32BluetoothServerCallback *serverCallbacks = new ESP32BluetoothServerCallback();
bleServer->setCallbacks(serverCallbacks);
bleServer->setCallbacks(serverCallbacks, true);
NimBLEService *bleService = bleServer->createService(MESH_SERVICE_UUID);
//NimBLECharacteristic *pNonSecureCharacteristic = bleService->createCharacteristic("1234", NIMBLE_PROPERTY::READ );
@ -208,9 +213,9 @@ void ESP32Bluetooth::setup()
//ToRadioCharacteristic->setCallbacks()
NimBLEAdvertising *pAdvertising = NimBLEDevice::getAdvertising();
pAdvertising->reset();
pAdvertising->addServiceUUID(MESH_SERVICE_UUID);
pAdvertising->start();
pAdvertising->start(0);
}
@ -228,7 +233,7 @@ void ESP32Bluetooth::clearBonds()
//Bluefruit.Periph.clearBonds();
//Bluefruit.Central.clearBonds();
NimBLEDevice::deleteAllBonds();
}
void clearNVS() {