Skip to content

rework WiFiRSSIMonitor to WiFiMonitor - #145

Merged
henkwiedig merged 3 commits into
OpenIPC:masterfrom
henkwiedig:apfpv-wifi-temp
Aug 6, 2026
Merged

rework WiFiRSSIMonitor to WiFiMonitor#145
henkwiedig merged 3 commits into
OpenIPC:masterfrom
henkwiedig:apfpv-wifi-temp

Conversation

@henkwiedig

Copy link
Copy Markdown
Collaborator

For APFPV mode this PR will:

  • add support for more WiFicards RSSI signal
  • add temperature readings for those cards as well

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Replace WiFiRSSIMonitor with WiFiMonitor (multi-driver RSSI + RF temperature)

✨ Enhancement 🐞 Bug fix 📝 Documentation ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Replace APFPV WiFi RSSI polling with a multi-Realtek-driver /proc scanner using stable adapter
 indices.
• Publish per-adapter RSSI and optional RF-path temperatures as os_mon.wifi.* facts (APFPV only).
• Fix tag-matching iterator bug and add %d placeholder support for templated text widgets.
Diagram

graph TD
  A["main.cpp APFPV loop"] --> B["WiFiMonitor"] --> C[("/proc/net/rtl*/<iface>")]
  B --> D["OSD fact bus"] --> E["OSD widgets (config_osd.json)"]
  F["GS menu mode toggle"] --> G["wifi_monitor_reset()"] --> D
  subgraph Legend
    direction LR
    _mod["Module/Component"] ~~~ _fs[("Procfs / kernel")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use nl80211/netlink for signal + temperature
  • ➕ More driver-agnostic than Realtek procfs layout
  • ➕ Avoids parsing driver-specific debug text files
  • ➖ Higher implementation complexity and testing burden across kernels/cards
  • ➖ Temperature often not available or exposed differently; still needs per-driver handling
2. Persist adapter identity by MAC/PCI/USB path instead of index
  • ➕ Stable widget bindings even when adapters are added/removed
  • ➖ Requires extra discovery logic and storage (and mapping differs by bus type)
  • ➖ More edge cases (renames, hotplug) than simple sorted interface ordering
3. Delegate APFPV WiFi stats to wfb-ng/wfbcli even in APFPV
  • ➕ Single source of truth for link stats across modes
  • ➕ Avoids duplicating parsing/sampling policy
  • ➖ Requires running/maintaining wfb-ng in APFPV mode, which this PR explicitly avoids
  • ➖ Adds runtime dependencies/process management overhead

Recommendation: The procfs-scanning approach is appropriate for the stated goal (APFPV-only Realtek cards) and keeps runtime dependencies minimal. If adapter-index churn becomes a practical issue, consider a follow-up to expose a stable hardware-id tag (MAC or USB path) alongside adapter, without replacing the current adapter indexing.

Files changed (10) +561 / -12

Enhancement (3) +388 / -2
WiFiMonitor.cppImplement multi-driver WiFi monitor with RSSI + thermal sampling +300/-0

Implement multi-driver WiFi monitor with RSSI + thermal sampling

• Introduces WiFiMonitor that scans /proc/net/rtl*/<iface>/ directories, parses trx_info_debug for RSSI/link state, and optionally parses thermal_state for per-RF-path temperatures. Publishes facts in batches with interface+adapter tags and provides a reset publisher via wifi_monitor_reset().

src/WiFiMonitor.cpp

WiFiMonitor.hppAdd WiFiMonitor interface and tagging/sampling policy docs +86/-0

Add WiFiMonitor interface and tagging/sampling policy docs

• Defines the WiFiMonitor class, data structures, and helper methods. Documents adapter indexing, tag layout, supported procfs locations, and slower thermal sampling interval.

src/WiFiMonitor.hpp

main.cppInstantiate and run WiFiMonitor in APFPV loop +2/-2

Instantiate and run WiFiMonitor in APFPV loop

• Replaces WiFiRSSIMonitor with WiFiMonitor and continues calling run() once per second only in APFPV mode.

src/main.cpp

Bug fix (1) +7 / -2
osd.cppFix FactMatcher tag lookup and add %d template token support +7/-2

Fix FactMatcher tag lookup and add %d template token support

• Fixes a tag-matching bug where the iterator returned by fact_tags.find() was compared against the wrong container end(), preventing correct mismatches and risking invalid dereference. Extends template tokenization to recognize %d placeholders (aliasing %i handling).

src/osd.cpp

Refactor (2) +3 / -3
WiFiMonitor.hRename C reset API to wifi_monitor_reset() +1/-1

Rename C reset API to wifi_monitor_reset()

• Replaces the old wifi_rssi_monitor_reset symbol with wifi_monitor_reset for the new monitor implementation.

src/WiFiMonitor.h

helper.cSwitch menu reset call to wifi_monitor_reset() +2/-2

Switch menu reset call to wifi_monitor_reset()

• Updates includes and RX-mode toggle reset call to use the renamed WiFi monitor reset API.

src/gsmenu/helper.c

Documentation (2) +20 / -3
README.mdDocument new os_mon.wifi.* facts and font limitations +19/-2

Document new os_mon.wifi.* facts and font limitations

• Updates fact table types (RSSI int) and adds documentation for os_mon.wifi.rssi / os_mon.wifi.temperature tagging semantics in APFPV mode. Also clarifies LVGL font coverage and correct degree sign usage.

README.md

colmenu_pages.cUpdate APFPV comment to reference WiFiMonitor +1/-1

Update APFPV comment to reference WiFiMonitor

• Adjusts RX-mode toggle comment to reflect the new WiFiMonitor as the APFPV source of os_mon.wifi.* facts.

src/gsmenu/colmenu_pages.c

Other (2) +143 / -2
CMakeLists.txtSwap WiFiRSSIMonitor sources for WiFiMonitor +2/-2

Swap WiFiRSSIMonitor sources for WiFiMonitor

• Updates the build source list to compile/link the new WiFiMonitor implementation instead of the removed WiFiRSSIMonitor files.

CMakeLists.txt

config_osd.jsonAdd APFPV widgets for per-adapter RSSI and RF temperatures +141/-0

Add APFPV widgets for per-adapter RSSI and RF temperatures

• Adds a parallel set of IconSelectorWidget RSSI indicators fed by os_mon.wifi.rssi (adapter/type) for multiple adapters/antennas. Adds text widgets to display RF-path temperatures via os_mon.wifi.temperature (adapter/rf_path).

config_osd.json

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Aug 2, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Stale WiFi facts persist ✓ Resolved 🐞 Bug ☼ Reliability
Description
WiFiMonitor::run() returns when no rtl* interfaces are found, but does not clear previously
published os_mon.wifi.* facts, so widgets can keep rendering the last RSSI/temperature after
adapters are unplugged or driver proc entries disappear. This can mislead the operator because facts
are only updated/cleared when explicitly flushed, not automatically retracted when a publisher stops
emitting them.
Code

src/WiFiMonitor.cpp[R79-82]

+            spdlog::error("No Realtek WiFi driver found below {}, no wifi stats will be published", base_path_);
+            warned_no_driver_ = true;
+        }
+        return;
Evidence
WiFiMonitor returns without publishing or flushing when no interfaces exist, while the OSD keeps
previously set widget facts until an explicit flush clears them; since wifi_monitor.run() is called
periodically, this can happen after adapters disappear at runtime.

src/WiFiMonitor.cpp[74-85]
src/main.cpp[1069-1077]
src/osd.cpp[2780-2804]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`WiFiMonitor::run()` returns early when `find_interfaces()` yields no interfaces. In that path, no new facts are published and no existing facts are cleared, leaving OSD widgets bound to `os_mon.wifi.*` with stale last-known values.
### Issue Context
The OSD fact processor only updates widgets when a matching fact is published (`Osd::setFact`) and clears facts only when `osd_flush_facts()` requests a prefix flush (`Osd::flushFacts`). If WiFiMonitor stops publishing, previously set widget facts remain defined.
### Fix (recommended)
- When interfaces become empty (or when the interface set changes), call `osd_flush_facts()` for prefix `"os_mon.wifi."` so removed adapters/interfaces drop to undefined and widgets hide.
- Optionally, track the last seen interface list and flush only when it changes to avoid unnecessary work.
### Fix Focus Areas
- src/WiFiMonitor.cpp[74-119]
- src/osd.cpp[2780-2810]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

Comment thread src/WiFiMonitor.cpp
@henkwiedig

Copy link
Copy Markdown
Collaborator Author

fixes #106

@henkwiedig
henkwiedig merged commit bcd5f8b into OpenIPC:master Aug 6, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant