We are making a bluetooth application for a vehicle.
Dependencies: BLE_API X_NUCLEO_IDB0XA1 mbed
Fork of BLE_HeartRate_IDB0XA1 by
Diff: main.cpp
- Revision:
- 22:985657fc70c8
- Parent:
- 21:0e7c08f5386f
- Child:
- 23:a31b178e2263
--- a/main.cpp Wed Oct 05 09:16:58 2016 +0000 +++ b/main.cpp Mon Jun 26 16:30:16 2017 +0000 @@ -23,6 +23,7 @@ const static char DEVICE_NAME[] = "HRM1"; static const uint16_t uuid16_list[] = {GattService::UUID_HEART_RATE_SERVICE}; + uint8_t hrmCounter = 60; // init HRM to 60bps static volatile bool triggerSensorPolling = false; void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params) @@ -46,6 +47,10 @@ /* Initialization error handling should go here */ } +void onDataWrittenCallback(const GattWriteCallbackParams *params) { + hrmCounter = *(params->data); +} + void bleInitComplete(BLE::InitializationCompleteCallbackContext *params) { BLE& ble = params->ble; @@ -62,8 +67,8 @@ ble.gap().onDisconnection(disconnectionCallback); + ble.gattServer().onDataWritten(onDataWrittenCallback); /* Setup primary service. */ - uint8_t hrmCounter = 60; // init HRM to 60bps HeartRateService hrService(ble, hrmCounter, HeartRateService::LOCATION_FINGER); /* Setup advertising. */