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
Revision 240:75b69581d1dd, committed 2015-06-19
- Comitter:
- rgrover1
- Date:
- Fri Jun 19 15:55:21 2015 +0100
- Parent:
- 239:693a1f145b5a
- Child:
- 241:d264f9ec06a3
- Commit message:
- Synchronized with git rev 11d76136
Author: Rohit Grover
add class NordicServiceDiscovery
Changed in this revision
--- a/btle/btle_discovery.cpp Fri Jun 19 15:55:21 2015 +0100
+++ b/btle/btle_discovery.cpp Fri Jun 19 15:55:21 2015 +0100
@@ -5,12 +5,6 @@
#include "btle_discovery.h"
#include "ble_err.h"
-ServiceDiscovery *ServiceDiscovery::getSingleton(void) {
- static ServiceDiscovery discoverySingleton;
-
- return &discoverySingleton;
-}
-
ble_error_t
ServiceDiscovery::launch(Gap::Handle_t connectionHandle, ServiceCallback_t sc, CharacteristicCallback_t cc)
{
@@ -62,7 +56,7 @@
}
void
-ServiceDiscovery::setupDiscoveredServices(const ble_gattc_evt_prim_srvc_disc_rsp_t *response)
+NordicServiceDiscovery::setupDiscoveredServices(const ble_gattc_evt_prim_srvc_disc_rsp_t *response)
{
currSrvInd = 0;
srvCount = response->count;
@@ -80,7 +74,7 @@
}
void
-ServiceDiscovery::setupDiscoveredCharacteristics(const ble_gattc_evt_char_disc_rsp_t *response)
+NordicServiceDiscovery::setupDiscoveredCharacteristics(const ble_gattc_evt_char_disc_rsp_t *response)
{
currCharInd = 0;
charCount = response->count;
--- a/btle/btle_discovery.h Fri Jun 19 15:55:21 2015 +0100
+++ b/btle/btle_discovery.h Fri Jun 19 15:55:21 2015 +0100
@@ -137,9 +137,6 @@
memset(characteristics, 0, sizeof(DiscoveredCharacteristic) * BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV);
}
- void setupDiscoveredServices(const ble_gattc_evt_prim_srvc_disc_rsp_t *response);
- void setupDiscoveredCharacteristics(const ble_gattc_evt_char_disc_rsp_t *response);
-
void progressCharacteristicDiscovery() {
while (characteristicDiscoveryInProgress && (currCharInd < charCount)) {
/* THIS IS WHERE THE CALLBACK WILL GO */
@@ -199,7 +196,7 @@
serviceDiscoveryInProgress = false;
}
-private:
+protected:
ServiceDiscovery() {
/* empty */
}
@@ -220,4 +217,10 @@
bool characteristicDiscoveryInProgress;
};
+class NordicServiceDiscovery : public ServiceDiscovery {
+public:
+ void setupDiscoveredServices(const ble_gattc_evt_prim_srvc_disc_rsp_t *response);
+ void setupDiscoveredCharacteristics(const ble_gattc_evt_char_disc_rsp_t *response);
+};
+
#endif /*_BTLE_DISCOVERY_H_*/
\ No newline at end of file
--- a/btle/btle_gattc.cpp Fri Jun 19 15:55:21 2015 +0100
+++ b/btle/btle_gattc.cpp Fri Jun 19 15:55:21 2015 +0100
@@ -18,20 +18,23 @@
#include "UUID.h"
#include "btle_discovery.h"
+static NordicServiceDiscovery discoverySingleton;
+ServiceDiscovery *ServiceDiscovery::getSingleton(void) {
+ return &discoverySingleton;
+}
+
void bleGattcEventHandler(const ble_evt_t *p_ble_evt)
{
- ServiceDiscovery *singleton = ServiceDiscovery::getSingleton();
-
switch (p_ble_evt->header.evt_id) {
case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP:
switch (p_ble_evt->evt.gattc_evt.gatt_status) {
case BLE_GATT_STATUS_SUCCESS:
- singleton->setupDiscoveredServices(&p_ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp);
+ discoverySingleton.setupDiscoveredServices(&p_ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp);
break;
case BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND:
default:
- singleton->terminate();
+ discoverySingleton.terminate();
break;
}
break;
@@ -39,17 +42,17 @@
case BLE_GATTC_EVT_CHAR_DISC_RSP:
switch (p_ble_evt->evt.gattc_evt.gatt_status) {
case BLE_GATT_STATUS_SUCCESS:
- singleton->setupDiscoveredCharacteristics(&p_ble_evt->evt.gattc_evt.params.char_disc_rsp);
+ discoverySingleton.setupDiscoveredCharacteristics(&p_ble_evt->evt.gattc_evt.params.char_disc_rsp);
break;
case BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND:
default:
- singleton->terminateCharacteristicDiscovery();
+ discoverySingleton.terminateCharacteristicDiscovery();
break;
}
break;
}
- singleton->progressCharacteristicDiscovery();
- singleton->progressServiceDiscovery();
+ discoverySingleton.progressCharacteristicDiscovery();
+ discoverySingleton.progressServiceDiscovery();
}
\ No newline at end of file
