Skip to content

feat(cellular): expose signal strength and conn type - #3533

Merged
bbedward merged 1 commit into
duxlabs-dev:masterfrom
marcusramberg:marcus/cellstrength
Sep 25, 2026
Merged

bbedward merged 1 commit into
duxlabs-dev:masterfrom
marcusramberg:marcus/cellstrength

Conversation

@marcusramberg

@marcusramberg marcusramberg commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

network manager doesn't expose this so talk to modem manager over dbus

Description

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Refactor / internal cleanup
  • Documentation
  • Other

Related issues

Screenshots / video

Checklist

@hthienloc

Copy link
Copy Markdown
Member

/claude review


b.updateAllCellularDevices()
if b.onStateChange != nil {
b.onStateChange()

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.

Signal-quality updates never reach the shell. onStateChange funnels into Manager.onBackendStateChange → notifySubscribers, and the broadcast loop drops the state unless stateChangedMeaningfully returns true (manager.go:534). That function's cellular-device loop (manager.go:430-445) only compares Name, Connected, State and IP — SignalQuality and AccessTech aren't compared, so a modem-only change is filtered out and subscribers keep the stale values until something unrelated changes.

SignalQuality/AccessTech need to be added to that loop. When you do, gate the signal on a threshold the way WiFi does (signalChangeSignificant, used at manager.go:298) — otherwise every 1% jitter from ModemManager re-broadcasts the whole state to every client, which is exactly the churn the WiFi path avoids.

@claude

claude Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Claude review

Two issues: the new signal data never actually reaches the shell, and the ModemManager probe can auto-start the daemon.

  • Signal-quality-only changes are dropped by stateChangedMeaningfully, so SignalQuality/AccessTech never propagate to subscribers, core/internal/server/network/backend_networkmanager_modem.go:174
  • GetManagedObjects/GetAll called with flag 0 D-Bus-activates ModemManager on hosts where it is installed but not running, core/internal/server/network/backend_networkmanager_modem.go:52

Checked: MM bit masks and port type against the MMModemAccessTechnology/MMModemPortType enums, modemMutex lock ordering and the refreshModem/updateAllCellularDevices path, signal match add/remove symmetry in start/stopSignalPump, and the QML null-safety of activeCellularDevice plus the cellularAvailable swap in SettingsSearchService — no problems in those. Model: claude-opus-5.

@bbedward

Copy link
Copy Markdown
Member

/claude review

@github-actions

Copy link
Copy Markdown
Contributor

@bbedward

Copy link
Copy Markdown
Member

/claude review

@claude

claude Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Claude review

Both earlier findings are fixed. One new issue: with more than one modem, modems are matched to NM devices by the wrong port.

  • The NM device key is the modem control port (cdc-wdm0), not the MM net port (wwan0), so interface matching never succeeds. Match on MM PrimaryPort instead. core/internal/server/network/backend_networkmanager_modem.go:29

Checked: the new stateChangedMeaningfully cellular fields and signalChangeSignificant gating, the FlagNoAutoStart fix, ObjectManager/PropertiesChanged signal routing in handleDBusSignal, match add/remove symmetry, modemMutex vs stateMutex ordering, and QML null-safety of activeCellularDevice/cellularSignalIcon. Model: claude-opus-5-5.

@bbedward

Copy link
Copy Markdown
Member

/claude review

dbusMMModemInterface = "org.freedesktop.ModemManager1.Modem"
dbusObjectManagerInterface = "org.freedesktop.DBus.ObjectManager"

mmPortTypePrimary = 1

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.

MMModemPortType has no "primary" value. 1 is MM_MODEM_PORT_TYPE_UNKNOWN (NET=2, AT=3, QMI=6, MBIM=7). A real modem's primary port is QMI, MBIM or AT, so this check almost never matches and primaryPort stays empty. Matching still only works through the lone-modem fallback, which means the multi-modem problem from the last review is still there. The test passes only because it tags cdc-wdm0 with this same constant.

Fix: read the modem's PrimaryPort string property (props["PrimaryPort"]) instead of scanning Ports by type.

@claude

claude Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Claude review

The port-matching fix is still not right: modems still match only through the lone-modem fallback.

  • mmPortTypePrimary = 1 is MM_MODEM_PORT_TYPE_UNKNOWN, not a primary port type, so primaryPort is almost never set. Read the PrimaryPort property instead. core/internal/server/network/backend_networkmanager_modem.go:13

Checked: MMModemPortType and MMModemAccessTechnology enum values, ObjectManager/PropertiesChanged routing in handleDBusSignal, match add/remove symmetry, FlagNoAutoStart on the startup probe, the stateChangedMeaningfully cellular fields, and QML null-safety of cellularSignalIcon. Model: claude-opus-5-5.

@marcusramberg

Copy link
Copy Markdown
Contributor Author

/claude review

@hthienloc

Copy link
Copy Markdown
Member

/claude review

@marcusramberg

Copy link
Copy Markdown
Contributor Author

ok, I've tested against a real device now, and this is still not right. :-/ update coming in a moment.

}

