[SX126x] Simplify receive timeout duration (5x ToA instead of 100 symbols)

pull/1592/head
jgromes 2025-09-07 13:07:55 +01:00
rodzic c7e9da7cd9
commit 2f291ddbf5
1 zmienionych plików z 4 dodań i 18 usunięć

Wyświetl plik

@ -256,24 +256,10 @@ int16_t SX126x::receive(uint8_t* data, size_t len, RadioLibTime_t timeout) {
RadioLibTime_t timeoutInternal = timeout;
if(!timeoutInternal) {
// get currently active modem
uint8_t modem = getPacketType();
if(modem == RADIOLIB_SX126X_PACKET_TYPE_LORA) {
// calculate timeout (100 LoRa symbols, the default for SX127x series)
float symbolLength = (float)(uint32_t(1) << this->spreadingFactor) / (float)this->bandwidthKhz;
timeoutInternal = (RadioLibTime_t)(symbolLength * 100.0f);
} else if(modem == RADIOLIB_SX126X_PACKET_TYPE_GFSK) {
// calculate timeout (500 % of expected time-one-air)
size_t maxLen = len;
if(len == 0) { maxLen = 0xFF; }
float brBps = (RADIOLIB_SX126X_CRYSTAL_FREQ * 1000000.0f * 32.0f) / (float)this->bitRate;
timeoutInternal = (RadioLibTime_t)(((maxLen * 8.0f) / brBps) * 1000.0f * 5.0f);
} else {
return(RADIOLIB_ERR_UNKNOWN);
}
// calculate timeout (500 % of expected time-one-air)
size_t maxLen = len;
if(len == 0) { maxLen = RADIOLIB_SX126X_MAX_PACKET_LENGTH; }
timeoutInternal = (getTimeOnAir(maxLen) * 5) / 1000;
}
RADIOLIB_DEBUG_BASIC_PRINTLN("Timeout in %lu ms", timeoutInternal);