Files
RedBear-OS/local
vasilito b6ac916a2c wifictl dbus_nm: correct wire types — NmState 0..70 + OwnedObjectPath
The redbear-wifictl NM-shaped D-Bus interface returned wire-incompatible
types that no compliant client (Qt, GNOME, kf6-networkmanager-qt) could
parse:

1. Root State returned a NmDeviceState value (up to 120 = Failed),
   but Qt's qnetworkmanagerservice.h:65-74 defines NmState as
   0..=70 (Unknown..ConnectedGlobal). Returning a device-state value
   in the manager-state property is wire-incompatible.

2. get_devices() and get_access_points() returned Vec<String>, but
   the D-Bus spec requires Vec<o> (array of object paths). zbus
   serializes Vec<String> as 'as' which clients reject.

3. active_access_point returned String, should be o. The sentinel
   '/' for 'no active AP' is a valid object path per spec.

Fixes:

- Add new NmState enum with the correct 8 variants (Unknown=0,
  Asleep=10, Disconnected=20, Disconnecting=30, Connecting=40,
  ConnectedLocal=50, ConnectedSite=60, ConnectedGlobal=70).
- Add NmState::from_device_state(NmDeviceState) mapping table:
  Unmanaged/Unavailable/Disconnected/Failed -> Disconnected;
  Prepare/Config/NeedAuth/IpConfig/IpCheck -> Connecting;
  Activated -> ConnectedGlobal; Unknown -> Unknown.
- Root state property now returns NmState::from_device_state(
  device.state).as_u32(), guaranteed 0..=70.
- get_devices(), get_all_devices(), active_connections (property),
  get_access_points(), get_all_access_points() all return
  Vec<OwnedObjectPath> via a shared try_path() helper that maps
  malformed strings to fdo::Error::Failed instead of panicking.
- active_access_point() property returns fdo::Result<OwnedObjectPath>;
  uses '/' sentinel when no AP is active.
- 5 new host tests verify NmState numeric values (the Qt-required
  0/10/20/.../70 sequence), from_device_state mapping, and the
  'range never exceeds 70' invariant.

Verified: 35 unit + 2 integration tests pass.
2026-07-27 22:20:04 +09:00
..