No changes
Fork of nRF51822 by
Diff: btle/btle_discovery.h
- Revision:
- 245:3abc61d38db3
- Parent:
- 244:57c98fe71376
- Child:
- 246:1098730d84de
diff -r 57c98fe71376 -r 3abc61d38db3 btle/btle_discovery.h --- a/btle/btle_discovery.h Fri Jun 19 15:55:22 2015 +0100 +++ b/btle/btle_discovery.h Fri Jun 19 15:55:22 2015 +0100 @@ -116,12 +116,26 @@ 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); } +protected: + void resetDiscoveredCharacteristics(void) { + numCharacteristics = 0; + characteristicIndex = 0; + memset(characteristics, 0, sizeof(DiscoveredCharacteristic) * BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV); + } + +public: void serviceDiscoveryStarted(Gap::Handle_t connectionHandle) { connHandle = connectionHandle; resetDiscoveredServices(); @@ -130,6 +144,14 @@ } protected: + void characteristicDiscoveryStarted(Gap::Handle_t connectionHandle) { + connHandle = connectionHandle; + resetDiscoveredCharacteristics(); + cDiscoveryActive = true; + sDiscoveryActive = false; + } + +protected: ServiceDiscovery() { /* empty */ } @@ -157,26 +179,6 @@ 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)) {