mirror of
https://github.com/markqvist/RNode_Firmware.git
synced 2025-05-07 17:15:02 -04:00
Accurate preamble and airtime calculations on SX1280. Fix airtime calculation on SX1262 when LDRO is enabled.
This commit is contained in:
parent
b667e825f8
commit
c39164e272
8 changed files with 99 additions and 57 deletions
20
Utilities.h
20
Utilities.h
|
@ -863,8 +863,8 @@ void kiss_indicate_phy_stats() {
|
|||
#if MCU_VARIANT == MCU_ESP32
|
||||
uint16_t lst = (uint16_t)(lora_symbol_time_ms*1000);
|
||||
uint16_t lsr = (uint16_t)(lora_symbol_rate);
|
||||
uint16_t prs = (uint16_t)(lora_preamble_symbols+4);
|
||||
uint16_t prt = (uint16_t)((lora_preamble_symbols+4)*lora_symbol_time_ms);
|
||||
uint16_t prs = (uint16_t)(lora_preamble_symbols);
|
||||
uint16_t prt = (uint16_t)((lora_preamble_symbols)*lora_symbol_time_ms);
|
||||
uint16_t cst = (uint16_t)(csma_slot_ms);
|
||||
serial_write(FEND);
|
||||
serial_write(CMD_STAT_PHYPRM);
|
||||
|
@ -1091,20 +1091,14 @@ void updateBitrate() {
|
|||
lora_symbol_time_ms = (1.0/lora_symbol_rate)*1000.0;
|
||||
lora_bitrate = (uint32_t)(lora_sf * ( (4.0/(float)lora_cr) / ((float)(pow(2, lora_sf))/((float)lora_bw/1000.0)) ) * 1000.0);
|
||||
lora_us_per_byte = 1000000.0/((float)lora_bitrate/8.0);
|
||||
csma_slot_ms = lora_symbol_time_ms*12;
|
||||
|
||||
csma_slot_ms = lora_symbol_time_ms*CSMA_SLOT_SYMBOLS;
|
||||
if (csma_slot_ms > CSMA_SLOT_MAX_MS) { csma_slot_ms = CSMA_SLOT_MAX_MS; }
|
||||
if (csma_slot_ms < CSMA_SLOT_MIN_MS) { csma_slot_ms = CSMA_SLOT_MIN_MS; }
|
||||
float target_preamble_symbols = (LORA_PREAMBLE_TARGET_MS/lora_symbol_time_ms)-LORA_PREAMBLE_SYMBOLS_HW;
|
||||
|
||||
#if MODEM == SX1280
|
||||
target_preamble_symbols = 12;
|
||||
#else
|
||||
if (target_preamble_symbols < LORA_PREAMBLE_SYMBOLS_MIN) {
|
||||
target_preamble_symbols = LORA_PREAMBLE_SYMBOLS_MIN;
|
||||
} else {
|
||||
target_preamble_symbols = ceil(target_preamble_symbols);
|
||||
}
|
||||
#endif
|
||||
float target_preamble_symbols = LORA_PREAMBLE_TARGET_MS/lora_symbol_time_ms;
|
||||
if (target_preamble_symbols < LORA_PREAMBLE_SYMBOLS_MIN) { target_preamble_symbols = LORA_PREAMBLE_SYMBOLS_MIN; }
|
||||
else { target_preamble_symbols = (ceil)(target_preamble_symbols); }
|
||||
|
||||
lora_preamble_symbols = (long)target_preamble_symbols;
|
||||
setPreamble();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue