terminate service discovery upon reaching the end handle.

This commit is contained in:
Rohit Grover 2015-05-22 14:51:43 +01:00
parent 4a2fd63867
commit acb585e077
2 changed files with 6 additions and 1 deletions

View file

@ -210,8 +210,12 @@ NordicServiceDiscovery::progressServiceDiscovery(void)
Gap::Handle_t endHandle = services[serviceIndex - 1].getEndHandle();
resetDiscoveredServices(); /* Note: resetDiscoveredServices() must come after fetching endHandle. */
if (sd_ble_gattc_primary_services_discover(connHandle, endHandle, NULL) != NRF_SUCCESS) {
if (endHandle == SRV_DISC_END_HANDLE) {
terminateServiceDiscovery();
} else {
if (sd_ble_gattc_primary_services_discover(connHandle, endHandle, NULL) != NRF_SUCCESS) {
terminateServiceDiscovery();
}
}
}
}

View file

@ -26,6 +26,7 @@ class NordicServiceDiscovery : public ServiceDiscovery
{
public:
static const uint16_t SRV_DISC_START_HANDLE = 0x0001; /**< The start handle value used during service discovery. */
static const uint16_t SRV_DISC_END_HANDLE = 0xFFFF; /**< The end handle value used during service discovery. */
private:
static const unsigned BLE_DB_DISCOVERY_MAX_SRV = 4; /**< Maximum number of services we can retain information for after a single discovery. */