LR Initial Publish

Dependencies:   X_NUCLEO_IKS01A2 driver_mbed_TH02 mbed LoRaWAN-lib-v1_0_1 SX1272Lib

Fork of Training-Aug2018-SX1272-X-NUCLEO-IKS01A2 by Uttam Bhat

Committer:
ubhat
Date:
Sun Aug 12 06:09:53 2018 +0000
Revision:
9:a47750bce9f8
Parent:
2:19dd7bfcacf7
Child:
10:bba416e2c3e1
Add Cayenne Application for Push Button

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 9:a47750bce9f8 189
ubhat 9:a47750bce9f8 190 uint8_t tmp[2] = {0};
ubhat 2:19dd7bfcacf7 191
ubhat 2:19dd7bfcacf7 192 //Point the pointer to position index of Tx Buffer
ubhat 2:19dd7bfcacf7 193 LoRaApp.ApplicationPtrPos( ptrIndex );
ubhat 9:a47750bce9f8 194
ubhat 9:a47750bce9f8 195 tmp[0] = 0;
ubhat 9:a47750bce9f8 196 tmp[1] = 0;
ubhat 9:a47750bce9f8 197 LoRaApp.ApplicationAppendData( tmp, 2 );
ubhat 2:19dd7bfcacf7 198
ubhat 2:19dd7bfcacf7 199 LoRaApp.ApplicationCall( AppPushButton ); // Transmit uplink counter
ubhat 2:19dd7bfcacf7 200
ubhat 2:19dd7bfcacf7 201 break;
ubhat 2:19dd7bfcacf7 202 }
ubhat 2:19dd7bfcacf7 203
ubhat 2:19dd7bfcacf7 204 // GROVE sensor using Cayenne Payload Format
ubhat 2:19dd7bfcacf7 205 case 12: {
ubhat 2:19dd7bfcacf7 206 #ifdef USE_CAYENNE_LPP
ubhat 2:19dd7bfcacf7 207 uint8_t ptrIndex = 0;
ubhat 2:19dd7bfcacf7 208
ubhat 2:19dd7bfcacf7 209 uint8_t tmp[2] = {0};
ubhat 2:19dd7bfcacf7 210
ubhat 0:6cc76d70e2a1 211 //Point the pointer to position index of Tx Buffer
ubhat 0:6cc76d70e2a1 212 LoRaApp.ApplicationPtrPos( ptrIndex );
ubhat 2:19dd7bfcacf7 213
ubhat 2:19dd7bfcacf7 214 tmp[0] = 1;
ubhat 2:19dd7bfcacf7 215 tmp[1] = 103; // Data Type TEMP: 103
ubhat 2:19dd7bfcacf7 216 LoRaApp.ApplicationAppendData( tmp, 2 );
ubhat 0:6cc76d70e2a1 217
ubhat 2:19dd7bfcacf7 218 printf("Temp Call\r\n");
ubhat 2:19dd7bfcacf7 219
ubhat 2:19dd7bfcacf7 220 /*!
ubhat 2:19dd7bfcacf7 221 * Read Temperature
ubhat 2:19dd7bfcacf7 222 * Appends 1 Byte to TX buffer
ubhat 2:19dd7bfcacf7 223 */
ubhat 2:19dd7bfcacf7 224 LoRaApp.ApplicationCall( AppTemp );
ubhat 2:19dd7bfcacf7 225
ubhat 2:19dd7bfcacf7 226 tmp[0] = 2;
ubhat 2:19dd7bfcacf7 227 tmp[1] = 104; // Data Type HUMIDITY: 103
ubhat 2:19dd7bfcacf7 228 LoRaApp.ApplicationAppendData( tmp, 2 );
ubhat 0:6cc76d70e2a1 229
ubhat 2:19dd7bfcacf7 230 printf("Humidity Call\r\n");
ubhat 2:19dd7bfcacf7 231
ubhat 2:19dd7bfcacf7 232 /*!
ubhat 2:19dd7bfcacf7 233 * Read Humidity
ubhat 2:19dd7bfcacf7 234 * Appends 1 Byte to TX buffer
ubhat 2:19dd7bfcacf7 235 */
ubhat 2:19dd7bfcacf7 236 LoRaApp.ApplicationCall( AppHumid );
ubhat 2:19dd7bfcacf7 237
ubhat 2:19dd7bfcacf7 238 #endif
ubhat 0:6cc76d70e2a1 239 break;
ubhat 0:6cc76d70e2a1 240 }
ubhat 2:19dd7bfcacf7 241
ubhat 2:19dd7bfcacf7 242 default:
ubhat 2:19dd7bfcacf7 243 break;
ubhat 0:6cc76d70e2a1 244 }
ubhat 0:6cc76d70e2a1 245 }
ubhat 0:6cc76d70e2a1 246
ubhat 0:6cc76d70e2a1 247
ubhat 0:6cc76d70e2a1 248 /*!
ubhat 0:6cc76d70e2a1 249 * \brief Sets Interrupt for next payload transmission
ubhat 0:6cc76d70e2a1 250 */
ubhat 0:6cc76d70e2a1 251 void InitNextTxInterrupt( uint8_t port )
ubhat 2:19dd7bfcacf7 252 {
ubhat 2:19dd7bfcacf7 253 switch( port ) {
ubhat 2:19dd7bfcacf7 254 /* GPS Application Demo
ubhat 2:19dd7bfcacf7 255 Set Timer interrupt for next uplink
ubhat 2:19dd7bfcacf7 256 */
ubhat 2:19dd7bfcacf7 257 case 5: {
ubhat 0:6cc76d70e2a1 258 }
ubhat 0:6cc76d70e2a1 259
ubhat 2:19dd7bfcacf7 260 /* Senet + M2X demo
ubhat 2:19dd7bfcacf7 261 Set Timer interrupt for next uplink
ubhat 2:19dd7bfcacf7 262 */
ubhat 2:19dd7bfcacf7 263 case 6: {
ubhat 2:19dd7bfcacf7 264
ubhat 0:6cc76d70e2a1 265 }
ubhat 2:19dd7bfcacf7 266
ubhat 2:19dd7bfcacf7 267 /* Senet GPS Demo
ubhat 2:19dd7bfcacf7 268 Set Timer interrupt for next uplink
ubhat 2:19dd7bfcacf7 269 */
ubhat 2:19dd7bfcacf7 270 case 7: {
ubhat 0:6cc76d70e2a1 271 // Schedule next packet transmission
ubhat 0:6cc76d70e2a1 272 TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( -APP_TX_DUTYCYCLE_RND, APP_TX_DUTYCYCLE_RND );
ubhat 0:6cc76d70e2a1 273 TimerSetValue( &TxNextPacketTimer, TxDutyCycleTime );
ubhat 0:6cc76d70e2a1 274 TimerStart( &TxNextPacketTimer );
ubhat 0:6cc76d70e2a1 275 break;
ubhat 0:6cc76d70e2a1 276 }
ubhat 0:6cc76d70e2a1 277
ubhat 2:19dd7bfcacf7 278 /* Push Button Demo
ubhat 2:19dd7bfcacf7 279 Send Packet Immedietly if PC0 = GND
ubhat 2:19dd7bfcacf7 280 */
ubhat 2:19dd7bfcacf7 281 case 11: {
ubhat 0:6cc76d70e2a1 282 volatile bool PushButtonStatus;
ubhat 0:6cc76d70e2a1 283
ubhat 0:6cc76d70e2a1 284 PushButtonStatus = UsrButton;
ubhat 2:19dd7bfcacf7 285
ubhat 2:19dd7bfcacf7 286 if(PushButtonStatus == 0) {
ubhat 0:6cc76d70e2a1 287 // Send Pkt immedietly if PC = GND
ubhat 0:6cc76d70e2a1 288 DeviceState = DEVICE_STATE_SEND;
ubhat 0:6cc76d70e2a1 289 NextTx = true;
ubhat 2:19dd7bfcacf7 290 } else {
ubhat 0:6cc76d70e2a1 291 // Keep polling
ubhat 0:6cc76d70e2a1 292 IsTxIntUpdate = true;
ubhat 0:6cc76d70e2a1 293 }
ubhat 2:19dd7bfcacf7 294
ubhat 0:6cc76d70e2a1 295 break;
ubhat 2:19dd7bfcacf7 296 }
ubhat 0:6cc76d70e2a1 297
ubhat 2:19dd7bfcacf7 298 /* Orientation Demo
ubhat 2:19dd7bfcacf7 299 Send Packet Immedietly if Mote is Vertical
ubhat 2:19dd7bfcacf7 300 */
ubhat 2:19dd7bfcacf7 301 case 12: {
ubhat 2:19dd7bfcacf7 302 // Schedule next packet transmission
ubhat 2:19dd7bfcacf7 303 TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( -APP_TX_DUTYCYCLE_RND, APP_TX_DUTYCYCLE_RND );
ubhat 2:19dd7bfcacf7 304 TimerSetValue( &TxNextPacketTimer, TxDutyCycleTime );
ubhat 2:19dd7bfcacf7 305 TimerStart( &TxNextPacketTimer );
ubhat 0:6cc76d70e2a1 306 break;
ubhat 2:19dd7bfcacf7 307 }
ubhat 0:6cc76d70e2a1 308
ubhat 2:19dd7bfcacf7 309 /* Compliance Test
ubhat 2:19dd7bfcacf7 310 Set Timer interrupt for next uplink
ubhat 2:19dd7bfcacf7 311 */
ubhat 2:19dd7bfcacf7 312 case 224: {
ubhat 0:6cc76d70e2a1 313 // Schedule next packet transmission
ubhat 0:6cc76d70e2a1 314 TimerSetValue( &TxNextPacketTimer, COMPLIANCE_TX_DUTYCYCLE );
ubhat 0:6cc76d70e2a1 315 TimerStart( &TxNextPacketTimer );
ubhat 0:6cc76d70e2a1 316 break;
ubhat 0:6cc76d70e2a1 317 }
ubhat 0:6cc76d70e2a1 318
ubhat 2:19dd7bfcacf7 319 default: {
ubhat 0:6cc76d70e2a1 320 // Schedule next packet transmission
ubhat 0:6cc76d70e2a1 321 TimerSetValue( &TxNextPacketTimer, TxDutyCycleTime );
ubhat 0:6cc76d70e2a1 322 TimerStart( &TxNextPacketTimer );
ubhat 0:6cc76d70e2a1 323 break;
ubhat 0:6cc76d70e2a1 324 }
ubhat 0:6cc76d70e2a1 325 }
ubhat 0:6cc76d70e2a1 326
ubhat 0:6cc76d70e2a1 327 }
ubhat 0:6cc76d70e2a1 328
ubhat 0:6cc76d70e2a1 329 /*!
ubhat 0:6cc76d70e2a1 330 * \brief What to do during JOIN process ? blink/toggle LED etc.
ubhat 0:6cc76d70e2a1 331 */
ubhat 0:6cc76d70e2a1 332 void JoinEvent( void )
ubhat 0:6cc76d70e2a1 333 {
ubhat 0:6cc76d70e2a1 334 // CtrlLED is defined in LoRaBoardAppIf.h
ubhat 0:6cc76d70e2a1 335 // param 1: LED color (Red, Yellow or Green)
ubhat 0:6cc76d70e2a1 336 // param 2: LED_ON or LED_OFF
ubhat 2:19dd7bfcacf7 337 //CtrlLED( Red, LED_ON );
ubhat 0:6cc76d70e2a1 338 }
ubhat 0:6cc76d70e2a1 339
ubhat 0:6cc76d70e2a1 340
ubhat 0:6cc76d70e2a1 341 /*!
ubhat 0:6cc76d70e2a1 342 * \brief What to do during TX ? blink/toggle LED etc.
ubhat 0:6cc76d70e2a1 343 */
ubhat 0:6cc76d70e2a1 344 void TxEvent( void )
ubhat 0:6cc76d70e2a1 345 {
ubhat 0:6cc76d70e2a1 346 int blinkTime = 25000;
ubhat 0:6cc76d70e2a1 347
ubhat 0:6cc76d70e2a1 348 // Blink Red LED for 25msec
ubhat 0:6cc76d70e2a1 349 //BlinkLED( Red, blinkTime );
ubhat 0:6cc76d70e2a1 350 }
ubhat 0:6cc76d70e2a1 351
ubhat 0:6cc76d70e2a1 352 void RxEvent()
ubhat 0:6cc76d70e2a1 353 {
ubhat 0:6cc76d70e2a1 354 // Toggle yellow LED
ubhat 2:19dd7bfcacf7 355 //ToggleLED( Yellow );
ubhat 0:6cc76d70e2a1 356
ubhat 0:6cc76d70e2a1 357 // If Rx Data is 0x01 turn on Green LED else if 0x0 Turn Green LED off
ubhat 2:19dd7bfcacf7 358 if( LoRaMacDownlinkStatus.BufferSize == 1 ) {
ubhat 2:19dd7bfcacf7 359 if( LoRaMacDownlinkStatus.Buffer[0] == 0x01 ) {
ubhat 0:6cc76d70e2a1 360 AppLed = 1;
ubhat 2:19dd7bfcacf7 361 } else {
ubhat 2:19dd7bfcacf7 362 if( LoRaMacDownlinkStatus.Buffer[0] == 0x00 ) {
ubhat 0:6cc76d70e2a1 363 AppLed = 0;
ubhat 0:6cc76d70e2a1 364 }
ubhat 0:6cc76d70e2a1 365 }
ubhat 0:6cc76d70e2a1 366 }
ubhat 0:6cc76d70e2a1 367
ubhat 2:19dd7bfcacf7 368 if( AppLed != 0 ) {
ubhat 0:6cc76d70e2a1 369 // Turn USR_LED ON
ubhat 0:6cc76d70e2a1 370 //UsrLED = 3.3;
ubhat 2:19dd7bfcacf7 371 } else {
ubhat 0:6cc76d70e2a1 372 // Turn USR_LED OFF
ubhat 0:6cc76d70e2a1 373 //UsrLED = 0;
ubhat 0:6cc76d70e2a1 374 }
ubhat 0:6cc76d70e2a1 375 }
ubhat 0:6cc76d70e2a1 376