mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-07 08:40:38 +01:00
wifi: update signal quality calculation for new supplicant interface
This commit is contained in:
parent
fb6cde508c
commit
bfbb71b763
2 changed files with 14 additions and 40 deletions
|
|
@ -2140,44 +2140,6 @@ cull_scan_list (NMDeviceWifi *self)
|
|||
removed, total);
|
||||
}
|
||||
|
||||
#define SET_QUALITY_MEMBER(qual_item, lc_member, uc_member) \
|
||||
if (lc_member != -1) { \
|
||||
qual_item.lc_member = lc_member; \
|
||||
qual_item.updated |= IW_QUAL_##uc_member##_UPDATED; \
|
||||
} else { \
|
||||
qual_item.updated |= IW_QUAL_##uc_member##_INVALID; \
|
||||
}
|
||||
|
||||
static void
|
||||
set_ap_strength_from_properties (NMDeviceWifi *self,
|
||||
NMAccessPoint *ap,
|
||||
GHashTable *properties)
|
||||
{
|
||||
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
||||
int qual, level, noise;
|
||||
struct iw_quality quality;
|
||||
GValue *value;
|
||||
gint8 strength;
|
||||
|
||||
value = (GValue *) g_hash_table_lookup (properties, "quality");
|
||||
qual = value ? g_value_get_int (value) : -1;
|
||||
|
||||
value = (GValue *) g_hash_table_lookup (properties, "level");
|
||||
level = value ? g_value_get_int (value) : -1;
|
||||
|
||||
value = (GValue *) g_hash_table_lookup (properties, "noise");
|
||||
noise = value ? g_value_get_int (value) : -1;
|
||||
|
||||
/* Calculate and set the AP's signal quality */
|
||||
memset (&quality, 0, sizeof (struct iw_quality));
|
||||
SET_QUALITY_MEMBER (quality, qual, QUAL);
|
||||
SET_QUALITY_MEMBER (quality, level, LEVEL);
|
||||
SET_QUALITY_MEMBER (quality, noise, NOISE);
|
||||
|
||||
strength = wireless_qual_to_percent (&quality, &priv->max_qual);
|
||||
nm_ap_set_strength (ap, strength);
|
||||
}
|
||||
|
||||
static void
|
||||
supplicant_iface_new_bss_cb (NMSupplicantInterface *iface,
|
||||
GHashTable *properties,
|
||||
|
|
@ -2197,8 +2159,6 @@ supplicant_iface_new_bss_cb (NMSupplicantInterface *iface,
|
|||
|
||||
ap = nm_ap_new_from_properties (properties);
|
||||
if (ap) {
|
||||
set_ap_strength_from_properties (self, ap, properties);
|
||||
|
||||
nm_ap_print_self (ap, "AP: ");
|
||||
|
||||
/* Add the AP to the device's AP list */
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include "wireless-helper.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "nm-wifi-ap.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
|
@ -495,6 +496,19 @@ foreach_property_cb (gpointer key, gpointer value, gpointer user_data)
|
|||
|
||||
if (!strcmp (key, "Frequency"))
|
||||
nm_ap_set_freq (ap, val);
|
||||
} else if (G_VALUE_HOLDS_INT (variant)) {
|
||||
gint val = g_value_get_int (variant);
|
||||
|
||||
if (!strcmp (key, "Signal")) {
|
||||
if (val < 0) {
|
||||
/* Rough conversion: best = -40, worst = -100 */
|
||||
val = abs (CLAMP (val, -100, -40) + 40);
|
||||
val = 100 - (int) ((100.0 * (double) val) / 60.0);
|
||||
} else
|
||||
val /= 100;
|
||||
|
||||
nm_ap_set_strength (ap, val);
|
||||
}
|
||||
} else if (G_VALUE_HOLDS_STRING (variant)) {
|
||||
const char *val = g_value_get_string (variant);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue