Retry longer until first packet is catched

This commit is contained in:
Goebish 2019-09-17 15:15:43 +02:00
parent 7513dbb570
commit bff4150dec

View File

@ -25,6 +25,7 @@
static uint8_t frskyx_rx_txid[3]; static uint8_t frskyx_rx_txid[3];
static uint8_t frskyx_rx_chanskip; static uint8_t frskyx_rx_chanskip;
static uint8_t frskyx_rx_disable_lna; static uint8_t frskyx_rx_disable_lna;
static uint8_t frskyx_rx_data_started;
static void __attribute__((unused)) FrSkyX_Rx_initialise() { static void __attribute__((unused)) FrSkyX_Rx_initialise() {
CC2500_Reset(); CC2500_Reset();
@ -130,6 +131,7 @@ uint16_t initFrSkyX_Rx()
frskyx_bind_check = 0; frskyx_bind_check = 0;
frskyx_rx_chanskip = 0; frskyx_rx_chanskip = 0;
hopping_frequency_no = 0; hopping_frequency_no = 0;
frskyx_rx_data_started = 0;
if (IS_BIND_IN_PROGRESS) { if (IS_BIND_IN_PROGRESS) {
phase = FRSKYX_RX_BIND; phase = FRSKYX_RX_BIND;
} }
@ -154,7 +156,8 @@ uint16_t initFrSkyX_Rx()
uint16_t FrSkyX_Rx_callback() uint16_t FrSkyX_Rx_callback()
{ {
static uint32_t pps_timer=0; static uint32_t pps_timer=0;
static uint8_t read_retry=0, pps_counter=0; static uint8_t pps_counter=0;
static int8_t read_retry = 0;
uint8_t len, ch; uint8_t len, ch;
if (prev_option != option) if (prev_option != option)
{ {
@ -215,6 +218,7 @@ uint16_t FrSkyX_Rx_callback()
//if(chan1 < 2048) //if(chan1 < 2048)
// debugln("Ch1: %d Ch2: %d", chan1, chan2); // debugln("Ch1: %d Ch2: %d", chan1, chan2);
} }
frskyx_rx_data_started = 1;
read_retry = 0; read_retry = 0;
pps_counter++; pps_counter++;
} }
@ -231,7 +235,10 @@ uint16_t FrSkyX_Rx_callback()
if (read_retry++ >= 9) { if (read_retry++ >= 9) {
hopping_frequency_no = (hopping_frequency_no + frskyx_rx_chanskip) % 47; hopping_frequency_no = (hopping_frequency_no + frskyx_rx_chanskip) % 47;
frskyx_rx_set_channel(hopping_frequency_no); frskyx_rx_set_channel(hopping_frequency_no);
if(frskyx_rx_data_started)
read_retry = 0; read_retry = 0;
else
read_retry = -50; // retry longer until first packet is catched
} }
break; break;
} }