No changes
Fork of nRF51822 by
Diff: source/nRF5xServiceDiscovery.h
- Revision:
- 561:613dbbdeed27
- Parent:
- 549:3f782c64d014
- Child:
- 563:9c4b96f7be8d
diff -r f6e25408c913 -r 613dbbdeed27 source/nRF5xServiceDiscovery.h --- a/source/nRF5xServiceDiscovery.h Mon Jan 11 10:19:14 2016 +0000 +++ b/source/nRF5xServiceDiscovery.h Mon Jan 11 10:19:15 2016 +0000 @@ -99,6 +99,34 @@ onTerminationCallback = callback; } + /** + * @brief Clear nRF5xServiceDiscovery's state. + * + * @return + * BLE_ERROR_NONE if successful. + */ + virtual ble_error_t cleanup(void) { + /* Clear all state that is from the parent, including private members */ + if (ServiceDiscovery::cleanup() != BLE_ERROR_NONE) { + return BLE_ERROR_INVALID_STATE; + } + + /* Clear derived class members */ + serviceIndex = 0; + numServices = 0; + characteristicIndex = 0; + numCharacteristics = 0; + + state = INACTIVE; + + serviceUUIDDiscoveryQueue.reset(); + charUUIDDiscoveryQueue.reset(); + + onTerminationCallback = NULL; + + return BLE_ERROR_NONE; + } + private: ble_error_t launchCharacteristicDiscovery(Gap::Handle_t connectionHandle, Gap::Handle_t startHandle, Gap::Handle_t endHandle);