Hi, thanks for testing my code. Unfortunatly whatever I do this specific code won't work on my devices.
I did some research and changed this part:
Code: Select all
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
/**
* Called for each advertising BLE server.
*/
void onResult(BLEAdvertisedDevice advertisedDevice) {
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() ) {
//
Serial.print("Found our device! address: ");
advertisedDevice.getScan()->stop();
pServerAddress = new BLEAddress(advertisedDevice.getAddress());
doConnect = true;
} // Found our server
} // onResult
}; // MyAdvertisedDeviceCallbacks
to this:
Code: Select all
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
void onResult(BLEAdvertisedDevice advertisedDevice) {
if (advertisedDevice.getName() == "MyESP32") { //Check if the name of the advertiser matches
advertisedDevice.getScan()->stop(); //Scan can be stopped, we found what we are looking for
pServerAddress = new BLEAddress(advertisedDevice.getAddress()); //Address of advertiser is the one we need
doConnect = true; //Set indicator, stating that we are ready to connect
Serial.println("Device found. Connecting!");
}
}
};
Now it connects right away to the device, which is great, but I have an other problem.
Some values will be displayed or interpreted the wrong way and I hope you can help me figure this out aswell.
For example the serial monitor displays the device name "50429-97" as just "e" or sometimes it displayes an arrow symbol.
I am still not quite sure, I am using the wrong UUIDs from the nRF-App or converting them the wrong way. Could you show me what I would have to use as my service and characteristic UUIDs for reading the "Device Name" under the "Generic Access" in this screenshot?