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
- Temperature Service : Gatt profile details from bluetooth.org
- Temperature Measurement : Gatt Characteristic details
- Temperature Type : Gatt Characteristic details
Diff: main.cpp
- Revision:
- 2:a34d554282b0
- Parent:
- 1:2deb859ed1a3
- Child:
- 4:83c07b0e93d6
--- 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)); }