Skip to content

fix(crsf): send modelID after module reset#5506

Merged
pfeerick merged 1 commit into
EdgeTX:mainfrom
mha1:PR_send_modelID_after_reset
Sep 6, 2024
Merged

fix(crsf): send modelID after module reset#5506
pfeerick merged 1 commit into
EdgeTX:mainfrom
mha1:PR_send_modelID_after_reset

Conversation

@mha1
Copy link
Copy Markdown
Contributor

@mha1 mha1 commented Sep 4, 2024

Problem:

ExpressLRS modules store the RF parameters in a model specific way using the modelID as index. EdgeTX sends the modelID once at first initialization of the module. If after that the module resets for any reason the module starts up and assumes modelID 0 for a lack of better information. This is not only annoying but also dangerous because a receiver will potentially not re-connect after the module comes back to live after the reset as the module is now using the RF parameters stored for the model with the modelID 0.

The effect is demonstrated in the attached video. The module is removed during normal operation with a receiver connected using a model with modelID 7 (100Hz in my case) to simulate a reset. After putting the module back in it starts up but uses modelID 0 RF parameters (250 Hz in my case) which prevents the receiver to re-connect. If you want to try this you can use a less brutal method that also works for internal modules. Prepare two models and set one to modelID 0, the other to modelID e.g. 7. Use the LUA script to set both models to different packet rates. Select the model with modelID 7 and connect to a receiver. Start the LUA Script, put the module into WiFi mode and exit WiFi mode again. Best to observe the LCD screen on an external module.

Reasons for a module resetting might be:

  • power surge
  • internal non-recoverable error
  • after flashing in WiFi mode
  • putting the module in WiFi mode and exiting WiFi mode (LUA script)

Solution:

This PR adds some logic to detect a module coming back to live after a reset and in this case sends the current modelID again to ensure the correct RF parameters are used.

Implementation:

A live ExpressLRS module will send CRSF packets even if no receiver is connected. If no packets are received within 500ms the module is declared not alive. If the module boots up again it'll start sending CRSF frames with a period of far less than 500ms again. The transition from not alive to alive triggers the sending of the modelID. The module receives the modelID and selects the correct RF parameter which allow the receiver to re-connect.

vid.mp4

@mha1
Copy link
Copy Markdown
Contributor Author

mha1 commented Sep 4, 2024

This is an issue in 2.10 (and previous versions) too

@pfeerick
Copy link
Copy Markdown
Member

pfeerick commented Sep 4, 2024

Sounds good to me... I told Raphael a while back there were still some issues with RX_ID (I think he'd just fixed it to at least make it send when you changed the RX_ID, rather than just on module startup) but clearly it got lost amongst all the other things needing working on. Crossfire will benefit from this also, as clearly the RF module can "forget" the active RX_ID...

@pfeerick pfeerick changed the title ELRS/CRSF: send modelID after module reset fix(crsf): send modelID after module reset Sep 5, 2024
@pfeerick pfeerick added bug 🪲 Something isn't working firmware General radio firmware issue, not colorlcd or B&W specific labels Sep 6, 2024
@pfeerick pfeerick modified the milestones: 2.11, 2.10.5 Sep 6, 2024
Copy link
Copy Markdown
Member

@pfeerick pfeerick left a comment

Choose a reason for hiding this comment

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

Seems to be working perfectly with TX16S and RM Ranger Micro - returns to correct RX_ID on exiting wifi mode, resetting after update, re-insertion of module, model switch, etc.

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

Labels

bug 🪲 Something isn't working firmware General radio firmware issue, not colorlcd or B&W specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants