Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions client_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 10 additions & 6 deletions client_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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{{
Expand Down
6 changes: 6 additions & 0 deletions wifi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading