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:
Wed Sep 03 16:25:50 2014 +0000
Parent:
1:2deb859ed1a3
Child:
3:8733f3e50c84
Commit message:
fix the UUID for the service; needs to be HealthThermometer.; Also enabled debugging. will revert this shortly.

Changed in this revision

HealthThermometerService.h 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
--- a/HealthThermometerService.h	Tue Sep 02 16:24:12 2014 +0000
+++ b/HealthThermometerService.h	Wed Sep 03 16:25:50 2014 +0000
@@ -19,7 +19,7 @@
 
 #include "BLEDevice.h"
 
-/* Heart Rate Service */
+/* Health Thermometer Service */
 /* Service:  https://developer.bluetooth.org/gatt/profiles/Pages/ProfileViewer.aspx?u=org.bluetooth.profile.health_thermometer.xml */
 /* Temperature Measurement: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.temperature_measurement.xml */
 /* Temperature Type: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.temperature_type.xml */
@@ -54,7 +54,7 @@
                      GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ) {
 
         GattCharacteristic *hrmChars[] = {&tempMeasurement, &tempLocation, };
-        GattService         hrmService(GattService::UUID_HEART_RATE_SERVICE, hrmChars, sizeof(hrmChars) / sizeof(GattCharacteristic *));
+        GattService         hrmService(GattService::UUID_HEALTH_THERMOMETER_SERVICE, hrmChars, sizeof(hrmChars) / sizeof(GattCharacteristic *));
 
         ble.addService(hrmService);
     }
--- a/main.cpp	Tue Sep 02 16:24:12 2014 +0000
+++ b/main.cpp	Wed Sep 03 16:25:50 2014 +0000
@@ -22,7 +22,7 @@
 BLEDevice  ble;
 DHT        sensor(D10, DHT11);
 
-#define NEED_CONSOLE_OUTPUT 0 /* Set this if you need debug messages on the console;
+#define NEED_CONSOLE_OUTPUT 1 /* Set this if you need debug messages on the console;
                                * it will have an impact on code-size and power consumption. */
 
 #if NEED_CONSOLE_OUTPUT
@@ -53,7 +53,7 @@
 int main(void)
 {
     Ticker ticker;
-    ticker.attach(periodicCallback, 1);
+    ticker.attach(periodicCallback, 3);
 
     DEBUG("Initialising the nRF51822\n\r");
     ble.init();
@@ -75,9 +75,12 @@
         if (triggerSensorPolling) {
             triggerSensorPolling = false;
 
+            wait(2);
+            
             /* Do blocking calls or whatever is necessary for sensor polling. */
             /* In our case, we simply update the dummy HRM measurement. */
             int error = sensor.readData();
+            DEBUG("sensor read returned %d\r\n", error);
             if (!error) {
                 thermometerService.updateTemperature(sensor.ReadTemperature(CELCIUS));
             }