test HeartRate+ BatteryLevel

Dependencies:   BLE_API mbed nRF51822

Fork of BLE_HeartRate by Bluetooth Low Energy

/media/uploads/szqt/img_0062-001.jpg

Files at this revision

API Documentation at this revision

Comitter:
szqt
Date:
Tue Sep 29 15:12:05 2015 +0000
Parent:
70:0a19690e8d23
Commit message:
Add batteryLevel

Changed in this revision

BLE_API.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
nRF51822.lib Show annotated file Show diff for this revision Revisions of this file
--- a/BLE_API.lib	Tue Aug 11 21:58:13 2015 +0000
+++ b/BLE_API.lib	Tue Sep 29 15:12:05 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#920101117187
+http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#d494ad3e87bd
--- a/main.cpp	Tue Aug 11 21:58:13 2015 +0000
+++ b/main.cpp	Tue Sep 29 15:12:05 2015 +0000
@@ -22,10 +22,12 @@
 
 BLE  ble;
 DigitalOut led1(LED1);
+DigitalOut led2(LED2);
 
 const static char     DEVICE_NAME[]        = "HRM1";
 static const uint16_t uuid16_list[]        = {GattService::UUID_HEART_RATE_SERVICE,
-                                              GattService::UUID_DEVICE_INFORMATION_SERVICE};
+        GattService::UUID_DEVICE_INFORMATION_SERVICE
+                                             };
 static volatile bool  triggerSensorPolling = false;
 
 void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
@@ -44,7 +46,9 @@
 
 int main(void)
 {
+    uint8_t batteryLevel = 50;
     led1 = 1;
+    led2 = 0; 
     Ticker ticker;
     ticker.attach(periodicCallback, 1); // blink LED every second
 
@@ -56,6 +60,8 @@
     HeartRateService hrService(ble, hrmCounter, HeartRateService::LOCATION_FINGER);
 
     /* Setup auxiliary service. */
+    // BatteryService           battery(ble);
+    BatteryService batteryService(ble, batteryLevel);
     DeviceInformationService deviceInfo(ble, "ARM", "Model1", "SN1", "hw-rev1", "fw-rev1", "soft-rev1");
 
     /* Setup advertising. */
@@ -82,9 +88,20 @@
                 hrmCounter = 100;
             }
 
+
+
             // update bps
             hrService.updateHeartRate(hrmCounter);
+
+            batteryLevel++;
+            if (batteryLevel > 100) {
+                batteryLevel = 20;
+            }
+
+            batteryService.updateBatteryLevel(batteryLevel);
+            led2 = 1;
         } else {
+            led2 = 0;
             ble.waitForEvent(); // low power wait for event
         }
     }
--- a/mbed.bld	Tue Aug 11 21:58:13 2015 +0000
+++ b/mbed.bld	Tue Sep 29 15:12:05 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/b9ad9a133dc7
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/4f6c30876dfa
\ No newline at end of file
--- a/nRF51822.lib	Tue Aug 11 21:58:13 2015 +0000
+++ b/nRF51822.lib	Tue Sep 29 15:12:05 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#041752486b03
+http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#088f5738bf18