Skip to content
Snippets Groups Projects
Commit 430b4088 authored by Denis Bobrovskiy's avatar Denis Bobrovskiy
Browse files

Modified code to add walking game over characteristic

parent d1b0a443
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#define GPS_CHAR_UUID "3d4512a1-e027-473d-b880-f58e75ad8a9e" #define GPS_CHAR_UUID "3d4512a1-e027-473d-b880-f58e75ad8a9e"
#define STEP_COUNTER_CHAR_UUID "5609995a-8003-4f11-bd73-8ae0eee8d004" #define STEP_COUNTER_CHAR_UUID "5609995a-8003-4f11-bd73-8ae0eee8d004"
#define HEART_RATE_CHAR_UUID "50787168-dec5-437c-a6ab-e52fa492c85c" #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 #define GPS_DATA_UPLOAD_INTERVAL 3 //in seconds
...@@ -19,9 +20,11 @@ ...@@ -19,9 +20,11 @@
BLECharacteristic *gpsChar; BLECharacteristic *gpsChar;
BLECharacteristic *stepCounterChar; BLECharacteristic *stepCounterChar;
BLECharacteristic *heartRateChar; BLECharacteristic *heartRateChar;
BLECharacteristic *walkingGameOverChar;
//For testing //For testing
uint8_t tempCounter1 = 0; uint8_t tempCounter1 = 0;
uint32_t tempCounter2 = 0;
void gpsThread(void *parameter){ void gpsThread(void *parameter){
...@@ -47,13 +50,11 @@ void gpsThread(void *parameter){ ...@@ -47,13 +50,11 @@ void gpsThread(void *parameter){
void stepCounterThread(void *parameter){ void stepCounterThread(void *parameter){
for(;;){ for(;;){
Serial.println("Looping step counter thread"); Serial.println("Looping step counter thread");
unsigned char tempToggle = 0;
//Toggle this value between 0 and 1 for every new step detected //Toggle this value between 0 and 1 for every new step detected
tempToggle = tempToggle?0:1; stepCounterChar->setValue(tempCounter2); //Put in a uint32_t
stepCounterChar->setValue(&tempToggle,1);
stepCounterChar->notify(); stepCounterChar->notify();
tempCounter2++;
delay(500); delay(500);
} }
} }
...@@ -105,11 +106,18 @@ void setup() { ...@@ -105,11 +106,18 @@ void setup() {
BLECharacteristic::PROPERTY_NOTIFY | BLECharacteristic::PROPERTY_NOTIFY |
BLECharacteristic::PROPERTY_INDICATE 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 //Add descriptor to set up notifications
gpsChar->addDescriptor(new BLE2902()); gpsChar->addDescriptor(new BLE2902());
stepCounterChar->addDescriptor(new BLE2902()); stepCounterChar->addDescriptor(new BLE2902());
heartRateChar->addDescriptor(new BLE2902()); heartRateChar->addDescriptor(new BLE2902());
walkingGameOverChar->addDescriptor(new BLE2902());
//Set initial values (this doesnt really matter) //Set initial values (this doesnt really matter)
gpsChar->setValue("GPS initial data"); gpsChar->setValue("GPS initial data");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment