Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API mbed nRF51822 X_NUCLEO_IDB0XA1
Fork of BLE_HeartRate by
Revision 37:d310a72115c7, committed 2014-07-11
- Comitter:
- Rohit Grover
- Date:
- Fri Jul 11 11:34:55 2014 +0100
- Parent:
- 36:ea2a1b4f51c1
- Child:
- 38:b2efa4f73d3a
- Commit message:
- updated heart-rate demo to use the new connectionParams APIs
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Jul 11 11:12:42 2014 +0100
+++ b/main.cpp Fri Jul 11 11:34:55 2014 +0100
@@ -52,6 +52,7 @@
static volatile bool triggerSensorPolling = false; /* set to high periodically to indicate to the main thread that
* polling is necessary. */
+static Gap::ConnectionParams_t connectionParams;
void disconnectionCallback(Gap::Handle_t handle)
{
@@ -60,6 +61,16 @@
ble.startAdvertising();
}
+void onConnectionCallback(Gap::Handle_t handle)
+{
+ DEBUG("connected. Got handle %u\r\n", handle);
+
+ connectionParams.slaveLatency = 1;
+ if (ble.updateConnectionParams(handle, &connectionParams) != BLE_ERROR_NONE) {
+ DEBUG("failed to update connection paramter\r\n");
+ }
+}
+
/**
* Triggered periodically by the 'ticker' interrupt.
*/
@@ -81,6 +92,9 @@
DEBUG("Initialising the nRF51822\n\r");
ble.init();
ble.onDisconnection(disconnectionCallback);
+ ble.onConnection(onConnectionCallback);
+
+ ble.getPreferredConnectionParams(&connectionParams);
/* setup advertising */
ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
