BLE demo for the Health-Thermometer service.

Dependencies:   BLE_API mbed nRF51822 X_NUCLEO_IDB0XA1

This example demonstrates how to use the Health Thermometer Service. The Health Thermometer service reports two pieces of information, Temperature and Sensor Location.

API

Import library

Public Types

enum SensorLocation_t {
LOCATION_ARMPIT = 1, LOCATION_BODY , LOCATION_EAR , LOCATION_FINGER ,
LOCATION_GI_TRACT , LOCATION_MOUTH , LOCATION_RECTUM , LOCATION_TOE ,
LOCATION_EAR_DRUM
}

Public Member Functions

HealthThermometerService ( BLE &_ble, float initialTemp, uint8_t _location)
Add the Health Thermometer Service to an existing BLE object, initialize with temperature and location.
void updateTemperature (float temperature)
Update the temperature being broadcast.
void updateLocation ( SensorLocation_t loc)
Update the location.

Technical Details

Further Technical Details can be found at the following links

Files at this revision

API Documentation at this revision

Comitter:
rgrover1
Date:
Sat Jun 20 23:46:17 2015 +0000
Parent:
12:74a45a643722
Child:
14:677ef88025b8
Commit message:
update to the latest of the underlying libraries.

Changed in this revision

BLE_API.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
nRF51822.lib Show annotated file Show diff for this revision Revisions of this file
--- a/BLE_API.lib	Thu Apr 30 08:37:26 2015 +0000
+++ b/BLE_API.lib	Sat Jun 20 23:46:17 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#4a42f777161f
+http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#9f4251b3355c
--- a/main.cpp	Thu Apr 30 08:37:26 2015 +0000
+++ b/main.cpp	Sat Jun 20 23:46:17 2015 +0000
@@ -15,10 +15,10 @@
  */
 
 #include "mbed.h"
-#include "BLEDevice.h"
+#include "BLE.h"
 #include "HealthThermometerService.h"
 
-BLEDevice  ble;
+BLE        ble;
 DigitalOut led1(LED1);
 
 const static char     DEVICE_NAME[]        = "Therm";
@@ -28,7 +28,7 @@
 /* Restart Advertising on disconnection*/
 void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
 {
-    ble.startAdvertising();
+    ble.gap().startAdvertising();
 }
 
 void periodicCallback(void)
@@ -47,20 +47,20 @@
     ticker.attach(periodicCallback, 1);
 
     ble.init();
-    ble.onDisconnection(disconnectionCallback);
+    ble.gap().onDisconnection(disconnectionCallback);
 
     /* Setup primary service. */
     float currentTemperature = 39.6;
     HealthThermometerService thermometerService(ble, currentTemperature, HealthThermometerService::LOCATION_EAR);
 
     /* setup advertising */
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list));
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::THERMOMETER_EAR);
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));
-    ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
-    ble.setAdvertisingInterval(1000); /* 1000ms */
-    ble.startAdvertising();
+    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
+    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list));
+    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::THERMOMETER_EAR);
+    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));
+    ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
+    ble.gap().setAdvertisingInterval(1000); /* 1000ms */
+    ble.gap().startAdvertising();
 
     while (true) {
         if (triggerSensorPolling && ble.getGapState().connected) {
--- a/mbed.bld	Thu Apr 30 08:37:26 2015 +0000
+++ b/mbed.bld	Sat Jun 20 23:46:17 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/8ab26030e058
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7
\ No newline at end of file
--- a/nRF51822.lib	Thu Apr 30 08:37:26 2015 +0000
+++ b/nRF51822.lib	Sat Jun 20 23:46:17 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#3ba3e377b972
+http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#7c68c8d67e1f