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:
bootcamps
Date:
Sat Oct 06 01:43:37 2018 +0000
Revision:
12:5222f008392b
Parent:
10:bba416e2c3e1
Update LR

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