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.
Fork of nRF51822 by
Diff: btle/btle_gattc.cpp
- Revision:
- 237:f07be5960a98
- Parent:
- 236:631719c927ed
- Child:
- 238:6e85a2484de7
--- a/btle/btle_gattc.cpp Fri Jun 19 15:55:21 2015 +0100
+++ b/btle/btle_gattc.cpp Fri Jun 19 15:55:21 2015 +0100
@@ -23,7 +23,6 @@
#define SRV_DISC_START_HANDLE 0x0001 /**< The start handle value used during service discovery. */
-void launchServiceDiscovery(Gap::Handle_t connectionHandle);
void launchCharacteristicDiscovery(Gap::Handle_t connectionHandle, Gap::Handle_t startHandle, Gap::Handle_t endHandle);
@@ -223,10 +222,26 @@
static DiscoveryStatus discoveryStatus;
-void launchServiceDiscovery(Gap::Handle_t connectionHandle)
+ble_error_t launchServiceDiscovery(Gap::Handle_t connectionHandle)
{
discoveryStatus.serviceDiscoveryStarted(connectionHandle);
- printf("launch service discovery returned %u\r\n", sd_ble_gattc_primary_services_discover(connectionHandle, SRV_DISC_START_HANDLE, NULL));
+
+ uint32_t rc;
+ if ((rc = sd_ble_gattc_primary_services_discover(connectionHandle, SRV_DISC_START_HANDLE, NULL)) != NRF_SUCCESS) {
+ discoveryStatus.terminateServiceDiscovery();
+ switch (rc) {
+ case NRF_ERROR_INVALID_PARAM:
+ case BLE_ERROR_INVALID_CONN_HANDLE:
+ return BLE_ERROR_INVALID_PARAM;
+ case NRF_ERROR_BUSY:
+ return BLE_STACK_BUSY;
+ default:
+ case NRF_ERROR_INVALID_STATE:
+ return BLE_ERROR_INVALID_STATE;
+ }
+ }
+
+ return BLE_ERROR_NONE;
}
void launchCharacteristicDiscovery(Gap::Handle_t connectionHandle, Gap::Handle_t startHandle, Gap::Handle_t endHandle) {
