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