fdsf
Fork of nRF51822 by
Diff: btle/btle_discovery.cpp
- Revision:
- 293:cd86acfe41be
- Parent:
- 292:01b717803437
- Child:
- 294:a2219bad9d4a
diff -r 01b717803437 -r cd86acfe41be btle/btle_discovery.cpp --- 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; }