File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -323,6 +323,14 @@ void BLEServer::setCallbacks(BLEServerCallbacks* pCallbacks) {
323
323
m_pServerCallbacks = pCallbacks;
324
324
} // setCallbacks
325
325
326
+ /*
327
+ * Remove service
328
+ */
329
+ void BLEServer::removeService (BLEService *service) {
330
+ esp_ble_gatts_delete_service (handle);
331
+ uint16_t handle = service->getHandle ();
332
+ m_serviceMap->removeService (service);
333
+ }
326
334
327
335
/* *
328
336
* @brief Start advertising.
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ class BLEServiceMap {
42
42
std::string toString ();
43
43
BLEService* getFirst ();
44
44
BLEService* getNext ();
45
+ void removeService (BLEService *service);
45
46
46
47
private:
47
48
std::map<uint16_t , BLEService*> m_handleMap;
@@ -61,7 +62,7 @@ class BLEServer {
61
62
BLEAdvertising* getAdvertising ();
62
63
void setCallbacks (BLEServerCallbacks* pCallbacks);
63
64
void startAdvertising ();
64
-
65
+ void removeService (BLEService *service);
65
66
66
67
private:
67
68
BLEServer ();
Original file line number Diff line number Diff line change @@ -120,4 +120,9 @@ BLEService* BLEServiceMap::getNext() {
120
120
return pRet;
121
121
} // getNext
122
122
123
+ void BLEServiceMap::removeService (BLEService *service){
124
+ m_handleMap->erase (serice->getHandle ());
125
+ m_uuidMap->erase (service);
126
+ }
127
+
123
128
#endif /* CONFIG_BT_ENABLED */
You can’t perform that action at this time.
0 commit comments