@@ -114,7 +114,7 @@ void BLERemoteService::gattClientEventHandler(
114
114
} // switch
115
115
116
116
// Send the event to each of the characteristics owned by this service.
117
- for (auto &myPair : m_characteristicMap ) {
117
+ for (auto &myPair : m_characteristicMapByHandle ) {
118
118
myPair.second ->gattClientEventHandler (event, gattc_if, evtParam);
119
119
}
120
120
} // gattClientEventHandler
@@ -206,7 +206,7 @@ void BLERemoteService::retrieveCharacteristics() {
206
206
);
207
207
208
208
m_characteristicMap.insert (std::pair<std::string, BLERemoteCharacteristic*>(pNewRemoteCharacteristic->getUUID ().toString (), pNewRemoteCharacteristic));
209
-
209
+ m_characteristicMapByHandle. insert (std::pair< uint16_t , BLERemoteCharacteristic*>(result. char_handle , pNewRemoteCharacteristic));
210
210
offset++; // Increment our count of number of descriptors found.
211
211
} // Loop forever (until we break inside the loop).
212
212
@@ -231,6 +231,12 @@ std::map<std::string, BLERemoteCharacteristic *> * BLERemoteService::getCharacte
231
231
return &m_characteristicMap;
232
232
} // getCharacteristics
233
233
234
+ /* *
235
+ * @brief This function is designed to get characteristics map when we have multiple characteristics with the same UUID
236
+ */
237
+ void BLERemoteService::getCharacteristics (std::map<uint16_t , BLERemoteCharacteristic*>* pCharacteristicMap){
238
+ pCharacteristicMap = &m_characteristicMapByHandle;
239
+ } // Get the characteristics map.
234
240
235
241
/* *
236
242
* @brief Get the client associated with this service.
@@ -292,6 +298,10 @@ void BLERemoteService::removeCharacteristics() {
292
298
// m_characteristicMap.erase(myPair.first); // Should be no need to delete as it will be deleted by the clear
293
299
}
294
300
m_characteristicMap.clear (); // Clear the map
301
+ for (auto &myPair : m_characteristicMapByHandle) {
302
+ delete myPair.second ;
303
+ }
304
+ m_characteristicMapByHandle.clear (); // Clear the map
295
305
} // removeCharacteristics
296
306
297
307
0 commit comments