Add clearAll parameter to deinit() (#22)

* Add clearAll parameter to deinit()

Adds the ability to clear all resources consumed during BLE operation when deinitializing and shutting down BLE.
Useful when BLE is used intermittently or in a task that initializes, performs operations then deinitializes.

By setting the clearAll parameter to true all created BLE objects will be deleted, freeing the memory for other tasks.

Warning: This will invalidate any pointers that may be referencing the deleted objects.

* Add bool deleteCallbacks parameter to NimBLEServer::setCallbacks, if true (default) will delete the callback class when server is destructed.

* Delete scan results when scan is destructed.
This commit is contained in:
h2zero
2020-07-28 20:57:33 -06:00
committed by GitHub
parent b2df8384b3
commit abdf6cda35
6 changed files with 61 additions and 5 deletions
+3 -1
View File
@@ -44,7 +44,8 @@ public:
void removeService(NimBLEService* service, bool deleteSvc = false);
void addService(NimBLEService* service);
NimBLEAdvertising* getAdvertising();
void setCallbacks(NimBLEServerCallbacks* pCallbacks);
void setCallbacks(NimBLEServerCallbacks* pCallbacks,
bool deleteCallbacks = true);
void startAdvertising();
void stopAdvertising();
void start();
@@ -70,6 +71,7 @@ private:
bool m_advertiseOnDisconnect;
bool m_svcChanged;
NimBLEServerCallbacks* m_pServerCallbacks;
bool m_deleteCallbacks;
std::vector<uint16_t> m_connectedPeersVec;
// uint16_t m_svcChgChrHdl; // Future use