Skip to content

AP Scanning #4

@betim

Description

@betim

I'm trying to get WiFi scanning going something like iwlist scan but for some reason this small program:

package main

import (
	"fmt"
	"log"

	"github.com/mdlayher/wifi"
)

func main() {
	// Initialize a new WiFi client
	client, err := wifi.New()
	if err != nil {
		log.Fatalf("failed to create WiFi client: %v", err)
	}
	defer client.Close()

	// Get a list of WiFi interfaces
	ifaces, err := client.Interfaces()
	if err != nil {
		log.Fatalf("failed to get WiFi interfaces: %v", err)
	}

	// Scan for access points on each interface
	for _, iface := range ifaces {
		fmt.Printf("Scanning on interface: %s\n", iface.Name)

		surveyInfo, err := client.SurveyInfo(iface)
		if err != nil {
			log.Fatalf("failed to scan on interface %s: %v", iface.Name, err)
		}

		for _, si := range surveyInfo {
			fmt.Printf("%#v\n", si)
		}
	}
}

is returning

/perm # ./agent
Scanning on interface: wlan0
2025/03/23 01:02:00 failed to scan on interface wlan0: netlink receive: device or resource busy

Given that gokrazy is barebones, there's little room for getting to the bottom of this unless you know the internals of everything. Any idea why is this happening or how to accomplish this?

Long time fan of the project :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions