Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: nrf51-sdk
Fork of nRF51822 by
Diff: btle/btle_discovery.cpp
- Revision:
- 293:cd86acfe41be
- Parent:
- 292:01b717803437
- Child:
- 294:a2219bad9d4a
--- a/btle/btle_discovery.cpp Fri Jun 19 15:55:27 2015 +0100
+++ b/btle/btle_discovery.cpp Fri Jun 19 15:55:28 2015 +0100
@@ -109,10 +109,10 @@
void
NordicServiceDiscovery::ServiceIndicesNeedingUUIDDiscovery::triggerFirst(void)
{
- while (numIndices) {
+ while (numIndices) { /* loop until a call to char_value_by_uuid_read() succeeds or we run out of pending indices. */
parentContainer->state = DISCOVER_SERVICE_UUIDS;
- unsigned serviceIndex = serviceIndices[0];
+ unsigned serviceIndex = serviceIndices[0]; /* we chose to use the first index; we could just as easily have chosen the last. */
ble_uuid_t uuid = {
.uuid = BLE_UUID_SERVICE_PRIMARY,
.type = BLE_UUID_TYPE_BLE,
@@ -121,14 +121,16 @@
.start_handle = parentContainer->services[serviceIndex].getStartHandle(),
.end_handle = parentContainer->services[serviceIndex].getEndHandle(),
};
- if (sd_ble_gattc_char_value_by_uuid_read(parentContainer->connHandle, &uuid, &handleRange) != NRF_SUCCESS) {
- removeFirst();
- continue;
+ if (sd_ble_gattc_char_value_by_uuid_read(parentContainer->connHandle, &uuid, &handleRange) == NRF_SUCCESS) {
+ return;
}
- return;
+ /* Skip this service if we fail to launch a read for its service-declaration
+ * attribute. Its UUID will remain INVALID, and it may not match any filters. */
+ removeFirst();
}
+ /* Switch back to service discovery upon exhausting the service-indices pending UUID discovery. */
if (parentContainer->state == DISCOVER_SERVICE_UUIDS) {
parentContainer->state = SERVICE_DISCOVERY_ACTIVE;
}
