Update preamble dynamically to match runtime SF changes via CLI

This commit is contained in:
overkillfpv
2026-03-05 22:14:22 +11:00
parent 534a0c97a7
commit a61add2e6a
9 changed files with 12 additions and 2 deletions

View File

@@ -26,7 +26,7 @@ void setFlag(void) {
void RadioLibWrapper::begin() {
_radio->setPacketReceivedAction(setFlag); // this is also SentComplete interrupt
_radio->setPreambleLength(LORA_SF <= 8 ? 32 : 16); // longer preamble for lower SF improves reliability
_radio->setPreambleLength(getSpreadingFactor() <= 8 ? 32 : 16); // longer preamble for lower SF improves reliability
state = STATE_IDLE;
if (_board->getStartupReason() == BD_STARTUP_RX_PACKET) { // received a LoRa packet (while in deep sleep)
@@ -143,6 +143,7 @@ uint32_t RadioLibWrapper::getEstAirtimeFor(int len_bytes) {
bool RadioLibWrapper::startSendRaw(const uint8_t* bytes, int len) {
_board->onBeforeTransmit();
_radio->setPreambleLength(getSpreadingFactor() <= 8 ? 32 : 16); // keep preamble in sync with current SF
int err = _radio->startTransmit((uint8_t *) bytes, len);
if (err == RADIOLIB_ERR_NONE) {
state = STATE_TX_WAIT;