get onTerminationCallback invoked at the end of serviceDiscovery

master
Rohit Grover 2015-05-22 10:47:25 +01:00
parent 9a1cb12120
commit 7a7b768e37
2 changed files with 16 additions and 0 deletions

View File

@ -67,6 +67,10 @@ ServiceDiscovery::isActive(void)
return sdSingleton.isActive();
}
void ServiceDiscovery::onTermination(TerminationCallback_t callback) {
sdSingleton.setOnTermination(callback);
}
ble_error_t
NordicServiceDiscovery::launchCharacteristicDiscovery(Gap::Handle_t connectionHandle,
Gap::Handle_t startHandle,

View File

@ -39,8 +39,14 @@ public:
void setupDiscoveredCharacteristics(const ble_gattc_evt_char_disc_rsp_t *response);
void terminateServiceDiscovery(void) {
bool wasActive = isActive();
sDiscoveryActive = false;
cDiscoveryActive = false;
if (wasActive && onTerminationCallback) {
onTerminationCallback(connHandle);
}
}
void terminateCharacteristicDiscovery(void) {
@ -53,6 +59,10 @@ public:
return (sDiscoveryActive || cDiscoveryActive);
}
void setOnTermination(TerminationCallback_t callback) {
onTerminationCallback = callback;
}
private:
void resetDiscoveredServices(void) {
numServices = 0;
@ -99,6 +109,8 @@ private:
DiscoveredService services[BLE_DB_DISCOVERY_MAX_SRV]; /**< Information related to the current service being discovered.
* This is intended for internal use during service discovery. */
DiscoveredCharacteristic characteristics[BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV];
TerminationCallback_t onTerminationCallback;
};
#endif /*_BTLE_DISCOVERY_H_*/