working demo for Nucleo-L152RE and Nucleo-F446RE with modtronix inair9 module

Dependencies:   mbed

Committer:
GregCr
Date:
Fri Sep 19 15:24:34 2014 +0000
Revision:
5:f2431c4fe3bb
Parent:
4:5ece30264cd9
Child:
6:44752b4f8ab1
Minor correction

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GregCr 0:1ed39951ab7b 1 #include "mbed.h"
GregCr 4:5ece30264cd9 2 #include "main.h"
GregCr 0:1ed39951ab7b 3 #include "sx1276-hal.h"
GregCr 4:5ece30264cd9 4 #include "mbed_debug.h"
GregCr 0:1ed39951ab7b 5
GregCr 0:1ed39951ab7b 6 /* Set this flag to '1' to display debug messages on the console */
GregCr 5:f2431c4fe3bb 7 #define DEBUG_MESSAGE 0
GregCr 0:1ed39951ab7b 8
GregCr 0:1ed39951ab7b 9
GregCr 0:1ed39951ab7b 10 /* Set this flag to '1' to use the LoRa modulation or to '0' to use FSK modulation */
GregCr 5:f2431c4fe3bb 11 #define USE_MODEM_LORA 1
GregCr 0:1ed39951ab7b 12 #define USE_MODEM_FSK !USE_MODEM_LORA
GregCr 0:1ed39951ab7b 13
GregCr 5:f2431c4fe3bb 14 #define RF_FREQUENCY 868000000 // Hz
GregCr 0:1ed39951ab7b 15 #define TX_OUTPUT_POWER 14 // 14 dBm
GregCr 0:1ed39951ab7b 16
GregCr 0:1ed39951ab7b 17 #if USE_MODEM_LORA == 1
GregCr 0:1ed39951ab7b 18
GregCr 1:126d70d374f6 19 #define LORA_BANDWIDTH 2 // [0: 125 kHz,
GregCr 0:1ed39951ab7b 20 // 1: 250 kHz,
GregCr 0:1ed39951ab7b 21 // 2: 500 kHz,
GregCr 0:1ed39951ab7b 22 // 3: Reserved]
GregCr 0:1ed39951ab7b 23 #define LORA_SPREADING_FACTOR 7 // [SF7..SF12]
GregCr 0:1ed39951ab7b 24 #define LORA_CODINGRATE 1 // [1: 4/5,
GregCr 0:1ed39951ab7b 25 // 2: 4/6,
GregCr 0:1ed39951ab7b 26 // 3: 4/7,
GregCr 0:1ed39951ab7b 27 // 4: 4/8]
GregCr 0:1ed39951ab7b 28 #define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx
GregCr 0:1ed39951ab7b 29 #define LORA_SYMBOL_TIMEOUT 5 // Symbols
GregCr 0:1ed39951ab7b 30 #define LORA_FIX_LENGTH_PAYLOAD_ON false
GregCr 3:8b9e2a4df4b5 31 #define LORA_FHSS_ENABLED false
GregCr 3:8b9e2a4df4b5 32 #define LORA_NB_SYMB_HOP 4
GregCr 0:1ed39951ab7b 33 #define LORA_IQ_INVERSION_ON false
GregCr 3:8b9e2a4df4b5 34 #define LORA_CRC_ENABLED true
GregCr 3:8b9e2a4df4b5 35
GregCr 0:1ed39951ab7b 36 #elif USE_MODEM_FSK == 1
GregCr 0:1ed39951ab7b 37
GregCr 2:59e108728d71 38 #define FSK_FDEV 25000 // Hz
GregCr 2:59e108728d71 39 #define FSK_DATARATE 19200 // bps
GregCr 2:59e108728d71 40 #define FSK_BANDWIDTH 50000 // Hz
GregCr 2:59e108728d71 41 #define FSK_AFC_BANDWIDTH 83333 // Hz
GregCr 0:1ed39951ab7b 42 #define FSK_PREAMBLE_LENGTH 5 // Same for Tx and Rx
GregCr 0:1ed39951ab7b 43 #define FSK_FIX_LENGTH_PAYLOAD_ON false
GregCr 3:8b9e2a4df4b5 44 #define FSK_CRC_ENABLED true
GregCr 3:8b9e2a4df4b5 45
GregCr 0:1ed39951ab7b 46 #else
GregCr 0:1ed39951ab7b 47 #error "Please define a modem in the compiler options."
GregCr 0:1ed39951ab7b 48 #endif
GregCr 0:1ed39951ab7b 49
GregCr 0:1ed39951ab7b 50 #define RX_TIMEOUT_VALUE 3000000 // in us
GregCr 0:1ed39951ab7b 51 #define BUFFER_SIZE 32 // Define the payload size here
GregCr 0:1ed39951ab7b 52
GregCr 3:8b9e2a4df4b5 53 #if( defined ( TARGET_KL25Z ) )
GregCr 3:8b9e2a4df4b5 54 DigitalOut led(LED2);
GregCr 3:8b9e2a4df4b5 55 #else
GregCr 3:8b9e2a4df4b5 56 DigitalOut led(LED1);
GregCr 3:8b9e2a4df4b5 57 #endif
GregCr 3:8b9e2a4df4b5 58
GregCr 0:1ed39951ab7b 59 /*
GregCr 0:1ed39951ab7b 60 * Global variables declarations
GregCr 0:1ed39951ab7b 61 */
GregCr 0:1ed39951ab7b 62 typedef RadioState States_t;
GregCr 0:1ed39951ab7b 63
GregCr 0:1ed39951ab7b 64 /*
GregCr 0:1ed39951ab7b 65 * Global variables declarations
GregCr 0:1ed39951ab7b 66 */
GregCr 4:5ece30264cd9 67 SX1276MB1xAS Radio( OnTxDone, OnTxTimeout, OnRxDone, OnRxTimeout, OnRxError, NULL, NULL );
GregCr 0:1ed39951ab7b 68
GregCr 0:1ed39951ab7b 69 const uint8_t PingMsg[] = "PING";
GregCr 0:1ed39951ab7b 70 const uint8_t PongMsg[] = "PONG";
GregCr 0:1ed39951ab7b 71
GregCr 0:1ed39951ab7b 72 uint16_t BufferSize = BUFFER_SIZE;
GregCr 0:1ed39951ab7b 73 uint8_t Buffer[BUFFER_SIZE];
GregCr 0:1ed39951ab7b 74
GregCr 0:1ed39951ab7b 75 volatile States_t State = LOWPOWER;
GregCr 0:1ed39951ab7b 76
GregCr 5:f2431c4fe3bb 77 int16_t RssiValue = 0.0;
GregCr 5:f2431c4fe3bb 78 int8_t SnrValue = 0.0;
GregCr 0:1ed39951ab7b 79
GregCr 0:1ed39951ab7b 80 int main()
GregCr 0:1ed39951ab7b 81 {
GregCr 0:1ed39951ab7b 82 uint8_t i;
GregCr 0:1ed39951ab7b 83 bool isMaster = true;
GregCr 0:1ed39951ab7b 84
GregCr 1:126d70d374f6 85 debug( "\n\r\n\r SX1276 Ping Pong Demo Application \n\r" );
GregCr 0:1ed39951ab7b 86
GregCr 0:1ed39951ab7b 87 #if defined TARGET_NUCLEO_L152RE
GregCr 5:f2431c4fe3bb 88 debug_if( DEBUG_MESSAGE, " > Nucleo-L152RE Platform <\r\n", NULL );
GregCr 0:1ed39951ab7b 89 #elif defined TARGET_KL25Z
GregCr 4:5ece30264cd9 90 debug_if( DEBUG_MESSAGE, " > KL25Z Platform <\r\n", NULL );
GregCr 0:1ed39951ab7b 91 #elif defined TARGET_LPC11U6X
GregCr 4:5ece30264cd9 92 debug_if( DEBUG_MESSAGE, " > LPC11U6X Platform <\r\n", NULL );
GregCr 0:1ed39951ab7b 93 #else
GregCr 4:5ece30264cd9 94 debug_if( DEBUG_MESSAGE, " > Untested Platform <\r\n", NULL );
GregCr 0:1ed39951ab7b 95 #endif
GregCr 0:1ed39951ab7b 96
GregCr 2:59e108728d71 97 if( Radio.DetectBoardType( ) == SX1276MB1LAS )
GregCr 2:59e108728d71 98 {
GregCr 4:5ece30264cd9 99 debug_if( DEBUG_MESSAGE, "\n\r > Board Type: SX1276MB1LAS < \n\r", NULL );
GregCr 2:59e108728d71 100 }
GregCr 2:59e108728d71 101 else
GregCr 2:59e108728d71 102 {
GregCr 4:5ece30264cd9 103 debug_if( DEBUG_MESSAGE, "\n\r > Board Type: SX1276MB1MAS < \n\r", NULL );
GregCr 2:59e108728d71 104 }
GregCr 2:59e108728d71 105
GregCr 4:5ece30264cd9 106 debug_if( DEBUG_MESSAGE, " > Chipset Version = 0x%x < \n\r", Radio.Read( REG_VERSION ) );
GregCr 1:126d70d374f6 107
GregCr 0:1ed39951ab7b 108 Radio.SetChannel( RF_FREQUENCY );
GregCr 0:1ed39951ab7b 109
GregCr 0:1ed39951ab7b 110 #if USE_MODEM_LORA == 1
GregCr 3:8b9e2a4df4b5 111
GregCr 3:8b9e2a4df4b5 112 if( LORA_FHSS_ENABLED == true )
GregCr 3:8b9e2a4df4b5 113 {
GregCr 3:8b9e2a4df4b5 114 debug("\n\r\n\r > LORA FHSS Mode < \n\r\n\r");
GregCr 3:8b9e2a4df4b5 115 }
GregCr 3:8b9e2a4df4b5 116 else
GregCr 3:8b9e2a4df4b5 117 {
GregCr 3:8b9e2a4df4b5 118 debug("\n\r\n\r > LORA Mode < \n\r\n\r");
GregCr 3:8b9e2a4df4b5 119 }
GregCr 0:1ed39951ab7b 120 Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
GregCr 0:1ed39951ab7b 121 LORA_SPREADING_FACTOR, LORA_CODINGRATE,
GregCr 0:1ed39951ab7b 122 LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
GregCr 3:8b9e2a4df4b5 123 LORA_CRC_ENABLED, LORA_FHSS_ENABLED, LORA_NB_SYMB_HOP,
GregCr 3:8b9e2a4df4b5 124 LORA_IQ_INVERSION_ON, 3000000 );
GregCr 0:1ed39951ab7b 125
GregCr 0:1ed39951ab7b 126 Radio.SetRxConfig( MODEM_LORA, LORA_BANDWIDTH, LORA_SPREADING_FACTOR,
GregCr 0:1ed39951ab7b 127 LORA_CODINGRATE, 0, LORA_PREAMBLE_LENGTH,
GregCr 0:1ed39951ab7b 128 LORA_SYMBOL_TIMEOUT, LORA_FIX_LENGTH_PAYLOAD_ON,
GregCr 3:8b9e2a4df4b5 129 LORA_CRC_ENABLED, LORA_FHSS_ENABLED, LORA_NB_SYMB_HOP,
GregCr 3:8b9e2a4df4b5 130 LORA_IQ_INVERSION_ON, true );
GregCr 0:1ed39951ab7b 131
GregCr 0:1ed39951ab7b 132 #elif USE_MODEM_FSK == 1
GregCr 0:1ed39951ab7b 133
GregCr 0:1ed39951ab7b 134 debug("\n\r\n\r > FSK Mode < \n\r\n\r");
GregCr 0:1ed39951ab7b 135 Radio.SetTxConfig( MODEM_FSK, TX_OUTPUT_POWER, FSK_FDEV, 0,
GregCr 0:1ed39951ab7b 136 FSK_DATARATE, 0,
GregCr 0:1ed39951ab7b 137 FSK_PREAMBLE_LENGTH, FSK_FIX_LENGTH_PAYLOAD_ON,
GregCr 3:8b9e2a4df4b5 138 FSK_CRC_ENABLED, 0, 0, 0, 3000000 );
GregCr 0:1ed39951ab7b 139
GregCr 0:1ed39951ab7b 140 Radio.SetRxConfig( MODEM_FSK, FSK_BANDWIDTH, FSK_DATARATE,
GregCr 0:1ed39951ab7b 141 0, FSK_AFC_BANDWIDTH, FSK_PREAMBLE_LENGTH,
GregCr 3:8b9e2a4df4b5 142 0, FSK_FIX_LENGTH_PAYLOAD_ON, FSK_CRC_ENABLED,
GregCr 3:8b9e2a4df4b5 143 0, 0, false, true );
GregCr 0:1ed39951ab7b 144
GregCr 0:1ed39951ab7b 145 #else
GregCr 0:1ed39951ab7b 146
GregCr 0:1ed39951ab7b 147 #error "Please define a modem in the compiler options."
GregCr 0:1ed39951ab7b 148
GregCr 0:1ed39951ab7b 149 #endif
GregCr 1:126d70d374f6 150
GregCr 4:5ece30264cd9 151 debug_if( DEBUG_MESSAGE, "Starting Ping-Pong loop\r\n", NULL );
GregCr 0:1ed39951ab7b 152
GregCr 3:8b9e2a4df4b5 153 led = 0;
GregCr 3:8b9e2a4df4b5 154
GregCr 0:1ed39951ab7b 155 Radio.Rx( RX_TIMEOUT_VALUE );
GregCr 0:1ed39951ab7b 156
GregCr 0:1ed39951ab7b 157 while( 1 )
GregCr 0:1ed39951ab7b 158 {
GregCr 0:1ed39951ab7b 159 switch( State )
GregCr 0:1ed39951ab7b 160 {
GregCr 0:1ed39951ab7b 161 case RX:
GregCr 0:1ed39951ab7b 162 if( isMaster == true )
GregCr 0:1ed39951ab7b 163 {
GregCr 0:1ed39951ab7b 164 if( BufferSize > 0 )
GregCr 0:1ed39951ab7b 165 {
GregCr 0:1ed39951ab7b 166 if( strncmp( ( const char* )Buffer, ( const char* )PongMsg, 4 ) == 0 )
GregCr 0:1ed39951ab7b 167 {
GregCr 3:8b9e2a4df4b5 168 led = !led;
GregCr 2:59e108728d71 169 debug( "...Pong\r\n" );
GregCr 0:1ed39951ab7b 170 // Send the next PING frame
GregCr 0:1ed39951ab7b 171 Buffer[0] = 'P';
GregCr 0:1ed39951ab7b 172 Buffer[1] = 'I';
GregCr 0:1ed39951ab7b 173 Buffer[2] = 'N';
GregCr 0:1ed39951ab7b 174 Buffer[3] = 'G';
GregCr 0:1ed39951ab7b 175 // We fill the buffer with numbers for the payload
GregCr 0:1ed39951ab7b 176 for( i = 4; i < BufferSize; i++ )
GregCr 0:1ed39951ab7b 177 {
GregCr 0:1ed39951ab7b 178 Buffer[i] = i - 4;
GregCr 0:1ed39951ab7b 179 }
GregCr 0:1ed39951ab7b 180 wait_ms( 10 );
GregCr 0:1ed39951ab7b 181 Radio.Send( Buffer, BufferSize );
GregCr 0:1ed39951ab7b 182 }
GregCr 2:59e108728d71 183 else if( strncmp( ( const char* )Buffer, ( const char* )PingMsg, 4 ) == 0 )
GregCr 0:1ed39951ab7b 184 { // A master already exists then become a slave
GregCr 2:59e108728d71 185 debug( "...Ping\r\n" );
GregCr 3:8b9e2a4df4b5 186 led = !led;
GregCr 0:1ed39951ab7b 187 isMaster = false;
GregCr 2:59e108728d71 188 // Send the next PING frame
GregCr 2:59e108728d71 189 Buffer[0] = 'P';
GregCr 2:59e108728d71 190 Buffer[1] = 'O';
GregCr 2:59e108728d71 191 Buffer[2] = 'N';
GregCr 2:59e108728d71 192 Buffer[3] = 'G';
GregCr 2:59e108728d71 193 // We fill the buffer with numbers for the payload
GregCr 2:59e108728d71 194 for( i = 4; i < BufferSize; i++ )
GregCr 2:59e108728d71 195 {
GregCr 2:59e108728d71 196 Buffer[i] = i - 4;
GregCr 2:59e108728d71 197 }
GregCr 3:8b9e2a4df4b5 198 wait_ms( 10 );
GregCr 2:59e108728d71 199 Radio.Send( Buffer, BufferSize );
GregCr 2:59e108728d71 200 }
GregCr 2:59e108728d71 201 else // valid reception but neither a PING or a PONG message
GregCr 2:59e108728d71 202 { // Set device as master ans start again
GregCr 2:59e108728d71 203 isMaster = true;
GregCr 0:1ed39951ab7b 204 Radio.Rx( RX_TIMEOUT_VALUE );
GregCr 2:59e108728d71 205 }
GregCr 0:1ed39951ab7b 206 }
GregCr 0:1ed39951ab7b 207 }
GregCr 0:1ed39951ab7b 208 else
GregCr 0:1ed39951ab7b 209 {
GregCr 0:1ed39951ab7b 210 if( BufferSize > 0 )
GregCr 0:1ed39951ab7b 211 {
GregCr 0:1ed39951ab7b 212 if( strncmp( ( const char* )Buffer, ( const char* )PingMsg, 4 ) == 0 )
GregCr 0:1ed39951ab7b 213 {
GregCr 3:8b9e2a4df4b5 214 led = !led;
GregCr 2:59e108728d71 215 debug( "...Ping\r\n" );
GregCr 2:59e108728d71 216 // Send the reply to the PING string
GregCr 0:1ed39951ab7b 217 Buffer[0] = 'P';
GregCr 0:1ed39951ab7b 218 Buffer[1] = 'O';
GregCr 0:1ed39951ab7b 219 Buffer[2] = 'N';
GregCr 0:1ed39951ab7b 220 Buffer[3] = 'G';
GregCr 0:1ed39951ab7b 221 // We fill the buffer with numbers for the payload
GregCr 0:1ed39951ab7b 222 for( i = 4; i < BufferSize; i++ )
GregCr 0:1ed39951ab7b 223 {
GregCr 0:1ed39951ab7b 224 Buffer[i] = i - 4;
GregCr 0:1ed39951ab7b 225 }
GregCr 0:1ed39951ab7b 226 wait_ms( 10 );
GregCr 0:1ed39951ab7b 227 Radio.Send( Buffer, BufferSize );
GregCr 0:1ed39951ab7b 228 }
GregCr 2:59e108728d71 229 else // valid reception but not a PING as expected
GregCr 2:59e108728d71 230 { // Set device as master and start again
GregCr 2:59e108728d71 231 isMaster = true;
GregCr 2:59e108728d71 232 Radio.Rx( RX_TIMEOUT_VALUE );
GregCr 2:59e108728d71 233 }
GregCr 0:1ed39951ab7b 234 }
GregCr 0:1ed39951ab7b 235 }
GregCr 0:1ed39951ab7b 236 State = LOWPOWER;
GregCr 0:1ed39951ab7b 237 break;
GregCr 3:8b9e2a4df4b5 238 case TX:
GregCr 3:8b9e2a4df4b5 239 led = !led;
GregCr 2:59e108728d71 240 if( isMaster == true )
GregCr 0:1ed39951ab7b 241 {
GregCr 2:59e108728d71 242 debug( "Ping...\r\n" );
GregCr 0:1ed39951ab7b 243 }
GregCr 0:1ed39951ab7b 244 else
GregCr 0:1ed39951ab7b 245 {
GregCr 2:59e108728d71 246 debug( "Pong...\r\n" );
GregCr 0:1ed39951ab7b 247 }
GregCr 0:1ed39951ab7b 248 Radio.Rx( RX_TIMEOUT_VALUE );
GregCr 0:1ed39951ab7b 249 State = LOWPOWER;
GregCr 0:1ed39951ab7b 250 break;
GregCr 0:1ed39951ab7b 251 case RX_TIMEOUT:
GregCr 0:1ed39951ab7b 252 if( isMaster == true )
GregCr 0:1ed39951ab7b 253 {
GregCr 0:1ed39951ab7b 254 // Send the next PING frame
GregCr 0:1ed39951ab7b 255 Buffer[0] = 'P';
GregCr 0:1ed39951ab7b 256 Buffer[1] = 'I';
GregCr 0:1ed39951ab7b 257 Buffer[2] = 'N';
GregCr 0:1ed39951ab7b 258 Buffer[3] = 'G';
GregCr 0:1ed39951ab7b 259 for( i = 4; i < BufferSize; i++ )
GregCr 0:1ed39951ab7b 260 {
GregCr 0:1ed39951ab7b 261 Buffer[i] = i - 4;
GregCr 0:1ed39951ab7b 262 }
GregCr 0:1ed39951ab7b 263 wait_ms( 10 );
GregCr 0:1ed39951ab7b 264 Radio.Send( Buffer, BufferSize );
GregCr 0:1ed39951ab7b 265 }
GregCr 0:1ed39951ab7b 266 else
GregCr 0:1ed39951ab7b 267 {
GregCr 0:1ed39951ab7b 268 Radio.Rx( RX_TIMEOUT_VALUE );
GregCr 0:1ed39951ab7b 269 }
GregCr 0:1ed39951ab7b 270 State = LOWPOWER;
GregCr 0:1ed39951ab7b 271 break;
GregCr 0:1ed39951ab7b 272 case RX_ERROR:
GregCr 0:1ed39951ab7b 273 if( isMaster == true )
GregCr 0:1ed39951ab7b 274 {
GregCr 0:1ed39951ab7b 275 // Send the next PING frame
GregCr 0:1ed39951ab7b 276 Buffer[0] = 'P';
GregCr 0:1ed39951ab7b 277 Buffer[1] = 'I';
GregCr 0:1ed39951ab7b 278 Buffer[2] = 'N';
GregCr 0:1ed39951ab7b 279 Buffer[3] = 'G';
GregCr 0:1ed39951ab7b 280 for( i = 4; i < BufferSize; i++ )
GregCr 0:1ed39951ab7b 281 {
GregCr 0:1ed39951ab7b 282 Buffer[i] = i - 4;
GregCr 0:1ed39951ab7b 283 }
GregCr 0:1ed39951ab7b 284 wait_ms( 10 );
GregCr 0:1ed39951ab7b 285 Radio.Send( Buffer, BufferSize );
GregCr 0:1ed39951ab7b 286 }
GregCr 0:1ed39951ab7b 287 else
GregCr 0:1ed39951ab7b 288 {
GregCr 2:59e108728d71 289 // Send the next PONG frame
GregCr 2:59e108728d71 290 Buffer[0] = 'P';
GregCr 2:59e108728d71 291 Buffer[1] = 'O';
GregCr 2:59e108728d71 292 Buffer[2] = 'N';
GregCr 2:59e108728d71 293 Buffer[3] = 'G';
GregCr 2:59e108728d71 294 for( i = 4; i < BufferSize; i++ )
GregCr 2:59e108728d71 295 {
GregCr 2:59e108728d71 296 Buffer[i] = i - 4;
GregCr 2:59e108728d71 297 }
GregCr 2:59e108728d71 298 wait_ms( 10 );
GregCr 2:59e108728d71 299 Radio.Send( Buffer, BufferSize );
GregCr 0:1ed39951ab7b 300 }
GregCr 0:1ed39951ab7b 301 State = LOWPOWER;
GregCr 0:1ed39951ab7b 302 break;
GregCr 0:1ed39951ab7b 303 case TX_TIMEOUT:
GregCr 0:1ed39951ab7b 304 Radio.Rx( RX_TIMEOUT_VALUE );
GregCr 0:1ed39951ab7b 305 State = LOWPOWER;
GregCr 0:1ed39951ab7b 306 break;
GregCr 0:1ed39951ab7b 307 case LOWPOWER:
GregCr 0:1ed39951ab7b 308 break;
GregCr 0:1ed39951ab7b 309 default:
GregCr 0:1ed39951ab7b 310 State = LOWPOWER;
GregCr 0:1ed39951ab7b 311 break;
GregCr 0:1ed39951ab7b 312 }
GregCr 0:1ed39951ab7b 313 }
GregCr 0:1ed39951ab7b 314 }
GregCr 0:1ed39951ab7b 315
GregCr 0:1ed39951ab7b 316 void OnTxDone( void )
GregCr 0:1ed39951ab7b 317 {
GregCr 4:5ece30264cd9 318 debug_if( DEBUG_MESSAGE, "> OnTxDone\n\r", NULL );
GregCr 5:f2431c4fe3bb 319 Radio.Sleep( );
GregCr 0:1ed39951ab7b 320 State = TX;
GregCr 0:1ed39951ab7b 321 }
GregCr 0:1ed39951ab7b 322
GregCr 4:5ece30264cd9 323 void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr)
GregCr 0:1ed39951ab7b 324 {
GregCr 4:5ece30264cd9 325 debug_if( DEBUG_MESSAGE, "> OnRxDone\n\r", NULL );
GregCr 0:1ed39951ab7b 326 Radio.Sleep( );
GregCr 0:1ed39951ab7b 327 BufferSize = size;
GregCr 0:1ed39951ab7b 328 memcpy( Buffer, payload, BufferSize );
GregCr 0:1ed39951ab7b 329 RssiValue = rssi;
GregCr 0:1ed39951ab7b 330 SnrValue = snr;
GregCr 0:1ed39951ab7b 331 State = RX;
GregCr 0:1ed39951ab7b 332 }
GregCr 0:1ed39951ab7b 333
GregCr 0:1ed39951ab7b 334 void OnTxTimeout( void )
GregCr 0:1ed39951ab7b 335 {
GregCr 4:5ece30264cd9 336 debug_if( DEBUG_MESSAGE, "> OnTxTimeout\n\r", NULL );
GregCr 0:1ed39951ab7b 337 Radio.Sleep( );
GregCr 0:1ed39951ab7b 338 State = TX_TIMEOUT;
GregCr 0:1ed39951ab7b 339 }
GregCr 0:1ed39951ab7b 340
GregCr 0:1ed39951ab7b 341 void OnRxTimeout( void )
GregCr 0:1ed39951ab7b 342 {
GregCr 4:5ece30264cd9 343 debug_if( DEBUG_MESSAGE, "> OnRxTimeout\n\r", NULL );
GregCr 0:1ed39951ab7b 344 Radio.Sleep( );
GregCr 1:126d70d374f6 345 Buffer[ BufferSize ] = 0;
GregCr 0:1ed39951ab7b 346 State = RX_TIMEOUT;
GregCr 0:1ed39951ab7b 347 }
GregCr 0:1ed39951ab7b 348
GregCr 0:1ed39951ab7b 349 void OnRxError( void )
GregCr 0:1ed39951ab7b 350 {
GregCr 4:5ece30264cd9 351 debug_if( DEBUG_MESSAGE, "> OnRxError\n\r", NULL );
GregCr 0:1ed39951ab7b 352 Radio.Sleep( );
GregCr 0:1ed39951ab7b 353 State = RX_ERROR;
GregCr 0:1ed39951ab7b 354 }
GregCr 3:8b9e2a4df4b5 355