light sensor
Dependencies: X_NUCLEO_IKS01A1 LoRaWAN-lib SX1276Lib mbed
Fork of LoRaWAN-SX1276-Application-Demo by
Diff: app/LoRaEventProc.cpp
- Revision:
- 3:4bca7f8f731a
- Parent:
- 2:78df92a365c2
- Child:
- 4:a8706ec8a6d0
--- a/app/LoRaEventProc.cpp Sat Aug 27 04:03:02 2016 +0000 +++ b/app/LoRaEventProc.cpp Thu Apr 06 16:35:17 2017 +0000 @@ -23,6 +23,8 @@ bool AppLed = 0; +uint8_t AppCase = 0; + /*! * \brief Prepares the payload of the frame based on application port */ @@ -92,6 +94,105 @@ break; } + + // IKAS sensor using Cayenne Payload Format + case 9: + { +#ifdef USE_CAYENNE_LPP + uint8_t ptrIndex = 0; + + uint16_t AppSize = 0; + + uint8_t tmp[2] = {0}; + + //Point the pointer to position index of Tx Buffer + LoRaApp.ApplicationPtrPos( ptrIndex ); + + AppCase = AppCase > 3 ? 0 : AppCase; + + while( 1 ) + { + switch( AppCase ) + { + case 0: + { + tmp[0] = 0; + tmp[1] = 115; // Data Type PRESSURE: 115 + LoRaApp.ApplicationAppendData( tmp, 2 ); + + /*! + * Read Pressure + * Appends 2 Bytes to TX buffer + */ + LoRaApp.ApplicationCall( AppPressr ); + + AppSize += maxLPPsize[AppCase]; + + break; + } + + case 1: + { + tmp[0] = 1; + tmp[1] = 103; // Data Type TEMP: 103 + LoRaApp.ApplicationAppendData( tmp, 2 ); + + /*! + * Read Temperature + * Appends 1 Byte to TX buffer + */ + LoRaApp.ApplicationCall( AppTemp ); + + AppSize += maxLPPsize[AppCase]; + + break; + } + + case 2: + { + tmp[0] = 2; + tmp[1] = 104; // Data Type HUMIDITY: 103 + LoRaApp.ApplicationAppendData( tmp, 2 ); + + /*! + * Read Humidity + * Appends 1 Byte to TX buffer + */ + LoRaApp.ApplicationCall( AppHumid ); + + AppSize += maxLPPsize[AppCase]; + + break; + } + + case 3: + { + tmp[0] = 3; + tmp[1] = 113; // Data Type Accl: 113 + LoRaApp.ApplicationAppendData( tmp, 2 ); + /*! + * Read Accelerometer + */ + LoRaApp.ApplicationCall( AppAccl ); // Generate Accelerometer data bytes + + AppSize += maxLPPsize[AppCase]; + + break; + } + } + + AppCase++; + + if( AppSize + maxLPPsize[AppCase] > LORAWAN_APP_DATA_SIZE ) + { + break; + } + } + + AppDataSize = AppSize; +#endif + break; + } // Push-Button Demo case 11: