Heart Rate Monitor example for the BLE API using nRF51822 native mode drivers
Dependencies: BLE_API mbed nRF51822 X_NUCLEO_IDB0XA1
Fork of BLE_HeartRate by
Diff: main.cpp
- Revision:
- 15:7ba28817e31e
- Parent:
- 13:3ca2045597e7
- Child:
- 16:f3361e20642d
--- a/main.cpp Tue Jun 10 14:37:18 2014 +0100 +++ b/main.cpp Tue Jun 10 14:40:29 2014 +0100 @@ -138,6 +138,9 @@ Ticker ticker; ticker.attach(periodicCallback, 1); + DEBUG("Initialising the nRF51822\n\r"); + ble.init(); + /* Setup the local GAP/GATT event handlers */ ble.onTimeout(timeoutCallback); ble.onConnection(connectionCallback); @@ -145,13 +148,10 @@ ble.onUpdatesEnabled(updatesEnabledCallback); ble.onUpdatesDisabled(updatesDisabledCallback); - DEBUG("Initialising the nRF51822\n\r"); - ble.init(); - + /* setup advertising */ ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED); ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list)); ble.accumulateAdvertisingPayload(GapAdvertisingData::HEART_RATE_SENSOR_HEART_RATE_BELT); - ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); ble.setAdvertisingInterval(160); /* 100ms; in multiples of 0.625ms. */ ble.startAdvertising();