diff --git a/client_linux.go b/client_linux.go index 57378d3..44a5bc4 100644 --- a/client_linux.go +++ b/client_linux.go @@ -636,6 +636,12 @@ func (b *BSS) parseAttributes(attrs []netlink.Attribute) error { // NOTE: BSSStatus copies the ordering of nl80211's BSS status // constants. This may not be the case on other operating systems. b.Status = BSSStatus(nlenc.Uint32(a.Data)) + case unix.NL80211_BSS_SIGNAL_MBM: + // * @NL80211_BSS_SIGNAL_MBM: signal strength in mBm (100*dBm) + b.Signal = nlenc.Int32(a.Data) + case unix.NL80211_BSS_SIGNAL_UNSPEC: + // * @NL80211_BSS_SIGNAL_UNSPEC: signal strength in unspecified units (usually percent) + b.SignalUnspecified = nlenc.Uint32(a.Data) case unix.NL80211_BSS_INFORMATION_ELEMENTS: ies, err := parseIEs(a.Data) if err != nil { diff --git a/client_linux_test.go b/client_linux_test.go index 6e6dea3..77b3ad2 100644 --- a/client_linux_test.go +++ b/client_linux_test.go @@ -181,12 +181,14 @@ func TestLinux_clientBSSOKSkipMissingStatus(t *testing.T) { func TestLinux_clientBSSOK(t *testing.T) { want := &BSS{ - SSID: "Hello, 世界", - BSSID: net.HardwareAddr{0x00, 0x11, 0x22, 0x33, 0x44, 0x55}, - Frequency: 2492, - BeaconInterval: 100 * 1024 * time.Microsecond, - LastSeen: 10 * time.Second, - Status: BSSStatusAssociated, + SSID: "Hello, 世界", + BSSID: net.HardwareAddr{0x00, 0x11, 0x22, 0x33, 0x44, 0x55}, + Frequency: 2492, + BeaconInterval: 100 * 1024 * time.Microsecond, + LastSeen: 10 * time.Second, + Status: BSSStatusAssociated, + Signal: -5700, + SignalUnspecified: 80, } ifi := &Interface{ @@ -471,6 +473,8 @@ func (b *BSS) attributes() []netlink.Attribute { {Type: unix.NL80211_BSS_BEACON_INTERVAL, Data: nlenc.Uint16Bytes(uint16(b.BeaconInterval / 1024 / time.Microsecond))}, {Type: unix.NL80211_BSS_SEEN_MS_AGO, Data: nlenc.Uint32Bytes(uint32(b.LastSeen / time.Millisecond))}, {Type: unix.NL80211_BSS_STATUS, Data: nlenc.Uint32Bytes(uint32(b.Status))}, + {Type: unix.NL80211_BSS_SIGNAL_MBM, Data: nlenc.Int32Bytes(int32(b.Signal))}, + {Type: unix.NL80211_BSS_SIGNAL_UNSPEC, Data: nlenc.Uint32Bytes(uint32(b.SignalUnspecified))}, { Type: unix.NL80211_BSS_INFORMATION_ELEMENTS, Data: marshalIEs([]ie{{ diff --git a/wifi.go b/wifi.go index 0d472d8..f2f5390 100644 --- a/wifi.go +++ b/wifi.go @@ -247,6 +247,12 @@ type BSS struct { // Status: The status of the client within the BSS. Status BSSStatus + // Signal: The signal strength of the BSS, in mBm (divide by 100 to get dBm). + Signal int32 + + // SignalUnspecified: The signal strength of the BSS, in percent. + SignalUnspecified uint32 + // Load: The load element of the BSS (contains StationCount, ChannelUtilization and AvailableAdmissionCapacity). Load BSSLoad