SX1276 Ping Pong FHSS Demo Application

Dependencies:   SX1276Lib mbed

Ping-Pong demo application using FHSS (Frequency Hoping Spread Spectrum) between two SX1276MB1xAs demo board.

Application demonstrating simple Tx/Rx between two boards. By default, each board starts as a "master" and will transmit a "Ping" message, and then wait for an answer. The first board receiving a "Ping" message will become a slave and answer the "master" with a "Pong". The Ping-Pong is then started...

Committer:
GregCr
Date:
Fri Sep 19 15:25:35 2014 +0000
Revision:
0:db48addeabda
Child:
1:41b10c760ff2
First commit

Who changed what in which revision?

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