nordic
Fork of nRF51822 by
Diff: btle/btle_discovery.cpp
- Revision:
- 278:91705df8495e
- Parent:
- 277:ae6e5129b395
- Child:
- 279:26e3f0ef1e14
--- a/btle/btle_discovery.cpp Fri Jun 19 15:55:25 2015 +0100 +++ b/btle/btle_discovery.cpp Fri Jun 19 15:55:26 2015 +0100 @@ -155,7 +155,7 @@ terminateCharacteristicDiscovery(); } } else { - terminateCharacteristicDiscovery(); + terminateCharacteristicDiscovery(); } } } @@ -165,14 +165,19 @@ { /* Iterate through the previously discovered services cached in services[]. */ while (sDiscoveryActive && (serviceIndex < numServices)) { - if (serviceCallback) { - serviceCallback(services[serviceIndex]); - } + if ((matchingServiceUUID == ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) || + (matchingServiceUUID == services[serviceIndex].getShortUUID())) { + if (serviceCallback) { + serviceCallback(services[serviceIndex]); + } - if (sDiscoveryActive && characteristicCallback) { /* characteristic discovery is optional. */ - launchCharacteristicDiscovery(connHandle, services[serviceIndex].getStartHandle(), services[serviceIndex].getEndHandle()); + if (sDiscoveryActive && characteristicCallback) { + launchCharacteristicDiscovery(connHandle, services[serviceIndex].getStartHandle(), services[serviceIndex].getEndHandle()); + } else { + serviceIndex++; + } } else { - serviceIndex++; /* Progress service index to keep discovery alive. */ + serviceIndex++; } }