Sensor Demo for CTIA
Dependencies: LoRaWAN-lib SX1272Lib lib_gps lib_mma8451q lib_mpl3115a2 mbed
Fork of LoRaWAN-NAMote72-Application-Demo by
Diff: app/LoRaApp.cpp
- Revision:
- 13:238b23d4025c
- Parent:
- 7:92f4f419f91f
- Child:
- 14:172b8e37168c
diff -r 504203733f11 -r 238b23d4025c app/LoRaApp.cpp --- a/app/LoRaApp.cpp Fri Aug 05 20:45:12 2016 +0000 +++ b/app/LoRaApp.cpp Fri Aug 19 00:29:34 2016 +0000 @@ -81,15 +81,37 @@ } // Appends 1 Byte to TX buffer + case AppPrsr: + { + if( ( BuffPtr + 2 ) <= LORAWAN_APP_DATA_SIZE ) + { + volatile uint8_t stat; + + Mpl3115a2.SetModeBarometer(); + Mpl3115a2.ToggleOneShot( ); + + stat = Mpl3115a2.read(STATUS_REG); + while( (stat & 0x04) != 0x04 ) { + wait(0.01); + stat = Mpl3115a2.read(STATUS_REG); + } + + BuffAddr[BuffPtr++] = Mpl3115a2.read(OUT_P_MSB_REG); + BuffAddr[BuffPtr++] = Mpl3115a2.read(OUT_P_CSB_REG); + } + break; + } + + // Appends 1 Byte to TX buffer case AppTemp: { Mpl3115a2.ReadTemperature( ); if( ( BuffPtr + 1 ) <= LORAWAN_APP_DATA_SIZE ) { - BuffAddr[BuffPtr++] = ( int32_t )Mpl3115a2.Temperature; // Signed degrees Celcius in half degree units. So, +/-63 °C + BuffAddr[BuffPtr++] = ( int32_t )Mpl3115a2.Temperature; // Signed degrees Celcius in half degree units. So, +/-63 °C } break; - } + } // Appends 1 Byte to TX buffer case AppBat: @@ -186,6 +208,36 @@ break; } + case AppAcclSensor: + { + uint8_t statusReg; + + // Read the PS_STATUS register + statusReg = Mma8451q.read_single( MMA8451_PL_STATUS ); + + /* Display Orientation of NAMote on Serial Port */ + SerialAcclMetrDisplay( statusReg ); + + // If Orientation of the Mote changed then populate Upper Nibble of 0th Byte of Tx Buffer + if( ( statusReg & 0x80 ) != 0 ) + { + CtrlLED( Green, LED_ON ); + } + else + { + CtrlLED( Green, LED_OFF ); + } + + // Read and populate device orientation in Tx Buffer + if( ( BuffPtr + 2 ) <= LORAWAN_APP_DATA_SIZE ) + { + Mma8451q.read(MMA8451_OUT_X_MSB, &BuffAddr[BuffPtr], 6); + BuffPtr += 6; + } + + break; + } + case AppPushButton: { uint16_t PushButtonCnt;