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)
Revision 8:7b1d5fb9cf72, committed 2016-08-16
- Comitter:
- dudmuck
- Date:
- Tue Aug 16 00:16:25 2016 +0000
- Parent:
- 7:3173f0508a98
- Commit message:
- added IKS01A1 temperature sensing
Changed in this revision
diff -r 3173f0508a98 -r 7b1d5fb9cf72 X_NUCLEO_IKS01A1.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/X_NUCLEO_IKS01A1.lib Tue Aug 16 00:16:25 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/X_NUCLEO_IKS01A1/#f4fa3dad9ec4
diff -r 3173f0508a98 -r 7b1d5fb9cf72 app/Comissioning.h --- a/app/Comissioning.h Tue Jul 05 15:01:57 2016 +0000 +++ b/app/Comissioning.h Tue Aug 16 00:16:25 2016 +0000 @@ -29,12 +29,12 @@ /*! * IEEE Organizationally Unique Identifier ( OUI ) (big endian) */ -#define IEEE_OUI 0x11, 0x22, 0x33 +#define IEEE_OUI 0x00, 0x25, 0x0c /*! * Mote device IEEE EUI (big endian) */ -#define LORAWAN_DEVICE_EUI { IEEE_OUI, 0x44, 0x55, 0x66, 0x77, 0x88 } +#define LORAWAN_DEVICE_EUI { IEEE_OUI, 0x01, 0x00, 0x00, 0x00, 0x20 } /*! * Application IEEE EUI (big endian) @@ -44,7 +44,7 @@ /*! * AES encryption/decryption cipher application key */ -#define LORAWAN_APPLICATION_KEY { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C } +#define LORAWAN_APPLICATION_KEY { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff } /*! * Current network ID
diff -r 3173f0508a98 -r 7b1d5fb9cf72 app/main.cpp --- 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:
diff -r 3173f0508a98 -r 7b1d5fb9cf72 board/board.h --- a/board/board.h Tue Jul 05 15:01:57 2016 +0000 +++ b/board/board.h Tue Aug 16 00:16:25 2016 +0000 @@ -21,7 +21,7 @@ #include "system/utilities.h" #include "sx1276-hal.h" -#define USE_BAND_868 +#define USE_BAND_915_HYBRID extern SX1276MB1xAS Radio;