Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

brlbil/wpaclient

Open more actions menu

Repository files navigation

wpaclient Travis-CI GoDoc Go Report Card

Package wpaclient provides a high level wap_supplicant client.

Install

go get github.com/brlbil/wpaclient

Usage

Execute

Client can execute commands, all of the available commands are exported.

// Initialize n new client
client, err := New("wlan0")
if err != nil {
    return err
}
// Close connection
defer client.Close()

// Execute a command, all commands are exported
buf, err := client.Execute(CmdPing)

fmt.Println(buf)
$ PONG

Scan access-points

Scan is a helper function for SCAN and SCAN_RESULTS commands.

aps, err := client.Scan()

for _, ap := range aps {
    fmt.Printf("ssid: %s mac: %s freq: %d signal strength: %d\n",
    ap.SSID, ap.BSSID, ap.Frequency, ap.SignalStrength)
}

List networks

List is a helper function for LIST_NETWORKS command.

nets, err := client.Networks()

for _, nt := range nets {
    fmt.Printf("id: %d, ssid: %s\n", nt.ID, nt.SSID)
}

Get event notifications

Client get event notification by opening a second socket connection.

// Get all events
ch, err := client.Notify()

// Just get connection and disconnection events.
ch, err := client.Notify(WpaEventConnected, WpaEventDisconnected)

ev := <- ch

Credits

License

The MIT License (MIT) - see LICENSE.md for more details

About

Client library for wpa_supplicant

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.