Skip to content

Add MSP functions to get/set binding information - #3554

Merged
CapnBry merged 16 commits into
ExpressLRS:masterfrom
CapnBry:msp-bindphrase
Apr 15, 2026
Merged

CapnBry merged 16 commits into
ExpressLRS:masterfrom
CapnBry:msp-bindphrase

Conversation

@CapnBry

@CapnBry CapnBry commented Feb 23, 2026 •

Copy link
Copy Markdown
Member

Extends support for our own MSP_ELRS_RXTX_CONFIG (formerly named MSP_SET_RX_CONFIG) MSP messages to support get/set the UID and set the UID by binding phrase. This allows lua scripts or engineering QA to programmatically set / clear the binding information without going through the binding process. Both receiver and transmitter support this message, and setting it to blank will clear binding info.

To reviewers: Sorry about all the code reorg 🙂‍↕️I spent an hour writing this and then 3 days trying to make the dependencies not be circular. Details below.

Limitation

The MSP message has to fit in one packet so bind phrases need to be less than 52 characters.

Lua test

elrs-phrase.zip

screen-2000-01-01-035345

A little EdgeTX lvgl demo tool script for being able to test this function. I would unalive myself if I had to enter my bind phrase on a B&W screen, but the function works on B&W radios too if someone wants to manage their bind phrase with a scroll wheel like they just got the high score on Space Invaders.

Set which device you want to change the phrase on, hit Set. You can also get the current UID with the Refresh button.

Code reorg

We have a bit of a problem with how much our libraries depend on each other and the main codebase, which is sort of the opposite of how libraries work. I got into a circular dependency where this new code (shared between RX and TX) relied on config-> OTA -> Handset -> CrsfProtocol -> back to this code, all of which tried to bring in common and device. I've moved some things from common.cpp and Handset into OTA, which allows OTA to be a true library, only needing FIFO and CRC, both of which are also true libraries. This broke the loop and I think these are all OTA things anyway?

  • UID and the 2 associated yet scattered functions moved to OTA lib
  • linkStatistics moved from CRSFRouter to OTA lib
  • isArmed removed from Handset and merged with RX's isArmed in OTA lib.

@CapnBry
CapnBry marked this pull request as draft February 23, 2026 22:36
@CapnBry

CapnBry commented Feb 24, 2026

Copy link
Copy Markdown
Member Author

Oh Lorde help me, there's no saving ourselves from the layout of this project! 😭

@CapnBry
CapnBry marked this pull request as ready for review April 7, 2026 20:01
@CapnBry

CapnBry commented Apr 7, 2026

Copy link
Copy Markdown
Member Author

Tested with

  • TX16S SX1280 ESP32 TX
  • Nomad LR1121 ESP32 TX
  • EP2 SX1280 ESP8285 RX
  • Bayckrc Dual Band Gemini LR1121 ESP32 RX
  • Bayckrc RR2 LR1121 ESP32C3 RX

@pkendall64 pkendall64 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OMG this is going to cause me a few issues down the line with my LR2021 and Arduino3 PRs!
Still, that's a me problem I guess 😭

Comment thread src/lib/CrsfProtocol/RxTxEndpoint.cpp Resolved
Comment thread src/lib/MSP/msptypes.h Resolved
Comment thread src/lib/MSP/msptypes.h Resolved
Comment thread src/src/dynpower.cpp Resolved
Comment thread src/lib/CONFIG/config.cpp Resolved
Comment thread src/lib/FHSS/FHSS.cpp Resolved
Comment thread src/lib/OTA/OTA.cpp Resolved
Comment thread src/lib/OTA/OTA.cpp Resolved
Comment thread src/lib/tx-crsf/TXModuleEndpoint.cpp Resolved
Comment thread src/lib/tx-crsf/TXModuleEndpoint.cpp Resolved
@CapnBry

CapnBry commented Apr 8, 2026 •

Copy link
Copy Markdown
Member Author

Thanks PK. Let me know if you'd like me to help with getting this over to your branch. There's not many changes at the radio level, with this happening mostly in handset / routing, and the UID members shouldn't be in radio either, but I do understand the wincing. Hope it won't be too much trouble. This was such an easy PR until I went back and tried to merge the RX and TX code. 😣

I've switched them and merged the get/set into one ID for simplicity. I was using the old standard MSP names since we had precedent of using it for the "set MODEL_ID" function over MSP

  • MSP_SET_RX_CONFIG -> MSP_ELRS_RXTX_CONFIG
  • MSP_RX_CONFIG -> MSP_ELRS_RXTX_CONFIG
  • MSP_ELRS_RX_CONFIG -> MSP_ELRS_RXTX_CONFIG_SUBCMD

Does this naming meet your approval? I'm open to anything but the number (45) has to stay the same since I am using the set model_id message we created back in 2.0 or whenever.

EDIT: Updated the lua script in the OP with the updated MSP IDs

@pkendall64

Copy link
Copy Markdown
Collaborator

Let me know if you'd like me to help with getting this over to your branch.

It's the other PRs that are there now that may be affected, but it shouldn't be too bad.

Does this naming meet your approval? I'm open to anything but the number (45) has to stay the same since I am using the set model_id message we created back in 2.0 or whenever.

Looks good 👍

@pkendall64 pkendall64 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now, thanks

@mha1 mha1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Phew, quite the refactor to get this in. Tested on Nomad and SuperP. Not only works as expected but even connects, reconnect,, arms, disarms as it should.

Comment thread src/lib/CrsfProtocol/CRSFRouter.cpp Resolved
@CapnBry

CapnBry commented Apr 14, 2026

Copy link
Copy Markdown
Member Author

