Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: X_NUCLEO_IKS01A2 driver_mbed_TH02 mbed LoRaWAN-lib-v1_0_1 SX1272Lib
Fork of Training-Aug2018-SX1272-X-NUCLEO-IKS01A2 by
Diff: app/LoRaApp.cpp
- Revision:
- 2:19dd7bfcacf7
- Parent:
- 0:6cc76d70e2a1
- Child:
- 9:a47750bce9f8
--- a/app/LoRaApp.cpp Sat Apr 29 07:41:12 2017 +0000
+++ b/app/LoRaApp.cpp Sat Nov 04 20:05:46 2017 +0000
@@ -16,8 +16,9 @@
#include "LoRaApp.h"
+float sensor_data;
+
#ifdef USE_IKS01A1_SENSOR
-float iks01a1_data;
int32_t Accl_Value[3] = {0};
#endif
@@ -63,23 +64,30 @@
// Appends 1 Byte to TX buffer
case AppTemp:
{
-#ifdef USE_IKS01A1_SENSOR
+#if defined( USE_IKS01A1_SENSOR )
+//#ifdef USE_IKS01A1_SENSOR
- temp_sensor2->GetTemperature(&iks01a1_data);
-
- printf("Temp = %f, %d\r\n", iks01a1_data, (int8_t) iks01a1_data);
+ temp_sensor2->GetTemperature(&sensor_data);
+
+#elif defined( USE_GROVE_SENSOR )
+
+ sensor_data = myTH02.ReadTemperature();
+
+#endif
+
+ printf("Temp = %f, %d\r\n", sensor_data, (int8_t) sensor_data);
if( ( BuffPtr + 1 ) <= LORAWAN_APP_DATA_SIZE )
{
#ifdef USE_CAYENNE_LPP
- BuffAddr[BuffPtr++] = 0;
- BuffAddr[BuffPtr++] = (int8_t) ( iks01a1_data * 10 );
+ int16_t tmp_data = (int16_t) (sensor_data*10 + 0.5);
+ BuffAddr[BuffPtr++] = (int8_t) ( ( tmp_data >> 8 ) & 0xFF );
+ BuffAddr[BuffPtr++] = (int8_t) tmp_data & 0xFF;
#else
- BuffAddr[BuffPtr++] = (int8_t) iks01a1_data;
+ BuffAddr[BuffPtr++] = (int8_t) sensor_data;
#endif
}
-
-#endif
+
break;
}
@@ -88,21 +96,21 @@
{
#ifdef USE_IKS01A1_SENSOR
- pressure_sensor->GetPressure(&iks01a1_data);
+ pressure_sensor->GetPressure(&sensor_data);
- printf("Pressure = %f, %d\r\n", iks01a1_data, (uint16_t) iks01a1_data);
+ printf("Pressure = %f, %d\r\n", sensor_data, (uint16_t) sensor_data);
if( ( BuffPtr + 2 ) <= LORAWAN_APP_DATA_SIZE )
{
#ifdef USE_CAYENNE_LPP
int16_t tmp;
- tmp = (int16_t) ( iks01a1_data * 10 );
+ tmp = (int16_t) ( sensor_data * 10 );
BuffAddr[BuffPtr++] = ( tmp >> 8 ) & 0xFF;
BuffAddr[BuffPtr++] = ( tmp ) & 0xFF;
#else
- BuffAddr[BuffPtr++] = ( (int16_t) iks01a1_data >> 8 ) & 0xFF;
- BuffAddr[BuffPtr++] = ( (int16_t) iks01a1_data ) & 0xFF;
+ BuffAddr[BuffPtr++] = ( (int16_t) sensor_data >> 8 ) & 0xFF;
+ BuffAddr[BuffPtr++] = ( (int16_t) sensor_data ) & 0xFF;
#endif
}
@@ -113,22 +121,27 @@
// Appends 2 Bytes to TX buffer
case AppHumid:
{
-#ifdef USE_IKS01A1_SENSOR
+#if defined ( USE_IKS01A1_SENSOR )
- humidity_sensor->GetHumidity(&iks01a1_data);
-
- printf("Humidity = %f, %d\r\n", iks01a1_data, (uint8_t) iks01a1_data);
+ humidity_sensor->GetHumidity(&sensor_data);
+
+#elif defined ( USE_GROVE_SENSOR )
+
+ sensor_data = myTH02.ReadHumidity();
+
+#endif
+
+ printf("Humidity = %f, %d\r\n", sensor_data, (uint8_t) sensor_data);
if( ( BuffPtr + 1 ) <= LORAWAN_APP_DATA_SIZE )
{
#ifdef USE_CAYENNE_LPP
- BuffAddr[BuffPtr++] = (uint8_t) ( iks01a1_data * 2 );
+ BuffAddr[BuffPtr++] = (uint8_t) ( sensor_data * 2 );
#else
- BuffAddr[BuffPtr++] = (int8_t) iks01a1_data;
+ BuffAddr[BuffPtr++] = (int8_t) sensor_data;
#endif
}
-
-#endif
+
break;
}
