workss
Dependencies: mbed BLE_API nRF51822 VL53L0X
Diff: main.cpp
- Revision:
- 25:0a0805c118c0
- Parent:
- 24:931eeb8a70fc
- Child:
- 26:793d65b08afb
--- a/main.cpp Thu Mar 07 14:44:31 2019 +0000 +++ b/main.cpp Thu Mar 07 19:01:23 2019 +0000 @@ -1,7 +1,9 @@ #include "mbed.h" #include "ble/BLE.h" -#include "mbed.h" #include "VL53L0X.h" +#include "ble/services/HeartRateService.h" +#include "ble/services/BatteryService.h" +#include "ble/services/DeviceInformationService.h" #define range1_addr (0x56) #define range2_addr (0x60) @@ -30,7 +32,11 @@ int status2; const static char DEVICE_NAME[] = "OCCUPY-CRICHTON-ST"; // change this -static const uint16_t uuid16_list[] = {0xFFFF}; //Custom UUID, FFFF is reserved for development +static const uint16_t uuid16_list[] = {GattService::UUID_HEART_RATE_SERVICE}; //Custom UUID, FFFF is reserved for development + +HeartRateService *hrService; +DeviceInformationService *deviceInfo; +uint8_t hrmCounter = 100; // init HRM to 100bps /* Set Up custom Characteristics */ static uint8_t readValue[10] = {0}; @@ -80,19 +86,16 @@ } ble.gap().onDisconnection(disconnectionCallback); - ble.gattServer().onDataWritten(writeCharCallback); + hrService = new HeartRateService(ble, hrmCounter, HeartRateService::LOCATION_FINGER); - /* Setup advertising */ ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); // BLE only, no classic BT ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); // advertising type ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); // add name ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list)); // UUID's broadcast in advertising packet ble.gap().setAdvertisingInterval(100); // 100ms. + ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::GENERIC_HEART_RATE_SENSOR); - /* Add our custom service */ ble.addService(customService); - - /* Start advertising */ ble.gap().startAdvertising(); } void wakeup_event_cb() {