esp32-snippets
esp32-snippets copied to clipboard
How to initialise BLEAddress(advertisedDevice.getAddress())
I have read your previous post about removing "new" from "MyAdvertisedDeviceCallbacks" in the BLE Device example.
I was wondering how you would replace the "new" in BLEAddress(advertisedDevice.getAddress()); in the following code:
void MyAdvertisedDeviceCallbacks::onResult(BLEAdvertisedDevice advertisedDevice) {
/**
* Called for each advertising BLE server.
*/
Serial.print("BLE Advertised Device found: ");
Serial.println(advertisedDevice.toString().c_str());
// We have found a device, let us now see if it contains the service we are looking for.
if (advertisedDevice.haveServiceUUID() && advertisedDevice.getServiceUUID().equals(serviceUUID)) {
//
Serial.print("Found our device! address: ");
advertisedDevice.getScan()->stop();
pServerAddress = new BLEAddress(advertisedDevice.getAddress());
BT_conStatus = doConnect;
} // Found our server
Thanks again for your help!
Hi, I am also hoping there is another way to compare MAC addresses from an iBeacon. Massive memory leak. Stopping the scan or clearing the results or anything else short of reseting the ESP32, doesn't release the memory used by this line:
pServerAddress = new BLEAddress(Device.getAddress());
When you create class object with new, you have to delete it when no longer required.
When you create class object with new, you have to delete it when no longer required.
Thank you! This worked :)
delete pServerAddress; pServerAddress = NULL;
When you create class object with new, you have to delete it when no longer required.
Thank you! This worked :)
delete pServerAddress; pServerAddress = NULL;
Hi,
Could you share the entire your code for us?
Best Regards,