From 169caa2c162e21c4fee89266b6233c3b0643ad0f Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Thu, 9 Jul 2026 14:45:44 -0700 Subject: [PATCH 1/3] station: Add Utilization/SNR/LastSeen to station diagnostics For metric gathering and general debugging its convenient to query the last known utilization and/or SNR from the currently connected BSS. In addition another property was added, "BssLastSeen" which is the seconds since the last scan returned the BSS. Since the BSS's beacon info (like utilization/SNR) are only updated upon getting scan results we need to also advertise the "age" of the data so any consumers can decide whether or not to ignore these values if they are too old. --- src/station.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/station.c b/src/station.c index 8fcf8c70..05ed043e 100644 --- a/src/station.c +++ b/src/station.c @@ -5337,6 +5337,14 @@ static void station_destroy_interface(void *user_data) station_free(station); } +/* Gets the time in seconds since the BSS was last seen */ +static uint32_t bss_last_seen_time(const struct scan_bss *bss) +{ + uint64_t diff = l_time_diff(bss->time_stamp, l_time_now()); + + return (uint32_t)l_time_to_secs(diff); +} + static void station_get_diagnostic_cb( const struct diagnostic_station_info *info, void *user_data) @@ -5346,6 +5354,7 @@ static void station_get_diagnostic_cb( struct l_dbus_message_builder *builder; struct handshake_state *hs = netdev_get_handshake(station->netdev); uint16_t channel_num; + uint32_t last_seen; if (!info) { reply = dbus_error_aborted(station->get_station_pending); @@ -5388,6 +5397,23 @@ static void station_get_diagnostic_cb( 's', str); } + if (station->connected_bss->have_utilization) { + uint8_t percent = + (station->connected_bss->utilization * 100) / 255; + dbus_append_dict_basic(builder, "ChannelUtilization", 'y', + &percent); + } + + if (station->connected_bss->have_snr) { + uint8_t snr = (uint8_t)station->connected_bss->snr; + dbus_append_dict_basic(builder, "SignalNoiseRatio", 'y', &snr); + } + + last_seen = bss_last_seen_time(station->connected_bss); + + dbus_append_dict_basic(builder, "BssLastSeen", 'u', + &last_seen); + diagnostic_info_to_dict(info, builder); l_dbus_message_builder_leave_array(builder); From 43dff52760e3ff3aacf6640c260f47d80cc59d99 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Thu, 9 Jul 2026 14:45:45 -0700 Subject: [PATCH 2/3] client: support ChannelUtilization/SignalNoiseRatio/BssLastSeen Add support for these new diagnostic values in iwctl --- client/diagnostic.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/diagnostic.c b/client/diagnostic.c index 2be8b724..6bce1671 100644 --- a/client/diagnostic.c +++ b/client/diagnostic.c @@ -97,6 +97,9 @@ static const struct diagnostic_dict_mapping diagnostic_mapping[] = { { "Security", 's' }, { "InactiveTime", 'u', "ms" }, { "ConnectedTime", 'u', "s" }, + { "ChannelUtilization", 'y', "%" }, + { "SignalNoiseRatio", 'y', "dBm" }, + { "BssLastSeen", 'u', "s" }, { NULL } }; From 58b465605380532006e1b4a21441d1a36cd771f2 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Thu, 9 Jul 2026 14:45:46 -0700 Subject: [PATCH 3/3] doc: Document new station diagnostic values. (BssLastSeen, ChannelUtilization, and SignalNoiseRatio) --- doc/station-diagnostic-api.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doc/station-diagnostic-api.txt b/doc/station-diagnostic-api.txt index 9b51d4b7..a946682e 100644 --- a/doc/station-diagnostic-api.txt +++ b/doc/station-diagnostic-api.txt @@ -27,6 +27,9 @@ Methods dict GetDiagnostics() Security - The chosen security for the connection. + BssLastSeen - The time in seconds since the BSS was seen + in a scan. + RSSI [optional] - The RSSI of the currently connected BSS. AverageRSSI [optional] - Average RSSI of currently connected BSS. @@ -59,6 +62,19 @@ Methods dict GetDiagnostics() ConnectedTime [optional] - Time Duration (in s) for which this STA remains connected to the BSS. + ChannelUtilization [optional] - The channel utilization + advertised by the BSS load element in scans. + Note the confidence of this value heavily + depends on the BssLastSeen time as this only + updates when IWD scans. + + SignalNoiseRatio [optional] - The signal to noise ratio + (SNR) received on the last scan. + Note the confidence of this value heavily + depends on the BssLastSeen time as this only + updates when IWD scans. + + Possible errors: net.connman.iwd.Busy net.connman.iwd.Failed net.connman.iwd.NotConnected