High level Bluetooth Low Energy API and radio abstraction layer

Dependencies:   nRF51822

Dependents:   LinkNode_LIS3DH

Fork of BLE_API by Bluetooth Low Energy

Revision:
667:875aecb84719
Parent:
664:1624b24837d0
Child:
669:7179b4a5aa7d
--- a/services/BatteryService.h	Fri Jun 19 15:53:01 2015 +0100
+++ b/services/BatteryService.h	Fri Jun 19 15:53:01 2015 +0100
@@ -38,10 +38,16 @@
         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;
     }
 
     /**
@@ -56,7 +62,7 @@
         ble.updateCharacteristicValue(batteryLevelCharacteristic.getValueAttribute().getHandle(), &batteryLevel, 1);
     }
 
-protected:
+private:
     BLEDevice &ble;
 
     uint8_t    batteryLevel;