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
Fork of BLE_HeartRate by
Diff: main.cpp
- Revision:
- 37:d310a72115c7
- Parent:
- 36:ea2a1b4f51c1
- Child:
- 39:6390604f904c
--- 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);
