Skip to content

A golang library for detect when wifi changed(connected or disconnected or ssid changed)

License

Notifications You must be signed in to change notification settings

stenya/wifiNotifier

 
 

Repository files navigation

wifiNotifier

Detect when WiFi changed (connected or disconnected or ssid changed), support Windows, Mac OS, Linux.
Additional functionality:

  • get current WiFi SSID
  • scan for a WiFi networks
  • get current network security (checking if the current network is insecure)

Note: Some functionality requires privileged user rights.

Examples:

package main

import (
	"fmt"
	"time"

	"github.com/stenya/wifiNotifier"
)

func main() {

	fmt.Println("* available networks:")
	fmt.Println(wifiNotifier.GetAvailableSSIDs())

	fmt.Printf("* current ssid: %v\n", wifiNotifier.GetCurrentSSID())
	fmt.Printf("* current WiFi security: %v\n", wifiNotifier.GetCurrentNetworkSecurity())

	wifiNotifier.SetWifiNotifier(func(ssid string) {
		fmt.Printf("* onWifiChanged. Current ssid: %v (security %v)\n", ssid, wifiNotifier.GetCurrentNetworkSecurity())
	})

	for {
		time.Sleep(time.Second)
	}
}

About

A golang library for detect when wifi changed(connected or disconnected or ssid changed)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 54.9%
  • C 45.1%