diff --git a/libraries/BLE/src/BLEClient.cpp b/libraries/BLE/src/BLEClient.cpp index ee60030a81f..29fa0fbc140 100644 --- a/libraries/BLE/src/BLEClient.cpp +++ b/libraries/BLE/src/BLEClient.cpp @@ -343,7 +343,7 @@ void BLEClient::gattClientEventHandler(esp_gattc_cb_event_t event, esp_gatt_if_t BLEUUID uuid = BLEUUID(evtParam->search_res.srvc_id); BLERemoteService *pRemoteService = new BLERemoteService(evtParam->search_res.srvc_id, this, evtParam->search_res.start_handle, evtParam->search_res.end_handle); - m_servicesMap.insert(std::pair(uuid.toString(), pRemoteService)); + m_servicesMap.insert(std::pair(uuid.toString().c_str(), pRemoteService)); m_servicesMapByInstID.insert(std::pair(pRemoteService, evtParam->search_res.srvc_id.inst_id)); break; } // ESP_GATTC_SEARCH_RES_EVT @@ -428,7 +428,7 @@ BLERemoteService *BLEClient::getService(BLEUUID uuid) { if (!m_haveServices) { getServices(); } - String uuidStr = uuid.toString(); + std::string uuidStr = uuid.toString().c_str(); for (auto &myPair : m_servicesMap) { if (myPair.first == uuidStr) { log_v("<< getService: found the service with uuid: %s", uuid.toString().c_str()); @@ -445,7 +445,7 @@ BLERemoteService *BLEClient::getService(BLEUUID uuid) { * services and wait until we have received them all. * @return N/A */ -std::map *BLEClient::getServices() { +std::map *BLEClient::getServices() { /* * Design * ------ diff --git a/libraries/BLE/src/BLEClient.h b/libraries/BLE/src/BLEClient.h index 5820b86349b..ddb932fcd95 100644 --- a/libraries/BLE/src/BLEClient.h +++ b/libraries/BLE/src/BLEClient.h @@ -42,7 +42,7 @@ class BLEClient { void disconnect(); // Disconnect from the remote BLE Server BLEAddress getPeerAddress(); // Get the address of the remote BLE Server int getRssi(); // Get the RSSI of the remote BLE Server - std::map *getServices(); // Get a map of the services offered by the remote BLE Server + std::map *getServices(); // Get a map of the services offered by the remote BLE Server BLERemoteService *getService(const char *uuid); // Get a reference to a specified service offered by the remote BLE server. BLERemoteService *getService(BLEUUID uuid); // Get a reference to a specified service offered by the remote BLE server. String getValue(BLEUUID serviceUUID, BLEUUID characteristicUUID); // Get the value of a given characteristic at a given service. @@ -82,7 +82,7 @@ class BLEClient { FreeRTOS::Semaphore m_semaphoreOpenEvt = FreeRTOS::Semaphore("OpenEvt"); FreeRTOS::Semaphore m_semaphoreSearchCmplEvt = FreeRTOS::Semaphore("SearchCmplEvt"); FreeRTOS::Semaphore m_semaphoreRssiCmplEvt = FreeRTOS::Semaphore("RssiCmplEvt"); - std::map m_servicesMap; + std::map m_servicesMap; std::map m_servicesMapByInstID; void clearServices(); // Clear any existing services. uint16_t m_mtu = 23; diff --git a/libraries/BLE/src/BLERemoteCharacteristic.cpp b/libraries/BLE/src/BLERemoteCharacteristic.cpp index 3e066de347a..cd1078796c7 100644 --- a/libraries/BLE/src/BLERemoteCharacteristic.cpp +++ b/libraries/BLE/src/BLERemoteCharacteristic.cpp @@ -297,7 +297,7 @@ void BLERemoteCharacteristic::retrieveDescriptors() { // We now have a new characteristic ... let us add that to our set of known characteristics BLERemoteDescriptor *pNewRemoteDescriptor = new BLERemoteDescriptor(result.handle, BLEUUID(result.uuid), this); - m_descriptorMap.insert(std::pair(pNewRemoteDescriptor->getUUID().toString(), pNewRemoteDescriptor)); + m_descriptorMap.insert(std::pair(pNewRemoteDescriptor->getUUID().toString().c_str(), pNewRemoteDescriptor)); offset++; } // while true @@ -308,7 +308,7 @@ void BLERemoteCharacteristic::retrieveDescriptors() { /** * @brief Retrieve the map of descriptors keyed by UUID. */ -std::map *BLERemoteCharacteristic::getDescriptors() { +std::map *BLERemoteCharacteristic::getDescriptors() { return &m_descriptorMap; } // getDescriptors @@ -329,7 +329,7 @@ uint16_t BLERemoteCharacteristic::getHandle() { */ BLERemoteDescriptor *BLERemoteCharacteristic::getDescriptor(BLEUUID uuid) { log_v(">> getDescriptor: uuid: %s", uuid.toString().c_str()); - String v = uuid.toString(); + std::string v = uuid.toString().c_str(); for (auto &myPair : m_descriptorMap) { if (myPair.first == v) { log_v("<< getDescriptor: found"); diff --git a/libraries/BLE/src/BLERemoteCharacteristic.h b/libraries/BLE/src/BLERemoteCharacteristic.h index 97a7966ab77..dc63a3bc1a6 100644 --- a/libraries/BLE/src/BLERemoteCharacteristic.h +++ b/libraries/BLE/src/BLERemoteCharacteristic.h @@ -39,7 +39,7 @@ class BLERemoteCharacteristic { bool canWrite(); bool canWriteNoResponse(); BLERemoteDescriptor *getDescriptor(BLEUUID uuid); - std::map *getDescriptors(); + std::map *getDescriptors(); BLERemoteService *getRemoteService(); uint16_t getHandle(); BLEUUID getUUID(); @@ -82,7 +82,7 @@ class BLERemoteCharacteristic { notify_callback m_notifyCallback; // We maintain a map of descriptors owned by this characteristic keyed by a string representation of the UUID. - std::map m_descriptorMap; + std::map m_descriptorMap; }; // BLERemoteCharacteristic #endif /* CONFIG_BLUEDROID_ENABLED */ diff --git a/libraries/BLE/src/BLERemoteService.cpp b/libraries/BLE/src/BLERemoteService.cpp index 0ae12e03d21..e4cc31dbb33 100644 --- a/libraries/BLE/src/BLERemoteService.cpp +++ b/libraries/BLE/src/BLERemoteService.cpp @@ -79,8 +79,8 @@ void BLERemoteService::gattClientEventHandler(esp_gattc_cb_event_t event, esp_ga // This is an indication that we now have the characteristic details for a characteristic owned // by this service so remember it. - m_characteristicMap.insert(std::pair( - BLEUUID(evtParam->get_char.char_id.uuid).toString(), + m_characteristicMap.insert(std::pair( + BLEUUID(evtParam->get_char.char_id.uuid).toString().c_str(), new BLERemoteCharacteristic(evtParam->get_char.char_id, evtParam->get_char.char_prop, this) )); @@ -134,7 +134,7 @@ BLERemoteCharacteristic *BLERemoteService::getCharacteristic(BLEUUID uuid) { if (!m_haveCharacteristics) { retrieveCharacteristics(); } - String v = uuid.toString(); + std::string v = uuid.toString().c_str(); for (auto &myPair : m_characteristicMap) { if (myPair.first == v) { return myPair.second; @@ -179,7 +179,9 @@ void BLERemoteService::retrieveCharacteristics() { // We now have a new characteristic ... let us add that to our set of known characteristics BLERemoteCharacteristic *pNewRemoteCharacteristic = new BLERemoteCharacteristic(result.char_handle, BLEUUID(result.uuid), result.properties, this); - m_characteristicMap.insert(std::pair(pNewRemoteCharacteristic->getUUID().toString(), pNewRemoteCharacteristic)); + m_characteristicMap.insert( + std::pair(pNewRemoteCharacteristic->getUUID().toString().c_str(), pNewRemoteCharacteristic) + ); m_characteristicMapByHandle.insert(std::pair(result.char_handle, pNewRemoteCharacteristic)); offset++; // Increment our count of number of descriptors found. } // Loop forever (until we break inside the loop). @@ -192,7 +194,7 @@ void BLERemoteService::retrieveCharacteristics() { * @brief Retrieve a map of all the characteristics of this service. * @return A map of all the characteristics of this service. */ -std::map *BLERemoteService::getCharacteristics() { +std::map *BLERemoteService::getCharacteristics() { log_v(">> getCharacteristics() for service: %s", getUUID().toString().c_str()); // If is possible that we have not read the characteristics associated with the service so do that // now. The request to retrieve the characteristics by calling "retrieveCharacteristics" is a blocking diff --git a/libraries/BLE/src/BLERemoteService.h b/libraries/BLE/src/BLERemoteService.h index 0dbd6823039..49845a0a1e8 100644 --- a/libraries/BLE/src/BLERemoteService.h +++ b/libraries/BLE/src/BLERemoteService.h @@ -34,7 +34,7 @@ class BLERemoteService { BLERemoteCharacteristic *getCharacteristic(const char *uuid); // Get the specified characteristic reference. BLERemoteCharacteristic *getCharacteristic(BLEUUID uuid); // Get the specified characteristic reference. BLERemoteCharacteristic *getCharacteristic(uint16_t uuid); // Get the specified characteristic reference. - std::map *getCharacteristics(); + std::map *getCharacteristics(); std::map *getCharacteristicsByHandle(); // Get the characteristics map. void getCharacteristics(std::map **pCharacteristicMap); @@ -66,7 +66,7 @@ class BLERemoteService { // Properties // We maintain a map of characteristics owned by this service keyed by a string representation of the UUID. - std::map m_characteristicMap; + std::map m_characteristicMap; // We maintain a map of characteristics owned by this service keyed by a handle. std::map m_characteristicMapByHandle; diff --git a/libraries/BLE/src/BLEScan.cpp b/libraries/BLE/src/BLEScan.cpp index 689ce557f29..0a99b46c61d 100644 --- a/libraries/BLE/src/BLEScan.cpp +++ b/libraries/BLE/src/BLEScan.cpp @@ -99,7 +99,7 @@ void BLEScan::handleGAPEvent(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_ bool shouldDelete = true; if (!m_wantDuplicates) { - if (m_scanResults.m_vectorAdvertisedDevices.count(advertisedAddress.toString()) != 0) { + if (m_scanResults.m_vectorAdvertisedDevices.count(advertisedAddress.toString().c_str()) != 0) { found = true; } @@ -130,7 +130,8 @@ void BLEScan::handleGAPEvent(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_ m_pAdvertisedDeviceCallbacks->onResult(*advertisedDevice); } if (!m_wantDuplicates && !found) { // if no callback and not want duplicate, and not already in vector, record it - m_scanResults.m_vectorAdvertisedDevices.insert(std::pair(advertisedAddress.toString(), advertisedDevice)); + m_scanResults.m_vectorAdvertisedDevices.insert(std::pair(advertisedAddress.toString().c_str(), advertisedDevice) + ); shouldDelete = false; } if (shouldDelete) { @@ -443,8 +444,8 @@ void BLEScan::stop() { // delete peer device from cache after disconnecting, it is required in case we are connecting to devices with not public address void BLEScan::erase(BLEAddress address) { log_i("erase device: %s", address.toString().c_str()); - BLEAdvertisedDevice *advertisedDevice = m_scanResults.m_vectorAdvertisedDevices.find(address.toString())->second; - m_scanResults.m_vectorAdvertisedDevices.erase(address.toString()); + BLEAdvertisedDevice *advertisedDevice = m_scanResults.m_vectorAdvertisedDevices.find(address.toString().c_str())->second; + m_scanResults.m_vectorAdvertisedDevices.erase(address.toString().c_str()); delete advertisedDevice; } diff --git a/libraries/BLE/src/BLEScan.h b/libraries/BLE/src/BLEScan.h index 1c2c0f406a0..080e3b803b2 100644 --- a/libraries/BLE/src/BLEScan.h +++ b/libraries/BLE/src/BLEScan.h @@ -53,7 +53,7 @@ class BLEScanResults { private: friend BLEScan; - std::map m_vectorAdvertisedDevices; + std::map m_vectorAdvertisedDevices; }; /**