BLE Thermometer example

Dependencies:   BSP_B-L475E-IOT01

This example is a fork of the following mbed-os example:

https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-Thermometer/

Please read the documentation in this page.

Revision:
39:ac224f69256b
Parent:
27:0c99c4b33d56
--- a/source/main.cpp	Wed Jul 26 09:44:49 2017 +0200
+++ b/source/main.cpp	Wed Jul 26 08:10:04 2017 +0000
@@ -19,6 +19,14 @@
 #include "ble/BLE.h"
 #include "ble/services/HealthThermometerService.h"
 
+// Uncomment this line if you want to use the board temperature sensor instead of
+// a simulated one.
+#define USE_BOARD_TEMP_SENSOR
+
+#ifdef USE_BOARD_TEMP_SENSOR
+#include "stm32l475e_iot01_tsensor.h"
+#endif
+
 DigitalOut led1(LED1, 1);
 
 const static char     DEVICE_NAME[]        = "Therm";
@@ -38,7 +46,11 @@
 void updateSensorValue(void) {
     /* Do blocking calls or whatever is necessary for sensor polling.
        In our case, we simply update the Temperature measurement. */
+#ifdef USE_BOARD_TEMP_SENSOR
+    currentTemperature = BSP_TSENSOR_ReadTemp();
+#else
     currentTemperature = (currentTemperature + 0.1 > 43.0) ? 39.6 : currentTemperature + 0.1;
+#endif
     thermometerServicePtr->updateTemperature(currentTemperature);
 }
 
@@ -92,6 +104,10 @@
 
 int main()
 {
+#ifdef USE_BOARD_TEMP_SENSOR
+    BSP_TSENSOR_Init();
+#endif
+    
     eventQueue.call_every(500, periodicCallback);
 
     BLE &ble = BLE::Instance();