Chanel's edits

Dependencies:   max32630fthr USBDevice

Revision:
10:28b8729cf5dc
Parent:
7:4debec043316
Child:
14:ee2175578993
--- a/bt32630.h	Mon Mar 02 23:14:08 2020 +0000
+++ b/bt32630.h	Sat Mar 07 03:19:35 2020 +0000
@@ -7,9 +7,9 @@
 static const uint16_t uuid16_list[] = {GattService::UUID_HEART_RATE_SERVICE};
 
 
-static int32_t hrmCounter = 100; // init HRM to 100bps
+static int16_t hrmCounter = 100; // init HRM to 100bps
 //static HeartRateService *hrServicePtr;
-static ECGService *hrServicePtr;
+extern ECGService *hrServicePtr;
 
 static EventQueue eventQueue(/* event count */ 16 * EVENTS_EVENT_SIZE);
 
@@ -27,20 +27,25 @@
 void updateSensorValue() {
     // 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;
-    }*/
-    //pc.printf("Inside update sensor value \n");
-    if(max86150Sensor.check()>0)
-        {
-        hrServicePtr->updateHeartRate((uint16_t)max86150Sensor.getFIFOECG());
-        return;
-        }
+    }
+
     //hrmCounter = 133;
-    //hrServicePtr->updateHeartRate(hrmCounter);
+    hrServicePtr->updateHeartRate(hrmCounter);
+    */
+    int16_t ecgsigned16;
+    if(max86150Sensor.check()>0){         
+        ecgsigned16 = (int16_t) (max86150Sensor.getFIFOECG()>>2);
+        max86150Sensor.nextSample();
+        //hrServicePtr->updateHeartRate(ecgsigned16);
+        pc.printf("%d\n",ecgsigned16);
+    }
+    
+    
 }
 
 void periodicCallback(void)
@@ -60,24 +65,20 @@
 
 void bleInitComplete(BLE::InitializationCompleteCallbackContext *params)
 {
-    pc.printf("In bleInitComplete() ...\n");
     BLE&        ble   = params->ble;
     ble_error_t error = params->error;
 
     if (error != BLE_ERROR_NONE) {
-        pc.printf("In ERROR if ...\n");
         onBleInitError(ble, error);
         return;
     }
 
     if (ble.getInstanceID() != BLE::DEFAULT_INSTANCE) {
-        pc.printf("In InstanceID ERROR if ...\n");
         return;
     }
 
     ble.gap().onDisconnection(disconnectionCallback);
     ble.gap().onConnection(connectionCallback);
-    pc.printf("Set connection/disconnection callbacks ...\n");
 
     /* Setup primary service. */
     //hrServicePtr = new HeartRateService(ble, hrmCounter, HeartRateService::LOCATION_FINGER);
@@ -90,12 +91,12 @@
     ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list));
     ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::GENERIC_HEART_RATE_SENSOR);
     ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));
-    pc.printf("Accumulate asvertising payload done ...\n");
+
     ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
     ble.gap().setAdvertisingInterval(1000); /* 1000ms */
-    pc.printf("Before startAdvertising() ...\n");
+ 
     ble.gap().startAdvertising();
-    pc.printf("After startAdvertising() ...\n");
+
     pc.printf("Exiting bleInitComplete() ... \n");
     return;
 }