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 mbed-os-example-ble-BatteryLevel by
Revision 74:923be844d0fe, committed 2018-10-24
- Comitter:
- vazbyte
- Date:
- Wed Oct 24 13:28:56 2018 +0000
- Parent:
- 73:4bce85f91e5a
- Child:
- 75:fc7f3b141378
- Commit message:
- changed battery to heartbeat service
Changed in this revision
| source/main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/source/main.cpp Wed Oct 24 09:44:30 2018 +0000
+++ b/source/main.cpp Wed Oct 24 13:28:56 2018 +0000
@@ -19,14 +19,16 @@
#include "ble/BLE.h"
#include "ble/Gap.h"
#include "ble/services/BatteryService.h"
+#include "ble/services/HeartRateService.h"
DigitalOut led1(LED1, 1);
const static char DEVICE_NAME[] = "ProVaida";
-static const uint16_t uuid16_list[] = {GattService::UUID_BATTERY_SERVICE};
+static const uint16_t uuid16_list[] = {GattService::UUID_HEART_RATE_SERVICE};
+//static const uint16_t uuid16_list[] = {GattService::UUID_BATTERY_SERVICE};
-static uint8_t batteryLevel = 50;
-static BatteryService* batteryServicePtr;
+uint8_t hrmCounter = 100;
+static HeartRateService* hrService;
static EventQueue eventQueue(/* event count */ 16 * EVENTS_EVENT_SIZE);
@@ -36,12 +38,12 @@
}
void updateSensorValue() {
- batteryLevel++;
- if (batteryLevel > 100) {
- batteryLevel = 20;
+ hrmCounter++;
+ if (hrmCounter > 175) {
+ hrmCounter = 100;
}
-
- batteryServicePtr->updateBatteryLevel(batteryLevel);
+ hrService->updateHeartRate(hrmCounter);
+ //batteryServicePtr->updateBatteryLevel(batteryLevel);
}
void blinkCallback(void)
@@ -55,7 +57,7 @@
}
/**
- * This function is called when the ble initialization process has failled
+ * This function is called when the ble initialization process has failed
*/
void onBleInitError(BLE &ble, ble_error_t error)
{
@@ -97,7 +99,7 @@
ble.gap().onDisconnection(disconnectionCallback);
/* Setup primary service */
- batteryServicePtr = new BatteryService(ble, batteryLevel);
+ hrService = new HeartBeatService(ble, hrmCounter);
/* Setup advertising */
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
