heart rate monitor

Dependencies:   BLE_API GroveEarbudSensor mbed nRF51822

Fork of BLE_HeartRate by Bluetooth Low Energy

Revision:
73:32250c7c8e68
Parent:
72:cc9b1d195d9f
--- a/main.cpp	Sat Aug 29 18:44:12 2015 +0000
+++ b/main.cpp	Sat Aug 29 18:48:08 2015 +0000
@@ -28,21 +28,23 @@
 
 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;
-   /* Setup primary service. */
-    uint8_t hrmCounter = 100; // init HRM to 100bps
+/* Setup primary service. */
+uint8_t hrmCounter = 100; // init HRM to 100bps
 
 
 // callback for receiving heartrate values
-void heartrateCallback(float heartrate,void *data) {
+void heartrateCallback(float heartrate,void *data)
+{
     printf("Callback: heartrate = %.1f\r\n",heartrate);
-                // we can also call directly 
-            hrmCounter=heartrate;
-    
+    // we can also call directly
+    hrmCounter=heartrate;
 
-            // update bps
-            //hrService.updateHeartRate(hrmCounter);  
+
+    // update bps
+    //hrService.updateHeartRate(hrmCounter);
 }
 void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
 {
@@ -67,7 +69,7 @@
     ble.init();
     ble.gap().onDisconnection(disconnectionCallback);
 
-    
+
     HeartRateService hrService(ble, hrmCounter, HeartRateService::LOCATION_FINGER);
 
     /* Setup auxiliary service. */
@@ -81,17 +83,17 @@
     ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
     ble.gap().setAdvertisingInterval(1000); /* 1000ms */
     ble.gap().startAdvertising();
-                // announce
-            printf("Grove Earbud Sensor - Montoring Heart Rate\r\n");
+    // announce
+    printf("Grove Earbud Sensor - Montoring Heart Rate\r\n");
 
-            // allocate the earbud sensor
-             printf("Allocating earbud sensor instance...\r\n");
-             GroveEarbudSensor earbud(&sensor); 
-    
-            // register our callback function
-             printf("registering callback...\r\n");
-            earbud.registerCallback(heartrateCallback);
- 
+    // allocate the earbud sensor
+    printf("Allocating earbud sensor instance...\r\n");
+    GroveEarbudSensor earbud(&sensor);
+
+    // register our callback function
+    printf("registering callback...\r\n");
+    earbud.registerCallback(heartrateCallback);
+
     // infinite loop
     while (1) {
         // check for trigger from periodicCallback()
@@ -100,16 +102,16 @@
 
             // Do blocking calls or whatever is necessary for sensor polling.
             // In our case, we simply update the HRM measurement.
-           // hrmCounter++;
+            // hrmCounter++;
 
             //  100 <= HRM bps <=175
             /*if (hrmCounter == 175) {
                 hrmCounter = 100;
             }*/
 
-            // blink... 
-            led1 = !led1; 
-             wait(0.5);
+            // blink...
+            led1 = !led1;
+            wait(0.5);
             hrService.updateHeartRate(hrmCounter);
         } else {
             ble.waitForEvent(); // low power wait for event