Skip to content

Conversation

@CapnBry
Copy link
Member

@CapnBry CapnBry commented May 31, 2025

Moves the storage of the RX's Initial Rate (the packet rate it boots starting from) to during the connect process instead of the disconnect process.

It is inconvenient that the RX only stores the packet rate it expects a connection on when it disconnects. For most users, the TX starts on, they plug in an RX and wait for it to connect, fly, then unplug the RX before it ever experiences a disconnect. This does not update the initrate and they have to wait on the next battery to cycle through the rates again to find it. This PR saves the initrate as soon as the first matching SYNC packet comes in, rather than waiting for a disconnect. This is in line with what the user expects to happen, rather than knowing that "ExpressLRS does it weird, you have to turn off the TX now to 'lock' the packet rate"

The downside to doing this is the first time the RX gets a connection, the EEPROM write will cause a hiccup in the connection process and a delay in connecting, which is why it was done on disconnect. This hiccup will only occur when the rate changes:

  • When selecting a new rate in the lua
  • When connecting a model that previously had been used at a different rate, but only the first time it connects

The first case above can be reduced by leaving the old code in as well as adding the new line, but the hiccup is so short I don't think it justifies the maintenance burden of duplicating the code.

Log

Req air rate change 9->6
lost conn fc=0 fo=2
Config LoRa New TLMrate 1:64
tentative conn       <--- initial SYNC
lost conn fc=0 fo=0
Config LoRa COMMIT  <--- EEPROM write
tentative conn     <-- needs a second SYNC because the timer is now slightly off
got conn
Timer locked

3.5?!

I'd love to get this in 3.x because 3.x is going to probably hang around for a long time despite 4.0 coming soon and it would be nice to have this confusing behavior gone in the final 3.x version.

@CapnBry
Copy link
Member Author

CapnBry commented May 31, 2025

Had to make this a slightly larger change because I found 2 issues:

  • If the RX started on a different rate, the new initrate would get committed 2 lines before the PowerOnCount was reset, causing a second commit. The PowerOnCount(0) call has been moved to be with the initrate change so they can be combined into one write
  • The PowerOnCount(0) write was removing the extended duration of the rate cycler, which meant that the EEPROM write could consume most of a high rate connect timeout, which would cause the rate to cycle even though the RX knew it wanted to accept a connection at that rate. This is happening even if the InitRate is correct. The duration is now only reduced if the rate actually cycles, not during an EEPROM write.

@pkendall64 pkendall64 merged commit 240a061 into ExpressLRS:3.x.x-maintenance Jun 1, 2025
48 checks passed
@CapnBry CapnBry deleted the immediate-init-rate branch June 3, 2025 12:20
@offer-shmuely
Copy link

Great addition, thanks, we never understood why it take it so long to connect after the param of init-rate was removed in 3.5 (or 3.4?)
Thanks 🙏

frank26080115 pushed a commit to frank26080115/ExpressLRS that referenced this pull request Jul 2, 2025
* Store the RXs initrate during connect, not disconnect

* Prevent double commit on startup at new rate
@BAYCKRC
Copy link

BAYCKRC commented Jul 23, 2025

That's awesome! The little feature I've been longing for has finally been implemented. It's indeed more reasonable than my previous rough approach of storing RATE every time I loop through it. Great job! Thank you all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants