cycle speed and cadence service
Dependencies: BLE_API mbed nRF51822
Fork of Bluetooth_Heart_Rate_Monitor_dummy by
Diff: main.cpp
- Revision:
- 62:2ea9997b5249
- Parent:
- 61:16f888838853
- Child:
- 63:e4f933430f17
--- a/main.cpp Mon May 04 17:18:12 2015 +0000 +++ b/main.cpp Mon May 04 21:55:15 2015 +0000 @@ -28,7 +28,7 @@ BLEDevice ble; DigitalOut led1(LED1); -const static char DEVICE_NAME[] = "ST HRM2"; +const static char DEVICE_NAME[] = "CSC tracker"; static const uint16_t uuid16_list[] = {GattService::UUID_CYCLING_SPEED_AND_CADENCE, GattService::UUID_DEVICE_INFORMATION_SERVICE}; static volatile bool triggerSensorPolling = false; @@ -58,8 +58,9 @@ /* Setup primary service. */ uint32_t counter = 0; // init HRM to 100bps - uint16_t event = 0; // init HRM to 100bps - CycleSpeedCadenceService speedService(ble, counter,event, CycleSpeedCadenceService::LOCATION_REAR_DROPOUT, false); + uint16_t cadence = 0; // init HRM to 100bps + uint16_t event = 1; // init HRM to 100bps + CycleSpeedCadenceService speedService(ble, counter,event,cadence,event, CycleSpeedCadenceService::LOCATION_REAR_DROPOUT, false); /* Setup auxiliary service. */ DeviceInformationService deviceInfo(ble, "ARM", "Model1", "SN1", "hw-rev1", "fw-rev1", "soft-rev1"); @@ -67,7 +68,7 @@ /* Setup advertising. */ ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list)); - ble.accumulateAdvertisingPayload(GapAdvertisingData::GENERIC_HEART_RATE_SENSOR); + ble.accumulateAdvertisingPayload(GapAdvertisingData::CYCLING_SPEED_AND_CADENCE_SENSOR); ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); ble.setAdvertisingInterval(1000); @@ -82,11 +83,13 @@ // Do blocking calls or whatever is necessary for sensor polling. // In our case, we simply update the HRM measurement. counter++; + cadence++; // update bps speedService.updateWheel(counter,event); + speedService.updateCrank(cadence,event); } else { ble.waitForEvent(); // low power wait for event }