Sending IKS01A1 temperature sensor to LoRaWAN port-5 uplink
Dependencies: X_NUCLEO_IKS01A1 mbed LoRaWAN-lib SX1276Lib
Fork of LoRaWAN-demo-76 by
Use IKS01A1 sensor shield with SX1272 shield or SX1276 shield.
Sends temperature sensor to LoRaWAN uplink port 5.
Remove SB22 and SB23 from IKS01A1 before using
SB28 conflicts with DIO0 on radio. (TxDone RxDone)
SB22 conflicts with RxTx on radio. (antenna switch)
Diff: app/main.cpp
- Revision:
- 8:7b1d5fb9cf72
- Parent:
- 7:3173f0508a98
--- a/app/main.cpp Tue Jul 05 15:01:57 2016 +0000 +++ b/app/main.cpp Tue Aug 16 00:16:25 2016 +0000 @@ -19,17 +19,20 @@ #include "LoRaMac.h" #include "Comissioning.h" #include "SerialDisplay.h" +#include "x_nucleo_iks01a1.h" +#include "vt100.h" +extern VT100 vt; /*! * Defines the application data transmission duty cycle. 5s, value in [us]. */ -#define APP_TX_DUTYCYCLE 5000000 +#define APP_TX_DUTYCYCLE 15000000 /*! * Defines a random delay for application data transmission duty cycle. 1s, * value in [us]. */ -#define APP_TX_DUTYCYCLE_RND 1000000 +#define APP_TX_DUTYCYCLE_RND 3000000 /*! * Default datarate @@ -78,7 +81,7 @@ /*! * LoRaWAN application port */ -#define LORAWAN_APP_PORT 15 +#define LORAWAN_APP_PORT 5 //15 /*! * User application data buffer size @@ -281,6 +284,8 @@ } } +static X_NUCLEO_IKS01A1 *mems_expansion_board = X_NUCLEO_IKS01A1::Instance(); +static TempSensor *temp_sensor1 = mems_expansion_board->ht_sensor; /*! * \brief Prepares the payload of the frame */ @@ -288,6 +293,16 @@ { switch( port ) { + case 5: + unsigned int ret; + float TEMPERATURE_Value; + AppDataSize = 11; + AppData[0] = AppLedStateOn; + ret |= (!CALL_METH(temp_sensor1, GetTemperature, &TEMPERATURE_Value, 0.0f) ? 0x0 : 0x1); + vt.SetCursorPos( 43, 1 ); + vt.printf( "temp:%f", TEMPERATURE_Value ); + AppData[1] = (int)TEMPERATURE_Value * 2; + break; case 15: { AppData[0] = AppLedStateOn; @@ -778,6 +793,7 @@ { case DEVICE_STATE_INIT: { + uint8_t id2; LoRaMacPrimitives.MacMcpsConfirm = McpsConfirm; LoRaMacPrimitives.MacMcpsIndication = McpsIndication; LoRaMacPrimitives.MacMlmeConfirm = MlmeConfirm; @@ -826,6 +842,8 @@ LoRaMacDownlinkStatus.DownlinkCounter = 0; DeviceState = DEVICE_STATE_JOIN; + + CALL_METH(temp_sensor1, ReadID, &id2, 0x0); break; } case DEVICE_STATE_JOIN: