High level Bluetooth Low Energy API and radio abstraction layer

Dependencies:   nRF51822

Dependents:   LinkNode_LIS3DH

Fork of BLE_API by Bluetooth Low Energy

Files at this revision

API Documentation at this revision

Comitter:
rgrover1
Date:
Fri Jun 19 15:52:06 2015 +0100
Parent:
519:4af237e9f913
Child:
521:b2dae8d95c4d
Commit message:
Synchronized with git rev 1298a1dd
Author: Rohit Grover
certain services like the batteryService and heartRateService don't need to be singletons.

Changed in this revision

services/BatteryService.h Show annotated file Show diff for this revision Revisions of this file
services/HeartRateService.h Show annotated file Show diff for this revision Revisions of this file
--- a/services/BatteryService.h	Fri Jun 19 15:52:05 2015 +0100
+++ b/services/BatteryService.h	Fri Jun 19 15:52:06 2015 +0100
@@ -38,16 +38,10 @@
         batteryLevel(level),
         batteryLevelCharacteristic(GattCharacteristic::UUID_BATTERY_LEVEL_CHAR, &batteryLevel, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) {
 
-        static bool serviceAdded = false; /* We should only ever need to add the heart rate service once. */
-        if (serviceAdded) {
-            return;
-        }
-
         GattCharacteristic *charTable[] = {&batteryLevelCharacteristic};
         GattService         batteryService(GattService::UUID_BATTERY_SERVICE, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
 
         ble.addService(batteryService);
-        serviceAdded = true;
     }
 
     /**
--- a/services/HeartRateService.h	Fri Jun 19 15:52:05 2015 +0100
+++ b/services/HeartRateService.h	Fri Jun 19 15:52:06 2015 +0100
@@ -127,17 +127,10 @@
 
 private:
     void setupService(void) {
-        static bool serviceAdded = false; /* We should only ever need to add the heart rate service once. */
-        if (serviceAdded) {
-            return;
-        }
-
         GattCharacteristic *charTable[] = {&hrmRate, &hrmLocation, &controlPoint};
         GattService         hrmService(GattService::UUID_HEART_RATE_SERVICE, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
 
         ble.addService(hrmService);
-        serviceAdded = true;
-
         ble.onDataWritten(this, &HeartRateService::onDataWritten);
     }