workss
Dependencies: mbed BLE_API nRF51822 VL53L0X
Diff: main.cpp
- Revision:
- 32:b9306ebceb61
- Parent:
- 31:d1ceadbc6c44
- Child:
- 33:3fad9e7238a4
--- a/main.cpp Wed Mar 13 19:52:07 2019 +0000 +++ b/main.cpp Wed Mar 13 19:58:19 2019 +0000 @@ -45,8 +45,13 @@ HeartRateService *hrService; uint8_t hrmCounter = 0; +void connectionCallback(const Gap::ConnectionCallbackParams_t *) { + printf("Bluetooth connected\n"); +} + void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *) { + printf("Bluetooth disconnected\n"); BLE::Instance(BLE::DEFAULT_INSTANCE).gap().startAdvertising(); } @@ -58,7 +63,8 @@ if (error != BLE_ERROR_NONE) { return; } - + + ble.gap().onConnection(connectionCallback); ble.gap().onDisconnection(disconnectionCallback); hrService = new HeartRateService(ble, hrmCounter, HeartRateService::LOCATION_FINGER); @@ -116,13 +122,10 @@ countdown = cw; } else if (countdown2_triggered) { printf("STEP IN DETECTED\n"); -// hrmCounter = 1; -// hrService->updateHeartRate(hrmCounter); + hrmCounter = 1; + hrService->updateHeartRate(hrmCounter); countdown2_triggered = false; } - - hrmCounter = dist1; - hrService->updateHeartRate(hrmCounter); } else { led1 = 1; @@ -141,13 +144,10 @@ countdown = cw; } else if (countdown1_triggered) { printf("STEP OUT DETECTED\n"); -// hrmCounter = 16; -// hrService->updateHeartRate(hrmCounter); + hrmCounter = 16; + hrService->updateHeartRate(hrmCounter); countdown1_triggered = false; } - - hrmCounter = dist2; - hrService->updateHeartRate(hrmCounter); } } else { printf("Range2 [mm]: --\r\n");