Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Legacy switchWarningState decoded with 3 bits per switch since 2.12 (storage uses 2): impossible switch warnings after update

Open Beginner friendly
#7,901 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@GaboITB is already working on this.

Since Oct 11, 2026.

  • #7902 by @GaboITB — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp, yaml

Research direction

Read r_swtchWarn() in radio/src/storage/yaml/yaml_datastructs_funcs.cpp and the 2-bit accessors in radio/src/datastructs_private.h. Reproduce the issue by loading switchWarningState: AuBuCuDu through YamlTreeWalker/get_modeldata_nodes(), then add a gtest checking getSwitchWarning(0..4). Done when the values are up, up, up, up, none and the regression test passes.

Written by the indexing model from the issue text.

Description

Is there an existing issue for this problem?
  • I have searched the existing issues
What part of EdgeTX is the focus of this bug?

Transmitter firmware

Current Behavior

Since 2.12, ModelData::switchWarning stores 2 bits per switch (getSwitchWarning() / setSwitchWarning() in radio/src/datastructs_private.h), but the YAML reader of the legacy key switchWarningState (r_swtchWarn() in radio/src/storage/yaml/yaml_datastructs_funcs.cpp) still packs 3 bits per switch:

    // 3 bits per switch
    swtchWarn |= (state << (3 * swtch));

Any model file that still contains the legacy string gets wrong switch warnings on its first load in 2.12, and the wrong values are then saved in the new switchWarning: format.

Example on a RadioMaster Pocket: the factory model contains switchWarningState: AuBuCuDu (SA, SB, SC, SD up). r_swtchWarn builds 1 | 1<<3 | 1<<6 | 1<<9 = 585, which read back 2 bits per switch gives SA up, SB mid, SC none, SD up, SE mid. After flashing 2.12.4 the radio asks for SB and SE in the middle. SE is a momentary button on the Pocket, so the warning can never be cleared, and the model is saved as:

switchWarning:
   SA:
      pos: up
   SB:
      pos: mid
   SD:
      pos: up
   SE:
      pos: mid

Confirmed with a gtest built from v2.12.4 (PCB=X7 PCBREV=POCKET), loading the string through YamlTreeWalker / get_modeldata_nodes():

AuBuCuDu read by 2.12: SA=1 SB=2 SC=0 SD=1 SE=2 (0 none, 1 up, 2 mid, 3 down)

v2.10 and v2.11 are consistent (3 bits for both the storage and the legacy reader). The mismatch is present in v2.12.0 to v2.12.4 and on main today.

Expected Behavior

switchWarningState: AuBuCuDu is read as SA, SB, SC, SD up and no check on SE, exactly like in 2.10/2.11.

Steps To Reproduce
  1. Put a model file containing switchWarningState: AuBuCuDu on the SD card (for example the factory models of a RadioMaster Pocket, or any model never re-saved since the legacy format).
  2. Flash 2.12.x and start the radio on that model.
  3. The switch warning asks for SB and SE in the middle instead of SA, SB, SC, SD up.
Version

2.12.4 (also 2.12.0 to 2.12.3 and main)

Transmitter

RadioMaster Pocket

Anything else?

Suggested fix, packing the legacy string with the same width as the storage:

    // 2 bits per switch, same as ModelData::switchWarning
    swtchWarn |= ((swarnstate_t)state << (2 * swtch));

(The cast also avoids an int shift overflow on radios with many switches.) A gtest loading switchWarningState: AuBuCuDu and checking getSwitchWarning(0..4) = up, up, up, up, none would cover it. I can open a PR if that helps.

Found while building an installer for Pocket owners that rewrites the legacy string in the native format before the first 2.12 boot: https://github.com/GaboITB/PocketUFDS

Dominant language
C
Stars
2.4k
Forks
614
Avg merge
2d 14h
Merged PRs (30d)
75

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from EdgeTX/edgetx

All issues in EdgeTX/edgetx

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.