cycle speed and cadence service

Dependencies:   BLE_API mbed nRF51822

Fork of Bluetooth_Heart_Rate_Monitor_dummy by Icarus Sensors

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);