Hello everyone!
Long time user first time poster. Basically the premises is this: I want to dump all the Service/Characteristics UUIDs that I can connect to around me.
Serial.print("Forming a connection to ");
Serial.println(myDevice->getAddress().toString().c_str());
BLEClient* pClient = BLEDevice::createClient();
pClient->setClientCallbacks(new MyClientCallback());
// Connect to the remove BLE Server.
pClient->connect(myDevice); // if you pass BLEAdvertisedDevice instead of address, it will be recognized type of peer device address (public or private)
Serial.println(" - Connected to server");
pClient->setMTU(517); //set client to request maximum MTU from server (default is 23 otherwise)
using namespace std;
auto servicesMap = pClient->getServices(); // got services map how to use
std::map<std::string, BLERemoteService*>::iterator itr;
for (itr=servicesMap->begin(); itr!=servicesMap->end(); itr++){
result+=myDevice->getAddress().toString().c_str();
result+=",\n";
result+=itr->first.c_str();
result+=",\n";
}
Serial.println("Map succesfully compiled");
Serial.print(result);
This is great when I can connect the the device but if I can't it just sits there.
Forming a connection to 24:20:00:e7:45:c7
first print
second print
- Created client
- Connected to server
First I understand you cannot connect to all devices and interrogate them, however I can't seem to find a way to do a if(can connect) type of statement...
Few questions here
First is there a better way to attempt to do this that IDK about??
Second is there a way to do a timeout so the program stops if it cannot connect and map the Service/Characteristics UUIDs?
Is there a way to just print out the ServiceUUID maybe if one is there? Like printing this statement:
BLERemoteService* pRemoteService = pClient->getService(serviceUUID);
But that would just be the advertized serviceUUID wouldn't it?
Thanks!