LoRaWAN-SX1272-Application-24-31-9sec

Dependencies:   X_NUCLEO_IKS01A1 driver_mbed_TH02 LoRaWAN-lib-v1_0_1 SX1272Lib mbed

Fork of LoRaWAN-SX1272-Application-24-31-9sec by Oleh Zvonarov

Committer:
emerette
Date:
Mon Jan 22 15:55:52 2018 +0000
Revision:
8:89039f83e9fc
Parent:
2:19dd7bfcacf7
1-22-2018

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ubhat 0:6cc76d70e2a1 1 /*
ubhat 0:6cc76d70e2a1 2 / _____) _ | |
ubhat 0:6cc76d70e2a1 3 ( (____ _____ ____ _| |_ _____ ____| |__
ubhat 0:6cc76d70e2a1 4 \____ \| ___ | (_ _) ___ |/ ___) _ \
ubhat 0:6cc76d70e2a1 5 _____) ) ____| | | || |_| ____( (___| | | |
ubhat 0:6cc76d70e2a1 6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
ubhat 0:6cc76d70e2a1 7 (C)2015 Semtech
ubhat 0:6cc76d70e2a1 8
ubhat 0:6cc76d70e2a1 9 Description: Define events during Join, Tx & Rx
ubhat 0:6cc76d70e2a1 10 Prepare TX packet by appending with appropriate application data
ubhat 0:6cc76d70e2a1 11
ubhat 0:6cc76d70e2a1 12 License: Revised BSD License, see LICENSE.TXT file include in the project
ubhat 0:6cc76d70e2a1 13
ubhat 0:6cc76d70e2a1 14 Maintainer: Uttam Bhat
ubhat 0:6cc76d70e2a1 15 */
ubhat 0:6cc76d70e2a1 16
ubhat 0:6cc76d70e2a1 17 #include "LoRaEventProc.h"
ubhat 0:6cc76d70e2a1 18
ubhat 0:6cc76d70e2a1 19 /*!
ubhat 0:6cc76d70e2a1 20 * Defines the application data transmission duty cycle
ubhat 0:6cc76d70e2a1 21 */
ubhat 0:6cc76d70e2a1 22 uint32_t TxDutyCycleTime = APP_TX_DUTYCYCLE;
ubhat 0:6cc76d70e2a1 23
ubhat 0:6cc76d70e2a1 24 bool AppLed = 0;
ubhat 0:6cc76d70e2a1 25
ubhat 0:6cc76d70e2a1 26 uint8_t AppCase = 0;
ubhat 0:6cc76d70e2a1 27
ubhat 0:6cc76d70e2a1 28 /*!
ubhat 0:6cc76d70e2a1 29 * \brief Prepares the payload of the frame based on application port
ubhat 0:6cc76d70e2a1 30 */
ubhat 0:6cc76d70e2a1 31 void PrepareLoRaFrame( uint8_t port )
ubhat 0:6cc76d70e2a1 32 {
ubhat 0:6cc76d70e2a1 33
ubhat 2:19dd7bfcacf7 34 switch( port ) {
ubhat 2:19dd7bfcacf7 35 case 5: {
ubhat 0:6cc76d70e2a1 36 uint8_t tmp;
ubhat 0:6cc76d70e2a1 37 uint8_t tmpLength;
ubhat 0:6cc76d70e2a1 38 uint8_t ptrIndex = 0;
ubhat 2:19dd7bfcacf7 39
ubhat 0:6cc76d70e2a1 40 // Point the pointer to position index of Tx Buffer
ubhat 0:6cc76d70e2a1 41 LoRaApp.ApplicationPtrPos( ptrIndex );
ubhat 0:6cc76d70e2a1 42
ubhat 0:6cc76d70e2a1 43 tmp = ( AppLed != 0 ) ? 0x0F : 0x00;
ubhat 0:6cc76d70e2a1 44 tmpLength = 1;
ubhat 2:19dd7bfcacf7 45
ubhat 2:19dd7bfcacf7 46 LoRaApp.ApplicationAppendData( &tmp, tmpLength ); // Populate lower nibble of 0th Byte with LED state
ubhat 0:6cc76d70e2a1 47
ubhat 0:6cc76d70e2a1 48 /*!
ubhat 0:6cc76d70e2a1 49 * Generate Ramp data bytes
ubhat 0:6cc76d70e2a1 50 * Appends incremental values of 1 Byte each to TX buffer until Full
ubhat 0:6cc76d70e2a1 51 */
ubhat 0:6cc76d70e2a1 52 LoRaApp.ApplicationCall( AppRamp );
ubhat 0:6cc76d70e2a1 53
ubhat 0:6cc76d70e2a1 54 break;
ubhat 2:19dd7bfcacf7 55 }
ubhat 0:6cc76d70e2a1 56
ubhat 2:19dd7bfcacf7 57 case 8: {
ubhat 0:6cc76d70e2a1 58 uint8_t ptrIndex = 0;
ubhat 2:19dd7bfcacf7 59
ubhat 0:6cc76d70e2a1 60 //Point the pointer to position index of Tx Buffer
ubhat 2:19dd7bfcacf7 61 LoRaApp.ApplicationPtrPos( ptrIndex );
ubhat 2:19dd7bfcacf7 62
ubhat 0:6cc76d70e2a1 63 /*!
ubhat 0:6cc76d70e2a1 64 * Read Pressure
ubhat 0:6cc76d70e2a1 65 * Appends 2 Bytes to TX buffer
ubhat 0:6cc76d70e2a1 66 */
ubhat 0:6cc76d70e2a1 67 LoRaApp.ApplicationCall( AppPressr );
ubhat 2:19dd7bfcacf7 68
ubhat 0:6cc76d70e2a1 69 /*!
ubhat 0:6cc76d70e2a1 70 * Read Temperature
ubhat 0:6cc76d70e2a1 71 * Appends 1 Byte to TX buffer
ubhat 0:6cc76d70e2a1 72 */
ubhat 0:6cc76d70e2a1 73 LoRaApp.ApplicationCall( AppTemp );
ubhat 2:19dd7bfcacf7 74
ubhat 0:6cc76d70e2a1 75 /*!
ubhat 0:6cc76d70e2a1 76 * Read Humidity
ubhat 0:6cc76d70e2a1 77 * Appends 1 Byte to TX buffer
ubhat 0:6cc76d70e2a1 78 */
ubhat 0:6cc76d70e2a1 79 LoRaApp.ApplicationCall( AppHumid );
ubhat 0:6cc76d70e2a1 80
ubhat 0:6cc76d70e2a1 81 /*!
ubhat 0:6cc76d70e2a1 82 * Read Accelerometer
ubhat 0:6cc76d70e2a1 83 * Appends 2 Bytes to TX buffer
ubhat 0:6cc76d70e2a1 84 * Value Orientation
ubhat 0:6cc76d70e2a1 85 * 0x99 0x00 horizontal + faceup
ubhat 0:6cc76d70e2a1 86 * 0x66 0x00 horizontal + facedown
ubhat 0:6cc76d70e2a1 87 * 0x00 0x11 vertical
ubhat 0:6cc76d70e2a1 88 */
ubhat 2:19dd7bfcacf7 89 LoRaApp.ApplicationCall( AppAccl ); // Generate Accelerometer data bytes
ubhat 0:6cc76d70e2a1 90
ubhat 0:6cc76d70e2a1 91
ubhat 0:6cc76d70e2a1 92 break;
ubhat 0:6cc76d70e2a1 93 }
ubhat 2:19dd7bfcacf7 94
ubhat 0:6cc76d70e2a1 95 // IKAS sensor using Cayenne Payload Format
ubhat 2:19dd7bfcacf7 96 case 9: {
ubhat 2:19dd7bfcacf7 97 #ifdef USE_CAYENNE_LPP
ubhat 0:6cc76d70e2a1 98 uint8_t ptrIndex = 0;
ubhat 2:19dd7bfcacf7 99
ubhat 0:6cc76d70e2a1 100 uint16_t AppSize = 0;
ubhat 2:19dd7bfcacf7 101
ubhat 0:6cc76d70e2a1 102 uint8_t tmp[2] = {0};
ubhat 2:19dd7bfcacf7 103
ubhat 0:6cc76d70e2a1 104 //Point the pointer to position index of Tx Buffer
ubhat 0:6cc76d70e2a1 105 LoRaApp.ApplicationPtrPos( ptrIndex );
ubhat 2:19dd7bfcacf7 106
ubhat 0:6cc76d70e2a1 107 AppCase = AppCase > 3 ? 0 : AppCase;
ubhat 2:19dd7bfcacf7 108
ubhat 2:19dd7bfcacf7 109 while( 1 ) {
ubhat 2:19dd7bfcacf7 110 switch( AppCase ) {
ubhat 2:19dd7bfcacf7 111 case 0: {
ubhat 0:6cc76d70e2a1 112 tmp[0] = 0;
ubhat 0:6cc76d70e2a1 113 tmp[1] = 115; // Data Type PRESSURE: 115
ubhat 0:6cc76d70e2a1 114 LoRaApp.ApplicationAppendData( tmp, 2 );
ubhat 2:19dd7bfcacf7 115
ubhat 0:6cc76d70e2a1 116 /*!
ubhat 0:6cc76d70e2a1 117 * Read Pressure
ubhat 0:6cc76d70e2a1 118 * Appends 2 Bytes to TX buffer
ubhat 0:6cc76d70e2a1 119 */
ubhat 0:6cc76d70e2a1 120 LoRaApp.ApplicationCall( AppPressr );
ubhat 2:19dd7bfcacf7 121
ubhat 0:6cc76d70e2a1 122 AppSize += maxLPPsize[AppCase];
ubhat 0:6cc76d70e2a1 123
ubhat 0:6cc76d70e2a1 124 break;
ubhat 0:6cc76d70e2a1 125 }
ubhat 2:19dd7bfcacf7 126
ubhat 2:19dd7bfcacf7 127 case 1: {
ubhat 0:6cc76d70e2a1 128 tmp[0] = 1;
ubhat 0:6cc76d70e2a1 129 tmp[1] = 103; // Data Type TEMP: 103
ubhat 0:6cc76d70e2a1 130 LoRaApp.ApplicationAppendData( tmp, 2 );
ubhat 2:19dd7bfcacf7 131
ubhat 0:6cc76d70e2a1 132 /*!
ubhat 0:6cc76d70e2a1 133 * Read Temperature
ubhat 0:6cc76d70e2a1 134 * Appends 1 Byte to TX buffer
ubhat 0:6cc76d70e2a1 135 */
ubhat 0:6cc76d70e2a1 136 LoRaApp.ApplicationCall( AppTemp );
ubhat 2:19dd7bfcacf7 137
ubhat 0:6cc76d70e2a1 138 AppSize += maxLPPsize[AppCase];
ubhat 0:6cc76d70e2a1 139
ubhat 0:6cc76d70e2a1 140 break;
ubhat 0:6cc76d70e2a1 141 }
ubhat 2:19dd7bfcacf7 142
ubhat 2:19dd7bfcacf7 143 case 2: {
ubhat 0:6cc76d70e2a1 144 tmp[0] = 2;
ubhat 0:6cc76d70e2a1 145 tmp[1] = 104; // Data Type HUMIDITY: 103
ubhat 0:6cc76d70e2a1 146 LoRaApp.ApplicationAppendData( tmp, 2 );
ubhat 2:19dd7bfcacf7 147
ubhat 0:6cc76d70e2a1 148 /*!
ubhat 0:6cc76d70e2a1 149 * Read Humidity
ubhat 0:6cc76d70e2a1 150 * Appends 1 Byte to TX buffer
ubhat 0:6cc76d70e2a1 151 */
ubhat 0:6cc76d70e2a1 152 LoRaApp.ApplicationCall( AppHumid );
ubhat 2:19dd7bfcacf7 153
ubhat 0:6cc76d70e2a1 154 AppSize += maxLPPsize[AppCase];
ubhat 0:6cc76d70e2a1 155
ubhat 0:6cc76d70e2a1 156 break;
ubhat 0:6cc76d70e2a1 157 }
ubhat 2:19dd7bfcacf7 158
ubhat 2:19dd7bfcacf7 159 case 3: {
ubhat 0:6cc76d70e2a1 160 tmp[0] = 3;
ubhat 0:6cc76d70e2a1 161 tmp[1] = 113; // Data Type Accl: 113
ubhat 0:6cc76d70e2a1 162 LoRaApp.ApplicationAppendData( tmp, 2 );
ubhat 0:6cc76d70e2a1 163 /*!
ubhat 2:19dd7bfcacf7 164 * Read Accelerometer
ubhat 0:6cc76d70e2a1 165 */
ubhat 0:6cc76d70e2a1 166 LoRaApp.ApplicationCall( AppAccl ); // Generate Accelerometer data bytes
ubhat 2:19dd7bfcacf7 167
ubhat 0:6cc76d70e2a1 168 AppSize += maxLPPsize[AppCase];
ubhat 0:6cc76d70e2a1 169
ubhat 0:6cc76d70e2a1 170 break;
ubhat 0:6cc76d70e2a1 171 }
ubhat 0:6cc76d70e2a1 172 }
ubhat 2:19dd7bfcacf7 173
ubhat 0:6cc76d70e2a1 174 AppCase++;
ubhat 2:19dd7bfcacf7 175
ubhat 2:19dd7bfcacf7 176 if( AppSize + maxLPPsize[AppCase] > LORAWAN_APP_DATA_SIZE ) {
ubhat 0:6cc76d70e2a1 177 break;
ubhat 0:6cc76d70e2a1 178 }
ubhat 0:6cc76d70e2a1 179 }
ubhat 2:19dd7bfcacf7 180
ubhat 2:19dd7bfcacf7 181 AppDataSize = AppSize;
ubhat 0:6cc76d70e2a1 182 #endif
ubhat 0:6cc76d70e2a1 183 break;
ubhat 0:6cc76d70e2a1 184 }
ubhat 0:6cc76d70e2a1 185
ubhat 2:19dd7bfcacf7 186 // Push-Button Demo
ubhat 2:19dd7bfcacf7 187 case 11: {
ubhat 0:6cc76d70e2a1 188 uint8_t ptrIndex = 0;
ubhat 2:19dd7bfcacf7 189
ubhat 2:19dd7bfcacf7 190 //Point the pointer to position index of Tx Buffer
ubhat 2:19dd7bfcacf7 191 LoRaApp.ApplicationPtrPos( ptrIndex );
ubhat 2:19dd7bfcacf7 192
ubhat 2:19dd7bfcacf7 193 LoRaApp.ApplicationCall( AppPushButton ); // Transmit uplink counter
ubhat 2:19dd7bfcacf7 194
ubhat 2:19dd7bfcacf7 195 break;
ubhat 2:19dd7bfcacf7 196 }
ubhat 2:19dd7bfcacf7 197
ubhat 2:19dd7bfcacf7 198 // GROVE sensor using Cayenne Payload Format
ubhat 2:19dd7bfcacf7 199 case 12: {
ubhat 2:19dd7bfcacf7 200 #ifdef USE_CAYENNE_LPP
ubhat 2:19dd7bfcacf7 201 uint8_t ptrIndex = 0;
ubhat 2:19dd7bfcacf7 202
ubhat 2:19dd7bfcacf7 203 uint8_t tmp[2] = {0};
ubhat 2:19dd7bfcacf7 204
ubhat 0:6cc76d70e2a1 205 //Point the pointer to position index of Tx Buffer
ubhat 0:6cc76d70e2a1 206 LoRaApp.ApplicationPtrPos( ptrIndex );
ubhat 2:19dd7bfcacf7 207
ubhat 2:19dd7bfcacf7 208 tmp[0] = 1;
ubhat 2:19dd7bfcacf7 209 tmp[1] = 103; // Data Type TEMP: 103
ubhat 2:19dd7bfcacf7 210 LoRaApp.ApplicationAppendData( tmp, 2 );
ubhat 0:6cc76d70e2a1 211
ubhat 2:19dd7bfcacf7 212 printf("Temp Call\r\n");
ubhat 2:19dd7bfcacf7 213
ubhat 2:19dd7bfcacf7 214 /*!
ubhat 2:19dd7bfcacf7 215 * Read Temperature
ubhat 2:19dd7bfcacf7 216 * Appends 1 Byte to TX buffer
ubhat 2:19dd7bfcacf7 217 */
ubhat 2:19dd7bfcacf7 218 LoRaApp.ApplicationCall( AppTemp );
ubhat 2:19dd7bfcacf7 219
ubhat 2:19dd7bfcacf7 220 tmp[0] = 2;
ubhat 2:19dd7bfcacf7 221 tmp[1] = 104; // Data Type HUMIDITY: 103
ubhat 2:19dd7bfcacf7 222 LoRaApp.ApplicationAppendData( tmp, 2 );
ubhat 0:6cc76d70e2a1 223
ubhat 2:19dd7bfcacf7 224 printf("Humidity Call\r\n");
ubhat 2:19dd7bfcacf7 225
ubhat 2:19dd7bfcacf7 226 /*!
ubhat 2:19dd7bfcacf7 227 * Read Humidity
ubhat 2:19dd7bfcacf7 228 * Appends 1 Byte to TX buffer
ubhat 2:19dd7bfcacf7 229 */
ubhat 2:19dd7bfcacf7 230 LoRaApp.ApplicationCall( AppHumid );
ubhat 2:19dd7bfcacf7 231
ubhat 2:19dd7bfcacf7 232 #endif
ubhat 0:6cc76d70e2a1 233 break;
ubhat 0:6cc76d70e2a1 234 }
ubhat 2:19dd7bfcacf7 235
ubhat 2:19dd7bfcacf7 236 default:
ubhat 2:19dd7bfcacf7 237 break;
ubhat 0:6cc76d70e2a1 238 }
ubhat 0:6cc76d70e2a1 239 }
ubhat 0:6cc76d70e2a1 240
ubhat 0:6cc76d70e2a1 241
ubhat 0:6cc76d70e2a1 242 /*!
ubhat 0:6cc76d70e2a1 243 * \brief Sets Interrupt for next payload transmission
ubhat 0:6cc76d70e2a1 244 */
ubhat 0:6cc76d70e2a1 245 void InitNextTxInterrupt( uint8_t port )
ubhat 2:19dd7bfcacf7 246 {
ubhat 2:19dd7bfcacf7 247 switch( port ) {
ubhat 2:19dd7bfcacf7 248 /* GPS Application Demo
ubhat 2:19dd7bfcacf7 249 Set Timer interrupt for next uplink
ubhat 2:19dd7bfcacf7 250 */
ubhat 2:19dd7bfcacf7 251 case 5: {
ubhat 0:6cc76d70e2a1 252 }
ubhat 0:6cc76d70e2a1 253
ubhat 2:19dd7bfcacf7 254 /* Senet + M2X demo
ubhat 2:19dd7bfcacf7 255 Set Timer interrupt for next uplink
ubhat 2:19dd7bfcacf7 256 */
ubhat 2:19dd7bfcacf7 257 case 6: {
ubhat 2:19dd7bfcacf7 258
ubhat 0:6cc76d70e2a1 259 }
ubhat 2:19dd7bfcacf7 260
ubhat 2:19dd7bfcacf7 261 /* Senet GPS Demo
ubhat 2:19dd7bfcacf7 262 Set Timer interrupt for next uplink
ubhat 2:19dd7bfcacf7 263 */
ubhat 2:19dd7bfcacf7 264 case 7: {
ubhat 0:6cc76d70e2a1 265 // Schedule next packet transmission
ubhat 0:6cc76d70e2a1 266 TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( -APP_TX_DUTYCYCLE_RND, APP_TX_DUTYCYCLE_RND );
ubhat 0:6cc76d70e2a1 267 TimerSetValue( &TxNextPacketTimer, TxDutyCycleTime );
ubhat 0:6cc76d70e2a1 268 TimerStart( &TxNextPacketTimer );
ubhat 0:6cc76d70e2a1 269 break;
ubhat 0:6cc76d70e2a1 270 }
ubhat 0:6cc76d70e2a1 271
ubhat 2:19dd7bfcacf7 272 /* Push Button Demo
ubhat 2:19dd7bfcacf7 273 Send Packet Immedietly if PC0 = GND
ubhat 2:19dd7bfcacf7 274 */
ubhat 2:19dd7bfcacf7 275 case 11: {
ubhat 0:6cc76d70e2a1 276 volatile bool PushButtonStatus;
ubhat 0:6cc76d70e2a1 277
ubhat 0:6cc76d70e2a1 278 PushButtonStatus = UsrButton;
ubhat 2:19dd7bfcacf7 279
ubhat 2:19dd7bfcacf7 280 if(PushButtonStatus == 0) {
ubhat 0:6cc76d70e2a1 281 // Send Pkt immedietly if PC = GND
ubhat 0:6cc76d70e2a1 282 DeviceState = DEVICE_STATE_SEND;
ubhat 0:6cc76d70e2a1 283 NextTx = true;
ubhat 2:19dd7bfcacf7 284 } else {
ubhat 0:6cc76d70e2a1 285 // Keep polling
ubhat 0:6cc76d70e2a1 286 IsTxIntUpdate = true;
ubhat 0:6cc76d70e2a1 287 }
ubhat 2:19dd7bfcacf7 288
ubhat 0:6cc76d70e2a1 289 break;
ubhat 2:19dd7bfcacf7 290 }
ubhat 0:6cc76d70e2a1 291
ubhat 2:19dd7bfcacf7 292 /* Orientation Demo
ubhat 2:19dd7bfcacf7 293 Send Packet Immedietly if Mote is Vertical
ubhat 2:19dd7bfcacf7 294 */
ubhat 2:19dd7bfcacf7 295 case 12: {
ubhat 2:19dd7bfcacf7 296 // Schedule next packet transmission
ubhat 2:19dd7bfcacf7 297 TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( -APP_TX_DUTYCYCLE_RND, APP_TX_DUTYCYCLE_RND );
ubhat 2:19dd7bfcacf7 298 TimerSetValue( &TxNextPacketTimer, TxDutyCycleTime );
ubhat 2:19dd7bfcacf7 299 TimerStart( &TxNextPacketTimer );
ubhat 0:6cc76d70e2a1 300 break;
ubhat 2:19dd7bfcacf7 301 }
ubhat 0:6cc76d70e2a1 302
ubhat 2:19dd7bfcacf7 303 /* Compliance Test
ubhat 2:19dd7bfcacf7 304 Set Timer interrupt for next uplink
ubhat 2:19dd7bfcacf7 305 */
ubhat 2:19dd7bfcacf7 306 case 224: {
ubhat 0:6cc76d70e2a1 307 // Schedule next packet transmission
ubhat 0:6cc76d70e2a1 308 TimerSetValue( &TxNextPacketTimer, COMPLIANCE_TX_DUTYCYCLE );
ubhat 0:6cc76d70e2a1 309 TimerStart( &TxNextPacketTimer );
ubhat 0:6cc76d70e2a1 310 break;
ubhat 0:6cc76d70e2a1 311 }
ubhat 0:6cc76d70e2a1 312
ubhat 2:19dd7bfcacf7 313 default: {
ubhat 0:6cc76d70e2a1 314 // Schedule next packet transmission
ubhat 0:6cc76d70e2a1 315 TimerSetValue( &TxNextPacketTimer, TxDutyCycleTime );
ubhat 0:6cc76d70e2a1 316 TimerStart( &TxNextPacketTimer );
ubhat 0:6cc76d70e2a1 317 break;
ubhat 0:6cc76d70e2a1 318 }
ubhat 0:6cc76d70e2a1 319 }
ubhat 0:6cc76d70e2a1 320
ubhat 0:6cc76d70e2a1 321 }
ubhat 0:6cc76d70e2a1 322
ubhat 0:6cc76d70e2a1 323 /*!
ubhat 0:6cc76d70e2a1 324 * \brief What to do during JOIN process ? blink/toggle LED etc.
ubhat 0:6cc76d70e2a1 325 */
ubhat 0:6cc76d70e2a1 326 void JoinEvent( void )
ubhat 0:6cc76d70e2a1 327 {
ubhat 0:6cc76d70e2a1 328 // CtrlLED is defined in LoRaBoardAppIf.h
ubhat 0:6cc76d70e2a1 329 // param 1: LED color (Red, Yellow or Green)
ubhat 0:6cc76d70e2a1 330 // param 2: LED_ON or LED_OFF
ubhat 2:19dd7bfcacf7 331 //CtrlLED( Red, LED_ON );
ubhat 0:6cc76d70e2a1 332 }
ubhat 0:6cc76d70e2a1 333
ubhat 0:6cc76d70e2a1 334
ubhat 0:6cc76d70e2a1 335 /*!
ubhat 0:6cc76d70e2a1 336 * \brief What to do during TX ? blink/toggle LED etc.
ubhat 0:6cc76d70e2a1 337 */
ubhat 0:6cc76d70e2a1 338 void TxEvent( void )
ubhat 0:6cc76d70e2a1 339 {
ubhat 0:6cc76d70e2a1 340 int blinkTime = 25000;
ubhat 0:6cc76d70e2a1 341
ubhat 0:6cc76d70e2a1 342 // Blink Red LED for 25msec
ubhat 0:6cc76d70e2a1 343 //BlinkLED( Red, blinkTime );
ubhat 0:6cc76d70e2a1 344 }
ubhat 0:6cc76d70e2a1 345
ubhat 0:6cc76d70e2a1 346 void RxEvent()
ubhat 0:6cc76d70e2a1 347 {
ubhat 0:6cc76d70e2a1 348 // Toggle yellow LED
ubhat 2:19dd7bfcacf7 349 //ToggleLED( Yellow );
ubhat 0:6cc76d70e2a1 350
ubhat 0:6cc76d70e2a1 351 // If Rx Data is 0x01 turn on Green LED else if 0x0 Turn Green LED off
ubhat 2:19dd7bfcacf7 352 if( LoRaMacDownlinkStatus.BufferSize == 1 ) {
ubhat 2:19dd7bfcacf7 353 if( LoRaMacDownlinkStatus.Buffer[0] == 0x01 ) {
ubhat 0:6cc76d70e2a1 354 AppLed = 1;
ubhat 2:19dd7bfcacf7 355 } else {
ubhat 2:19dd7bfcacf7 356 if( LoRaMacDownlinkStatus.Buffer[0] == 0x00 ) {
ubhat 0:6cc76d70e2a1 357 AppLed = 0;
ubhat 0:6cc76d70e2a1 358 }
ubhat 0:6cc76d70e2a1 359 }
ubhat 0:6cc76d70e2a1 360 }
ubhat 0:6cc76d70e2a1 361
ubhat 2:19dd7bfcacf7 362 if( AppLed != 0 ) {
ubhat 0:6cc76d70e2a1 363 // Turn USR_LED ON
ubhat 0:6cc76d70e2a1 364 //UsrLED = 3.3;
ubhat 2:19dd7bfcacf7 365 } else {
ubhat 0:6cc76d70e2a1 366 // Turn USR_LED OFF
ubhat 0:6cc76d70e2a1 367 //UsrLED = 0;
ubhat 0:6cc76d70e2a1 368 }
ubhat 0:6cc76d70e2a1 369 }
ubhat 0:6cc76d70e2a1 370