if sig.Name == dbusObjectManagerInterface+".InterfacesAdded" ||
sig.Name == dbusObjectManagerInterface+".InterfacesRemoved" {

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.

This branch reacts to every ObjectManager signal on the system bus, not only ModemManager's. dbus.SystemBus() is a shared connection, and godbus sends every matched signal to every registered channel. The bluez manager adds bus-wide InterfacesAdded/InterfacesRemoved rules (bluez/manager.go:26-27) with no path or sender filter. So during a Bluetooth scan, each discovered device sends a synchronous GetManagedObjects to MM, re-reads every cellular device's NM properties, and calls onStateChange. UDisks, NM and iwd ObjectManager signals do the same.

Fix: filter on the MM path.

Suggested change
sig.Name == dbusObjectManagerInterface+".InterfacesRemoved" {
if sig.Path == dbus.ObjectPath(dbusMMPath) &&
(sig.Name == dbusObjectManagerInterface+".InterfacesAdded" ||
sig.Name == dbusObjectManagerInterface+".InterfacesRemoved") {

@claude

claude Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Claude review

One new issue: the ModemManager objects handler reacts to ObjectManager signals from every service on the bus, not just ModemManager. The earlier multi-modem comment still applies: netPort (wwan0) is compared against NM's control-port Interface (cdc-wdm0), so matching still only works through the lone-modem fallback.

  • InterfacesAdded/Removed from BlueZ, UDisks and others reach this handler through the shared system bus, so every signal triggers a MM GetManagedObjects call, a cellular refresh and a state broadcast. Filter on sig.Path. core/internal/server/network/backend_networkmanager_signals.go:342

Checked: signal routing in handleDBusSignal against the bluez/iwd match rules on the shared bus, match add/remove symmetry, FlagNoAutoStart on the startup probe, modemMutex vs stateMutex ordering, the stateChangedMeaningfully cellular gating, and QML null-safety of cellularSignalIcon. Model: claude-opus-5-5.

network manager doesn't expose this so talk to modem manager over dbus
@marcusramberg

Copy link
Copy Markdown
Contributor Author

re the last bug, I believe existing code for bluez also suffers from that and should be filtered, but I think that should be a separate PR from this. Happy to open a separate PR for that?

@bbedward

Copy link
Copy Markdown
Member

re the last bug, I believe existing code for bluez also suffers from that and should be filtered, but I think that should be a separate PR from this. Happy to open a separate PR for that?

Yea we should do that (I'll make an issue so I dont forget)

@bbedward

Copy link
Copy Markdown
Member

/claude review

@claude

claude Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Claude review

No issues found. The earlier findings are fixed: matching now uses PrimaryPort, the startup probe passes FlagNoAutoStart, ObjectManager signals are filtered to the ModemManager path, and stateChangedMeaningfully gates on signal changes.

Checked: PrimaryPort matching and the lone-modem fallback, add/remove symmetry for the ModemManager match rules, the ordering of the initial refresh in startSignalPump, lock usage between modemMutex and the cellular device snapshot, the signalChangeSignificant threshold on cellular signal, and null-safety of cellularSignalIcon in QML. Model: claude-opus-5-5.

@bbedward
bbedward merged commit 8da739a into duxlabs-dev:master Sep 25, 2026
4 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.

3 participants