move helper functions related to characteristicDiscovery into NordicSD.

This commit is contained in:
Rohit Grover 2015-05-06 11:42:56 +01:00
parent 0882a19dc3
commit 2f40cc9e7a

View file

@ -116,24 +116,12 @@ public:
printf("end of service discovery\r\n");
}
void terminateCharacteristicDiscovery(void) {
cDiscoveryActive = false;
sDiscoveryActive = true;
serviceIndex++; /* Progress service index to keep discovery alive. */
}
void resetDiscoveredServices(void) {
numServices = 0;
serviceIndex = 0;
memset(services, 0, sizeof(DiscoveredService) * BLE_DB_DISCOVERY_MAX_SRV);
}
void resetDiscoveredCharacteristics(void) {
numCharacteristics = 0;
characteristicIndex = 0;
memset(characteristics, 0, sizeof(DiscoveredCharacteristic) * BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV);
}
void serviceDiscoveryStarted(Gap::Handle_t connectionHandle) {
connHandle = connectionHandle;
resetDiscoveredServices();
@ -141,14 +129,6 @@ public:
cDiscoveryActive = false;
}
protected:
void characteristicDiscoveryStarted(Gap::Handle_t connectionHandle) {
connHandle = connectionHandle;
resetDiscoveredCharacteristics();
cDiscoveryActive = true;
sDiscoveryActive = false;
}
protected:
ServiceDiscovery() {
/* empty */
@ -174,9 +154,29 @@ public:
void setupDiscoveredServices(const ble_gattc_evt_prim_srvc_disc_rsp_t *response);
void setupDiscoveredCharacteristics(const ble_gattc_evt_char_disc_rsp_t *response);
private:
public:
ble_error_t launchCharacteristicDiscovery(Gap::Handle_t connectionHandle, Gap::Handle_t startHandle, Gap::Handle_t endHandle);
void terminateCharacteristicDiscovery(void) {
cDiscoveryActive = false;
sDiscoveryActive = true;
serviceIndex++; /* Progress service index to keep discovery alive. */
}
private:
void characteristicDiscoveryStarted(Gap::Handle_t connectionHandle) {
connHandle = connectionHandle;
resetDiscoveredCharacteristics();
cDiscoveryActive = true;
sDiscoveryActive = false;
}
void resetDiscoveredCharacteristics(void) {
numCharacteristics = 0;
characteristicIndex = 0;
memset(characteristics, 0, sizeof(DiscoveredCharacteristic) * BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV);
}
public:
void progressCharacteristicDiscovery() {
while (cDiscoveryActive && (characteristicIndex < numCharacteristics)) {