test HeartRate+ BatteryLevel
Dependencies: BLE_API mbed nRF51822
Fork of BLE_HeartRate by
Diff: main.cpp
- Revision:
- 73:05069f4ba756
- Parent:
- 72:469dbde1a238
--- a/main.cpp Tue Sep 29 09:49:50 2015 +0000 +++ b/main.cpp Tue Sep 29 16:55:53 2015 +0000 @@ -56,6 +56,9 @@ HeartRateService hrService(ble, hrmCounter, HeartRateService::LOCATION_FINGER); /* Setup auxiliary service. */ + // BatteryService battery(ble); + uint8_t batteryLevel = 50; // init batteryLevel to 50% + BatteryService batteryService(ble, batteryLevel); DeviceInformationService deviceInfo(ble, "ARM", "Model1", "SN1", "hw-rev1", "fw-rev1", "soft-rev1"); /* Setup advertising. */ @@ -84,6 +87,12 @@ // update bps hrService.updateHeartRate(hrmCounter); + + batteryLevel++; + if (batteryLevel == 100) { + batteryLevel = 20; + } + batteryService.updateBatteryLevel(batteryLevel); } else { ble.waitForEvent(); // low power wait for event }