Even though this is approved, I'll wait until @pkendall64 merges his 3 part refactors and then I can make sure all the shuffling things around is still good.

@CapnBry
CapnBry merged commit 34a6888 into ExpressLRS:master Apr 15, 2026
26 checks passed
pkendall64 added a commit to pkendall64/ExpressLRS that referenced this pull request Apr 18, 2026
pkendall64 added a commit that referenced this pull request Apr 18, 2026
@poweredjj

Copy link
Copy Markdown

This is something I needed so much!
I'm gonna switch to 4.x.x just for that.

Can you please make a simpler lua script that just sets a preset bindphrase to the receiver?

@OzDruiD

OzDruiD commented Jul 4, 2026 •

Copy link
Copy Markdown

@poweredjj a Lua for the MSP bind phrase you mean?

  • what i dont get is .. you can only use this msp bind method, via a lua if the RX is already bound (to the tx with the lua) right?

  • if thatr happens, you already set a bind phrase to get he RX to bind to your TX (or bound without one).,.. so needing a lua to do something you must have already done to achieve a bind is confusing me? i

  • unless of coruse, your binding them to YOUR tx with WIFI bind or whatever, or 3 power bind with no phrase etc - but your then wanting to use a LUA to CHANGE\SET a bindphrase and give the RX to someone else, use the RX with a different TX with Different (preset) bindphrase?

  • or you want to quickly change your TX bindphrase, to bind to your friends models or other RXs with a diff, but known bindphrase?

@CapnBry

CapnBry commented Jul 4, 2026

Copy link
Copy Markdown
Member Author

OzDruiD is correct, you can not set a bindphrase using this method to a receiver that is not connected because there's no way to send complex data to a receiver that isn't bound.

You're in luck though, we do have a way to set the bindphrase on a receiver that isn't bound: you put the receiver into bind mode, then hit Bind on the TX, which sends the bindphrase to an ubound RX! 🙂

@poweredjj

Copy link
Copy Markdown

@poweredjj a Lua for the MSP bind phrase you mean?

  • what i dont get is .. you can only use this msp bind method, via a lua if the RX is already bound (to the tx with the lua) right?
  • if thatr happens, you already set a bind phrase to get he RX to bind to your TX (or bound without one).,.. so needing a lua to do something you must have already done to achieve a bind is confusing me? i
  • unless of coruse, your binding them to YOUR tx with WIFI bind or whatever, or 3 power bind with no phrase etc - but your then wanting to use a LUA to CHANGE\SET a bindphrase and give the RX to someone else, use the RX with a different TX with Different (preset) bindphrase?
  • or you want to quickly change your TX bindphrase, to bind to your friends models or other RXs with a diff, but known bindphrase?

When I'm flying with another pilot we often switch between our fpv drones (having the same rates, modes, switches, etc.).

So, the setup would look like this:
Radio 1 (my radio): switch_to_radio_2.lua
Radio 2 (my friend's radio): switch_to_radio_1.lua

Each lua script would have a different bindphrase hardcoded, so that one pilot could "pass" his currently bound drone to the other.
This requires having the other radio on hand, which is not a problem in my situation.

@OzDruiD

OzDruiD commented Jul 6, 2026 •

Copy link
Copy Markdown

@poweredjj if you use the latest full unfiied lua scripts and then use the bind_phrase.zip lua - it keeps up 5 previous bind phrases. I used it on saturday and sunday to swtich back and forth between my radios bind phrase and my modify my friends craft. It works great this way, yes its not hardcoded and needs some cosmetic lvgl tuneup - but i think the focus on a community wide tool that can do exactly what you want is great.

Next message I will upload a picture of my actual transmitter screen with example Bindphrases as favourties.
These 'favourite' bind phases are stored in a simple bind-phrase text file on your radio - so yeah, thats easy to update as well if you dont feel like creating it on your radio by "setting" you trasmitter a few times with different bind phrases.

image

So - bascially, you and your firend, so both have this setup, both have each others bind pharse in the fav list (plus 3 others if yuou like), then its just 2 clicks - choose each others bindphrase from the list - click "set" as the default it sets your transmitter. OR if its a (bound) RX .. 3 clicks- change drown down to receiver, click the new bind phrase, click Set
Give it a try.. @CapnBry has updated the inital post with a ZIP file to achieve all this - see these recent updates

ExpressLRS/Lua#10
image
image

@OzDruiD

OzDruiD commented Jul 6, 2026

Copy link
Copy Markdown

20260706_170700.jpg

@poweredjj

poweredjj commented Jul 6, 2026 •

Copy link
Copy Markdown

20260706_170700.jpg

It looks like a working solution (if it supports bw screen radios). I'm gonna test it after updating all my drones to 4.X.X. Thank you!

@OzDruiD

OzDruiD commented Jul 6, 2026

Copy link
Copy Markdown

Ummm

It looks like a working solution (if it supports bw screen radios). I'm gonna test it after updating all my drones to 4.X.X. Thank you!

I dont think LVGL which is used in this is supported yet on B&W radios I am afraid.
Maybe a direct lua will work without all the graphical user inferface for now.

@poweredjj

Copy link
Copy Markdown

Ummm

It looks like a working solution (if it supports bw screen radios). I'm gonna test it after updating all my drones to 4.X.X. Thank you!

I dont think LVGL which is used in this is supported yet on B&W radios I am afraid. Maybe a direct lua will work without all the graphical user inferface for now.

I mean, I need a really simple script in which I can manually put my bindphrase. One for each pilot and that's it. I don't really need any interface to begin with...

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

Labels

enhancement 🪄 New feature or request V4.1 🍑

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants