netmanagerclient

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2024 License: GPL-3.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DbusInterface = "org.cacophony.RPiNetManager"
	DbusPath      = "/org/cacophony/RPiNetManager"
)

Variables

View Source
var (
	ErrNetworkAlreadyExists = InputError{Message: "a network with the given SSID already exists"}
	ErrPSKTooShort          = InputError{Message: "the given PSK is too short, must be at least 8 characters long"}
	ErrBushnetNetwork       = InputError{Message: "the given SSID is a Bushnet network so can't be modified"}
)

Functions

func AddWifiNetwork

func AddWifiNetwork(ssid, psk string) error

func CheckIfNetworkExists added in v0.5.1

func CheckIfNetworkExists(id string) (bool, error)

func CheckState added in v0.1.2

func CheckState() error

func ConnectWifiNetwork added in v0.5.0

func ConnectWifiNetwork(ssid string) error

Connects to an existing network

func DisconnectWifiNetwork added in v0.5.0

func DisconnectWifiNetwork(ssid string, startHotspot bool) error

func EnableHotspot

func EnableHotspot(force bool) error

EnableHotspot will enable the hotspot. If the hotspot is already enabled it will return unless force is true, then it will start up the hotspot again.

func EnableWifi

func EnableWifi(force bool) error

EnableWifi will enable the wifi. The force parameter doesn't do anything at the moment.

func GetStateChanges

func GetStateChanges() (chan NetworkState, chan<- struct{}, error)

GetStateChanges will start listening for state changes.

func KeepHotspotOnFor

func KeepHotspotOnFor(seconds int) error

func ModifyNetworkConfig added in v0.5.1

func ModifyNetworkConfig(id string, c map[string]string) error

ModifyNetworkConfig will check if a networks exists, create it if not, then set the given config values to it.

func ModifyWifiNetwork added in v0.5.0

func ModifyWifiNetwork(ssid, psk string) error

func RemoveWifiNetwork

func RemoveWifiNetwork(ssid string, disconnect bool, startHotspot bool) error

Types

type InputError

type InputError struct {
	Message string
}

func (InputError) Error

func (e InputError) Error() string

type NetworkState

type NetworkState string
const (
	NS_INIT             NetworkState = "Init"             // Initial state, before any network state changes
	NS_WIFI_OFF         NetworkState = "WIFI_OFF"         // WIFI Radio is off.
	NS_WIFI_SETUP       NetworkState = "WIFI_SETUP"       // WIFI is being setup.
	NS_WIFI_SCANNING    NetworkState = "WIFI_SCANNING"    // WIFI is scanning for networks to connect to.
	NS_WIFI_CONNECTING  NetworkState = "WIFI_CONNECTING"  // WIFI is trying to connect to a network.
	NS_WIFI_CONNECTED   NetworkState = "WIFI_CONNECTED"   // WIFI has connected to a network.
	NS_HOTSPOT_STARTING NetworkState = "HOTSPOT_STARTING" // Hotspot is being setup.
	NS_HOTSPOT_RUNNING  NetworkState = "HOTSPOT_RUNNING"  // Hotspot is running.
	NS_ERROR            NetworkState = "Error with network"
)

func ReadState

func ReadState() (NetworkState, error)

ReadState will read the current state of the network.

type WiFiNetwork

type WiFiNetwork struct {
	SSID               string
	Quality            string
	ID                 string
	InUse              bool
	AuthFailed         bool
	LastConnectionTime time.Time
}

func FindNetworkBySSID added in v0.5.0

func FindNetworkBySSID(ssid string) (WiFiNetwork, bool)

FindNetworkBySSID searches for a network by SSID in the list of WiFi networks

func ListSavedWifiNetworks

func ListSavedWifiNetworks() ([]WiFiNetwork, error)

func ListUserSavedWifiNetworks added in v0.5.0

func ListUserSavedWifiNetworks() ([]WiFiNetwork, error)

func ScanWiFiNetworks

func ScanWiFiNetworks() ([]WiFiNetwork, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL