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:
- 23:a31b178e2263
- Parent:
- 22:985657fc70c8
- Child:
- 24:d352571b1c1f
--- a/main.cpp Mon Jun 26 16:30:16 2017 +0000 +++ b/main.cpp Mon Jun 26 21:23:48 2017 +0000 @@ -16,14 +16,22 @@ #include "mbed.h" #include "ble/BLE.h" +#include "bike_service.h" #include "ble/services/HeartRateService.h" +#include "ble/services/BatteryService.h" DigitalOut led1(LED1, 1); -const static char DEVICE_NAME[] = "HRM1"; -static const uint16_t uuid16_list[] = {GattService::UUID_HEART_RATE_SERVICE}; +const static char DEVICE_NAME[] = "HeckBike"; +static const uint16_t uuid16_list[] = {GattService::UUID_HEART_RATE_SERVICE, + GattService::UUID_BATTERY_SERVICE, + 0x8EC5};//made up UUID for the Heck bike uint8_t hrmCounter = 60; // init HRM to 60bps + uint8_t inputs = 0x00; + uint8_t outputs = 0x00; + uint32_t timestamp = 0x00; + static volatile bool triggerSensorPolling = false; void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params) @@ -70,11 +78,12 @@ ble.gattServer().onDataWritten(onDataWrittenCallback); /* Setup primary service. */ HeartRateService hrService(ble, hrmCounter, HeartRateService::LOCATION_FINGER); - + /* Setup battery service. */ + BatteryService btService(ble,100); /* Setup advertising. */ ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list)); - ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::GENERIC_HEART_RATE_SENSOR); + ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::GENERIC_CYCLING); ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); ble.gap().setAdvertisingInterval(1000); /* 1000ms */