From 430b40886c90dc24d844fb0e1851f4cf94b4c6a7 Mon Sep 17 00:00:00 2001
From: Denis Bobrovskiy <denis.bobrovskiy3@gmail.com>
Date: Sun, 28 Feb 2021 15:33:52 +0000
Subject: [PATCH] Modified code to add walking game over characteristic

---
 wristwatch-test.cpp | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/wristwatch-test.cpp b/wristwatch-test.cpp
index 560619b..4476126 100644
--- a/wristwatch-test.cpp
+++ b/wristwatch-test.cpp
@@ -12,6 +12,7 @@
 #define GPS_CHAR_UUID "3d4512a1-e027-473d-b880-f58e75ad8a9e"
 #define STEP_COUNTER_CHAR_UUID "5609995a-8003-4f11-bd73-8ae0eee8d004"
 #define HEART_RATE_CHAR_UUID "50787168-dec5-437c-a6ab-e52fa492c85c"
+#define WALKING_GAME_OVER_CHAR_UUID "3c79b9e0-c841-42a5-8641-a456e335460b"
 
 
 #define GPS_DATA_UPLOAD_INTERVAL 3  //in seconds
@@ -19,9 +20,11 @@
 BLECharacteristic *gpsChar;
 BLECharacteristic *stepCounterChar;
 BLECharacteristic *heartRateChar;
+BLECharacteristic *walkingGameOverChar;
 
 //For testing
 uint8_t tempCounter1 = 0;
+uint32_t tempCounter2 = 0;
 
 
 void gpsThread(void *parameter){
@@ -47,13 +50,11 @@ void gpsThread(void *parameter){
 void stepCounterThread(void *parameter){
   for(;;){
     Serial.println("Looping step counter thread");
-    unsigned char tempToggle = 0;
 
     //Toggle this value between 0 and 1 for every new step detected
-    tempToggle = tempToggle?0:1;
-    stepCounterChar->setValue(&tempToggle,1);
+    stepCounterChar->setValue(tempCounter2); //Put in a uint32_t 
     stepCounterChar->notify();
-
+    tempCounter2++;
     delay(500);
   }
 }
@@ -105,11 +106,18 @@ void setup() {
                                          BLECharacteristic::PROPERTY_NOTIFY |
                                          BLECharacteristic::PROPERTY_INDICATE
                                        );
-
+  walkingGameOverChar = mainService->createCharacteristic(
+                                         WALKING_GAME_OVER_CHAR_UUID,
+                                         BLECharacteristic::PROPERTY_READ |
+                                         BLECharacteristic::PROPERTY_WRITE |
+                                         BLECharacteristic::PROPERTY_NOTIFY |
+                                         BLECharacteristic::PROPERTY_INDICATE
+                                       );
   //Add descriptor to set up notifications
   gpsChar->addDescriptor(new BLE2902());
   stepCounterChar->addDescriptor(new BLE2902());
   heartRateChar->addDescriptor(new BLE2902());
+  walkingGameOverChar->addDescriptor(new BLE2902());
 
   //Set initial values (this doesnt really matter)
   gpsChar->setValue("GPS initial data");
-- 
GitLab