@@ -406,32 +406,39 @@ void LoRaPHY::get_rx_window_params(float t_symb, uint8_t min_rx_symb,
406
406
uint32_t *window_length, int32_t *window_offset,
407
407
uint8_t phy_dr)
408
408
{
409
- float min_rx_symbol_overlap_required = float (min_rx_symb);
410
409
float target_rx_window_offset;
411
410
float window_len_in_ms;
412
411
413
412
if (phy_params.fsk_supported && phy_dr == phy_params.max_rx_datarate ) {
414
- min_rx_symbol_overlap_required = MAX_PREAMBLE_LENGTH;
413
+ min_rx_symb = MAX_PREAMBLE_LENGTH;
415
414
}
416
415
417
416
// We wish to be as close as possible to the actual start of data, i.e.,
418
417
// we are interested in the preamble symbols which are at the tail of the
419
418
// preamble sequence.
420
- target_rx_window_offset = (MAX_PREAMBLE_LENGTH - min_rx_symbol_overlap_required ) * t_symb; // in ms
419
+ target_rx_window_offset = (MAX_PREAMBLE_LENGTH - min_rx_symb ) * t_symb; // in ms
421
420
422
421
// Actual window offset in ms in response to timing error fudge factor and
423
422
// radio wakeup/turned around time.
424
- *window_offset = floor (target_rx_window_offset - error_fudge - wakeup_time);
423
+ *window_offset = floor (target_rx_window_offset - error_fudge - MBED_CONF_LORA_WAKEUP_TIME);
424
+
425
+ // possible wait for next symbol start if we start inside the preamble
426
+ float possible_wait_for_symb_start = MIN (t_symb,
427
+ ((2 * error_fudge) + MBED_CONF_LORA_WAKEUP_TIME + TICK_GRANULARITY_JITTER));
428
+
429
+ // how early we might start reception relative to transmit start (so negative if before transmit starts)
430
+ float earliest_possible_start_time = *window_offset - error_fudge - TICK_GRANULARITY_JITTER;
431
+
432
+ // time in (ms) we may have to wait for the other side to start transmission
433
+ float possible_wait_for_transmit = -earliest_possible_start_time;
425
434
426
435
// Minimum reception time plus extra time (in ms) we may have turned on before the
427
436
// other side started transmission
428
- window_len_in_ms = (min_rx_symbol_overlap_required * t_symb) - MIN ( 0 , (*window_offset - error_fudge - TICK_GRANULARITY_JITTER) );
437
+ window_len_in_ms = (min_rx_symb * t_symb) + MAX (possible_wait_for_transmit, possible_wait_for_symb_start );
429
438
430
439
// Setting the window_length in terms of 'symbols' for LoRa modulation or
431
440
// in terms of 'bytes' for FSK
432
441
*window_length = (uint32_t ) ceil (window_len_in_ms / t_symb);
433
-
434
-
435
442
}
436
443
437
444
int8_t LoRaPHY::compute_tx_power (int8_t tx_power_idx, float max_eirp,
@@ -874,13 +881,13 @@ bool LoRaPHY::rx_config(rx_config_params_t *rx_conf)
874
881
// Radio configuration
875
882
if (dr == DR_7 && phy_params.fsk_supported ) {
876
883
modem = MODEM_FSK;
877
- _radio->set_rx_config (modem, 50000 , phy_dr * 1000 , 0 , 83333 , 5 ,
884
+ _radio->set_rx_config (modem, 50000 , phy_dr * 1000 , 0 , 83333 , MAX_PREAMBLE_LENGTH ,
878
885
rx_conf->window_timeout , false , 0 , true , 0 , 0 ,
879
886
false , rx_conf->is_rx_continuous );
880
887
} else {
881
888
modem = MODEM_LORA;
882
889
_radio->set_rx_config (modem, rx_conf->bandwidth , phy_dr, 1 , 0 ,
883
- MBED_CONF_LORA_DOWNLINK_PREAMBLE_LENGTH ,
890
+ MAX_PREAMBLE_LENGTH ,
884
891
rx_conf->window_timeout , false , 0 , false , 0 , 0 ,
885
892
true , rx_conf->is_rx_continuous );
886
893
}
@@ -926,8 +933,8 @@ bool LoRaPHY::tx_config(tx_config_params_t *tx_conf, int8_t *tx_power,
926
933
// High Speed FSK channel
927
934
modem = MODEM_FSK;
928
935
_radio->set_tx_config (modem, phy_tx_power, 25000 , bandwidth,
929
- phy_dr * 1000 , 0 , 5 , false , true , 0 , 0 , false ,
930
- 3000 );
936
+ phy_dr * 1000 , 0 , MBED_CONF_LORA_UPLINK_PREAMBLE_LENGTH ,
937
+ false , true , 0 , 0 , false , 3000 );
931
938
} else {
932
939
modem = MODEM_LORA;
933
940
_radio->set_tx_config (modem, phy_tx_power, 0 , bandwidth, phy_dr, 1 ,
0 commit comments