1

Dependencies:   X_NUCLEO_IKS01A1 LoRaWAN-lib SX1276Lib mbed

Committer:
emerette
Date:
Fri Nov 09 21:52:19 2018 +0000
Revision:
8:88e8a1c7b88a
Parent:
7:730764a067dc
1

Who changed what in which revision?

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