Demo Glucose Service
Dependencies: BLE_API mbed nRF51822
Fork of BLE_HeartRate by
BLE_Glucose_demo implements the Glucose Service which enables a collector device to connect and interact with.
There is a brief sample code edited with Android Studio for demo this BLE_Glucose_demo example, and it is public on github, everyone can clone it by this URL: https://github.com/Marcomissyou/BluetoothLeGlucose.git. It is convenient for you to development your BLE idea.
There is also provided apk file so you can download and install it directly then demo this code, but make sure your Android phone supports Bluetooth 4.0. /media/uploads/Marcomissyou/bleglucoseservice.apk
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);