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.

Files at this revision

API Documentation at this revision

Comitter:
bcostm
Date:
Wed Jul 26 08:10:04 2017 +0000
Parent:
38:c583b8792cb5
Commit message:
Add reading of board temp sensor

Changed in this revision

BSP_B-L475E-IOT01.lib Show annotated file Show diff for this revision Revisions of this file
shields/TARGET_ST_BLUENRG.lib Show annotated file Show diff for this revision Revisions of this file
source/main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BSP_B-L475E-IOT01.lib	Wed Jul 26 08:10:04 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/ST/code/BSP_B-L475E-IOT01/#0c70bc6d2dc0
--- a/shields/TARGET_ST_BLUENRG.lib	Wed Jul 26 09:44:49 2017 +0200
+++ b/shields/TARGET_ST_BLUENRG.lib	Wed Jul 26 08:10:04 2017 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/ble-x-nucleo-idb0xa1/#b63273d1ba75546adc3374a11f2bf0ebf5e34cbd
+https://github.com/ARMmbed/ble-x-nucleo-idb0xa1/#1616127fd90a7bbf7dafc939e108a21693da1c41
--- 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();