Bluetooth trainer: local address not refreshed after Init (color LCD)

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

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

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

Research direction

The bug is in radio/src/gui/colorlcd/model/trainer_bluetooth.cpp: the local-address StaticText is created once in the window constructor, while BluetoothTrainerWindow::refresh() updates only state, r_addr and btn. Read radio/src/gui/colorlcd/radio/hw_bluetooth.cpp to see how the address is read dynamically. Done when the Local address field fills in right after Init without leaving and re-entering the screen, which needs a hardware or simulator check.

Written by the indexing model from the issue text.

Description

Summary

In the model Trainer screen (Bluetooth, master), the Local address field stays empty after pressing Init and only appears after leaving and re-entering the screen. The address itself is received and stored correctly (the Hardware -> Bluetooth screen shows it), so this is a display refresh issue.

Steps to reproduce
  1. Model Settings -> Trainer, Bluetooth trainer, master.
  2. Press Init (the BT handshake runs; discovery becomes available).
  3. Scan, select a device and connect.
  4. Observe the "Local address" field.
Actual result

The "Local address" field stays empty during the whole session. Leaving the screen and re-entering it makes the address appear.

Expected result

The local address should be shown as soon as it is known (right after the handshake).

Root cause

In radio/src/gui/colorlcd/model/trainer_bluetooth.cpp, the local-address StaticText is created once, anonymously, with the value of bluetooth.localAddr at window construction:

auto lclline = newLine(grid);
new StaticText(lclline, rect_t{}, STR_BLUETOOTH_LOCAL_ADDR);
new StaticText(lclline, rect_t{}, bluetooth.localAddr);   // created once, never updated

BluetoothTrainerWindow::refresh() updates state, r_addr and btn, but never the local-address text. Since the BT handshake starts when Init is pressed (i.e. after the window is built), bluetooth.localAddr is still empty at construction, so the field remains empty until the window is recreated.

The Hardware -> Bluetooth screen shows both addresses because it reads bluetooth.localAddr dynamically (radio/src/gui/colorlcd/radio/hw_bluetooth.cpp).

Suggested fix

Keep a pointer to the local-address StaticText as a member and set its text from bluetooth.localAddr in refresh() (or whenever bluetooth.state changes), the same way r_addr is updated.

Environment
  • Radio: Radiomaster TX16S MK3.
  • EdgeTX: current nightly.
  • Module: FrSky Bluetooth module emulator (ESP32-C3), which sends Central:<addr> / Peripheral:<addr> during the handshake (verified in the module logs).
Dominant language
C
Stars
2.4k
Forks
614
Avg merge
2d 14h
Merged PRs (30d)
68

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.