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:
mluis
Date:
Mon Apr 24 13:23:42 2017 +0000
Revision:
6:235854d4b0c4
Parent:
4:cd44376a1408
WARNING: Radio API timings changed from micro-seconds to milliseconds; ; Updated SX1276Lib and mbed libraries to the latest versions

Who changed what in which revision?

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