Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of nRF51822 by
Diff: source/nRF5xServiceDiscovery.h
- Revision:
- 549:3f782c64d014
- Parent:
- 548:920e941cbe1e
- Child:
- 561:613dbbdeed27
--- a/source/nRF5xServiceDiscovery.h Mon Jan 11 10:19:06 2016 +0000 +++ b/source/nRF5xServiceDiscovery.h Mon Jan 11 10:19:06 2016 +0000 @@ -41,6 +41,7 @@ gattc(gattcIn), serviceIndex(0), numServices(0), + characteristicIndex(0), numCharacteristics(0), state(INACTIVE), services(), @@ -94,12 +95,6 @@ terminateServiceDiscovery(); } - void terminate(Gap::Handle_t connectionHandle) { - if(connHandle == connectionHandle) { - terminate(); - } - } - virtual void onTermination(ServiceDiscovery::TerminationCallback_t callback) { onTerminationCallback = callback; } @@ -116,8 +111,6 @@ void removeFirstServiceNeedingUUIDDiscovery(void); void terminateServiceDiscovery(void) { - remainingCharacteristic = nRF5xDiscoveredCharacteristic(); - bool wasActive = isActive(); state = INACTIVE; @@ -126,24 +119,8 @@ } } - void terminateCharacteristicDiscovery(ble_error_t err) { + void terminateCharacteristicDiscovery(void) { if (state == CHARACTERISTIC_DISCOVERY_ACTIVE) { - if(remainingCharacteristic != nRF5xDiscoveredCharacteristic()) { - if(err == BLE_ERROR_NONE) { - // fullfill the last characteristic - remainingCharacteristic.setLastHandle(services[serviceIndex].getEndHandle()); - - if ((matchingCharacteristicUUID == UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) || - ((matchingCharacteristicUUID == remainingCharacteristic.getUUID()) && - (matchingServiceUUID != UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)))) { - if (characteristicCallback) { - characteristicCallback(&remainingCharacteristic); - } - } - } - remainingCharacteristic = nRF5xDiscoveredCharacteristic(); - } - state = SERVICE_DISCOVERY_ACTIVE; } serviceIndex++; /* Progress service index to keep discovery alive. */ @@ -157,6 +134,7 @@ void resetDiscoveredCharacteristics(void) { numCharacteristics = 0; + characteristicIndex = 0; } private: @@ -303,6 +281,7 @@ private: uint8_t serviceIndex; /**< Index of the current service being discovered. This is intended for internal use during service discovery.*/ uint8_t numServices; /**< Number of services at the peers GATT database.*/ + uint8_t characteristicIndex; /**< Index of the current characteristic being discovered. This is intended for internal use during service discovery.*/ uint8_t numCharacteristics; /**< Number of characteristics within the service.*/ enum State_t { @@ -321,8 +300,6 @@ CharUUIDDiscoveryQueue charUUIDDiscoveryQueue; TerminationCallback_t onTerminationCallback; - - nRF5xDiscoveredCharacteristic remainingCharacteristic; }; #endif /*__NRF_SERVICE_DISCOVERY_H__*/ \ No newline at end of file