Chanel's edits

Dependencies:   max32630fthr USBDevice

Revision:
15:b15b4b6c6da8
Parent:
14:ee2175578993
--- a/PPGService.h	Tue Mar 10 08:22:53 2020 +0000
+++ b/PPGService.h	Tue Mar 10 20:33:49 2020 +0000
@@ -58,6 +58,10 @@
  * heart rate services to one.
  */
  extern Serial pc;
+ const char* UUID_STR_PPG_SERVICE  = "E14C6C9D-3497-4835-8F8B-28D7AF2E6A15";
+ const char* UUID_STR_PPG_RED_CHAR  = "E14C6C9D-3497-4836-8F8B-28D7AF2E6A15";
+ const char* UUID_STR_PPG_IR_CHAR  = "E14C6C9D-3497-4837-8F8B-28D7AF2E6A15";
+
  
 class PPGService {
 
@@ -75,16 +79,22 @@
      * sensor.
      * @param[in] location Intended location of the heart rate sensor.
      */
-    PPGService(BLE &_ble, int16_t ppgVal) :
+    PPGService(BLE &_ble, int16_t ppgValRed, int16_t ppgValIR) :
         ble(_ble),
-        valueBytes(ppgVal),
-        ppgValue(
-            GattCharacteristic::UUID_HEART_RATE_MEASUREMENT_CHAR, //TODO: replace with UUID for PPG sample characteristic
-            valueBytes.getPointer(),
-            valueBytes.getNumValueBytes(),
-            HeartRateValueBytes::MAX_VALUE_BYTES,
-            GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY
-        )
+        valueBytesRed(ppgValRed),
+        valueBytesIR(ppgValIR),
+        ppgValueRed(
+            UUID_STR_PPG_RED_CHAR, //TODO: replace with UUID for PPG sample characteristic
+            valueBytesRed.getPointer(),
+            valueBytesRed.getNumValueBytes(),
+            PPGValueBytes::MAX_VALUE_BYTES,
+            GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY),
+        ppgValueIR(
+            UUID_STR_PPG_IR_CHAR, //TODO: replace with UUID for PPG sample characteristic
+            valueBytesIR.getPointer(),
+            valueBytesIR.getNumValueBytes(),
+            PPGValueBytes::MAX_VALUE_BYTES,
+            GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY)
     {
         //pc.printf("Setup service");
         setupService();
@@ -103,12 +113,20 @@
      * @attention This function must be called in the execution context of the
      * BLE stack.
      */
-    void updatePPGValue(uint16_t ppgVal) {
-        valueBytes.updatePPGValue(ppgVal);
+    void updatePPGRedValue(uint16_t ppgVal) {
+        valueBytesRed.updatePPGValue(ppgVal);
         ble.gattServer().write(
-            ppgValue.getValueHandle(),
-            valueBytes.getPointer(),
-            valueBytes.getNumValueBytes()
+            ppgValueRed.getValueHandle(),
+            valueBytesRed.getPointer(),
+            valueBytesRed.getNumValueBytes()
+        );
+    }
+    void updatePPGIRValue(uint16_t ppgVal) {
+        valueBytesIR.updatePPGValue(ppgVal);
+        ble.gattServer().write(
+            ppgValueIR.getValueHandle(),
+            valueBytesIR.getPointer(),
+            valueBytesIR.getNumValueBytes()
         );
     }
 
@@ -118,22 +136,23 @@
      */
     void setupService(void) {
         GattCharacteristic *charTable[] = {
-            &ppgValue
+            &ppgValueRed,
+            &ppgValueIR
         };
-        GattService hrmService(
-            GattService::UUID_HEART_RATE_SERVICE, //TODO: ECG service UUID
+        GattService ppgService(
+            UUID_STR_PPG_SERVICE, //TODO: ECG service UUID
             charTable,
             sizeof(charTable) / sizeof(GattCharacteristic*)
         );
 
-        ble.gattServer().addService(hrmService);
+        ble.gattServer().addService(ppgService);
     }
 
 protected:
     /*
      * Heart rate measurement value.
      */
-    struct HeartRateValueBytes {
+    struct PPGValueBytes {
         /* 1 byte for the Flags, and up to two bytes for heart rate value. */
         static const unsigned MAX_VALUE_BYTES = 2; // int16 per ECG sample
         static const unsigned FLAGS_BYTE_INDEX = 0;
@@ -141,7 +160,7 @@
         static const unsigned VALUE_FORMAT_BITNUM = 0;
         static const uint8_t  VALUE_FORMAT_FLAG = (1 << VALUE_FORMAT_BITNUM);
 
-        HeartRateValueBytes(int16_t ppgVal) : valueBytes()
+        PPGValueBytes(int16_t ppgVal) : valueBytes()
         {
             updatePPGValue(ppgVal);
         }
@@ -180,8 +199,10 @@
 
 protected:
     BLE &ble;
-    HeartRateValueBytes valueBytes;
-    GattCharacteristic ppgValue;
+    PPGValueBytes valueBytesRed;
+    PPGValueBytes valueBytesIR;
+    GattCharacteristic ppgValueRed;
+    GattCharacteristic ppgValueIR;
 };
 
 //#endif // BLE_FEATURE_GATT_SERVER