nordic
Fork of nRF51822 by
Diff: btle/btle_discovery.cpp
- Revision:
- 249:71ef03789dd3
- Parent:
- 248:df37e7bb3f71
- Child:
- 250:55aa8e43f532
--- 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 @@ -22,19 +22,15 @@ #include "ble_err.h" static NordicServiceDiscovery discoverySingleton; -ServiceDiscovery *ServiceDiscovery::getSingleton(void) { - return &discoverySingleton; -} ble_error_t ServiceDiscovery::launch(Gap::Handle_t connectionHandle, ServiceCallback_t sc, CharacteristicCallback_t cc) { - ServiceDiscovery *singleton = getSingleton(); discoverySingleton.serviceDiscoveryStarted(connectionHandle); uint32_t rc; - if ((rc = sd_ble_gattc_primary_services_discover(connectionHandle, SRV_DISC_START_HANDLE, NULL)) != NRF_SUCCESS) { - singleton->terminate(); + if ((rc = sd_ble_gattc_primary_services_discover(connectionHandle, NordicServiceDiscovery::SRV_DISC_START_HANDLE, NULL)) != NRF_SUCCESS) { + discoverySingleton.terminate(); switch (rc) { case NRF_ERROR_INVALID_PARAM: case BLE_ERROR_INVALID_CONN_HANDLE: @@ -50,6 +46,12 @@ return BLE_ERROR_NONE; } +void +ServiceDiscovery::terminate(void) +{ + discoverySingleton.terminateServiceDiscovery(); +} + ble_error_t NordicServiceDiscovery::launchCharacteristicDiscovery(Gap::Handle_t connectionHandle, Gap::Handle_t startHandle, Gap::Handle_t endHandle) { discoverySingleton.characteristicDiscoveryStarted(connectionHandle);