Implementation of Heart Rate Service on nRF52-DK with security (bonding/pairing procedure). Correct key for smartphone to enter is printed on serial. Baud rate 9600, 8 bits + 1 stop bit + no parity bit.

Fork of mbed-os-example-ble-HeartRate by mbed-os-examples

Revision:
69:f48bb19847e3
Parent:
68:50923da435f2
Child:
70:cae5b05ed2b9
--- a/source/main.cpp	Tue Oct 09 09:46:08 2018 +0000
+++ b/source/main.cpp	Tue Oct 09 23:03:58 2018 +0000
@@ -24,8 +24,10 @@
 
 const static char     DEVICE_NAME[] = "VT_HRM";
 static const uint16_t uuid16_list[] = {GattService::UUID_HEART_RATE_SERVICE};
+static uint8_t rriValues[100] = {880,860,860,860,870,880,890,910,920,930,940,940,950,940,950,940,950,950,950,950,530,1350,950,930,910,920,940,940,950,940,950,940,930,940,950,950,950,960,960,960,950,960,950,960,950,960,960,950,960,960,950,950,940,950,950,940,930,930,920,920,910,920,910,900,670,1130,910,880,880,870,660,1100,890,880,880,880,660,1110,910,890,900,900,690,1110,910,900,910,900,900,910,930,920,940,940,940,950,960,950,950,960};
+static uint16_t counter = 0;
+static uint8_t hrmCounter = 800; // init
 
-static uint8_t hrmCounter = 100; // init HRM to 100bps
 static HeartRateService *hrServicePtr;
 
 static EventQueue eventQueue(/* event count */ 16 * EVENTS_EVENT_SIZE);
@@ -38,11 +40,12 @@
 void updateSensorValue() {
     // Do blocking calls or whatever is necessary for sensor polling.
     // In our case, we simply update the HRM measurement.
-    hrmCounter++;
+    hrmCounter = rriValues[counter];
+    counter++;
 
-    //  100 <= HRM bps <=175
-    if (hrmCounter == 175) {
-        hrmCounter = 100;
+    //  There are x RRIs to cycle through (usually 1024)
+    if (counter == 100) {
+        counter = 0;
     }
     hrServicePtr->updateHeartRate(hrmCounter);
 }