Open GF65gh opened 3 years ago
Yes, it does not work the way you are doing it. Code is based on events and you cant perform some operations from withing an event. Follow examples.
Thank you, I used the BLE Client Test and getServices() works but I'm getting a size of 0. With the BlueCap app I use, I can see that my device has 5 UUIDs yet could these be not exposed as services and require a different access ?
`bool connectToServer() {
Serial.print("Forming a connection to ");
Serial.println(myDevice->getAddress().toString().c_str());
BLEClient* pClient = BLEDevice::createClient();
Serial.println(" - Created client");
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");
//OK
//Get Services
std::map<std::string, BLERemoteService*> *pRemoteServices = pClient->getServices();
Serial.print("Nb of services: "); Serial.println(pRemoteServices->size());`
Maybe it is case similar to other one recently was reported. Solution was to add small delay between connect and get services.
Hi, I'm working on a personal project to connect to a bluetooth enabled robot device and control it from an ESP32. Using a bluetooth app on my phone, I can connect to this device, access the service + characteristic I need, and write a value e.g. to change the color.
I'm working on a program based on the BLE Beacon Scanner example. I'm trying to connect to the service and characteric based on their UUID. The first issue I got is that the ESP32 doesn't see any service. advertisedDevice.haveServiceUUID() returns 0 and advertisedDevice.getServiceUUID() is null
Looking at my device on an iPhone app (LightBlue), it sees the robot device and it mentions "No services" below (or BlueCap app says Services: 0) When I connect to it, I can see and browse into 5 services, including the one I want to use. Opening this service, I have access to the 2 characteristics I want to use.
So I assume the solution involves using BLEClient::getServices yet running the program (see below) go until message "Client created, connecting..."
Is there a solution to loop on BLERemoteService items returned by getServices to use the appropriate service.