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: btle/btle_discovery.cpp
- Revision:
- 251:d4e0cf5e8751
- Parent:
- 249:55aa8e43f532
- Child:
- 252:4b3f294415f5
diff -r db3c51656388 -r d4e0cf5e8751 btle/btle_discovery.cpp --- a/btle/btle_discovery.cpp Fri Jun 19 15:55:22 2015 +0100 +++ b/btle/btle_discovery.cpp Fri Jun 19 15:55:22 2015 +0100 @@ -117,6 +117,54 @@ } } +void +NordicServiceDiscovery::progressCharacteristicDiscovery(void) +{ + while (cDiscoveryActive && (characteristicIndex < numCharacteristics)) { + /* THIS IS WHERE THE CALLBACK WILL GO */ + printf("%x [%u]\r\n", characteristics[characteristicIndex].uuid, characteristics[characteristicIndex].valueHandle); + + characteristicIndex++; + } + + if (cDiscoveryActive) { + Gap::Handle_t startHandle = characteristics[characteristicIndex - 1].valueHandle + 1; + Gap::Handle_t endHandle = services[serviceIndex].endHandle; + resetDiscoveredCharacteristics(); + + if (startHandle < endHandle) { + ble_gattc_handle_range_t handleRange = { + .start_handle = startHandle, + .end_handle = endHandle + }; + printf("char discovery returned %u\r\n", sd_ble_gattc_characteristics_discover(connHandle, &handleRange)); + } else { + terminateCharacteristicDiscovery(); + } + } +} + +void +NordicServiceDiscovery::progressServiceDiscovery(void) +{ + while (sDiscoveryActive && (serviceIndex < numServices)) { + /* THIS IS WHERE THE CALLBACK WILL GO */ + printf("%x [%u %u]\r\n", services[serviceIndex].uuid, services[serviceIndex].startHandle, services[serviceIndex].endHandle); + + if (true) { /* characteristic discovery is optional. */ + launchCharacteristicDiscovery(connHandle, services[serviceIndex].startHandle, services[serviceIndex].endHandle); + } else { + serviceIndex++; /* Progress service index to keep discovery alive. */ + } + } + if (sDiscoveryActive && (numServices > 0) && (serviceIndex > 0)) { + Gap::Handle_t endHandle = services[serviceIndex - 1].endHandle; + resetDiscoveredServices(); + + printf("services discover returned %u\r\n", sd_ble_gattc_primary_services_discover(connHandle, endHandle, NULL)); + } +} + void bleGattcEventHandler(const ble_evt_t *p_ble_evt) { switch (p_ble_evt->header.evt_id) {