Différences entre versions de « Projets:Testi »
Sauter à la navigation
Sauter à la recherche
(→Code) |
(→Code) |
||
Ligne 28 : | Ligne 28 : | ||
pClient->connect(myDevice); // if you pass BLEAdvertisedDevice instead of address, it will be recognized type of peer device address (public or private) | 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"); | Serial.println(" - Connected to server"); | ||
+ | |||
+ | |||
+ | // Obtain a reference to the service we are after in the remote BLE server. | ||
+ | BLERemoteService* pRemoteService = pClient->getService(serviceUUID); | ||
+ | if (pRemoteService == nullptr) { | ||
+ | Serial.print("Failed to find our service UUID: "); | ||
+ | Serial.println(serviceUUID.toString().c_str()); | ||
+ | pClient->disconnect(); | ||
+ | return false; | ||
+ | } | ||
+ | Serial.println(" - Found our service"); | ||
Version du 1 juin 2021 à 16:56
Description du projet
Une fois sur deux
Cahier des charges
Analyse de l'existant
Equipe (Porteur de projet et contributeurs)
- Porteurs du projet :
- Concepteurs/contributeurs :
- Animateur (coordinateur du projet)
- Fabmanager référent
- Responsable de documentation
Code
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"); // Obtain a reference to the service we are after in the remote BLE server. BLERemoteService* pRemoteService = pClient->getService(serviceUUID); if (pRemoteService == nullptr) { Serial.print("Failed to find our service UUID: "); Serial.println(serviceUUID.toString().c_str()); pClient->disconnect(); return false; } Serial.println(" - Found our service");