package gonetworkmanager import ( "encoding/json" "github.com/godbus/dbus" ) const ( AccessPointInterface = NetworkManagerInterface + ".AccessPoint" /* Property */ AccessPointPropertyFlags = AccessPointInterface + ".Flags" // readable u AccessPointPropertyWpaFlags = AccessPointInterface + ".WpaFlags" // readable u AccessPointPropertyRsnFlags = AccessPointInterface + ".RsnFlags" // readable u AccessPointPropertySsid = AccessPointInterface + ".Ssid" // readable ay AccessPointPropertyFrequency = AccessPointInterface + ".Frequency" // readable u AccessPointPropertyHwAddress = AccessPointInterface + ".HwAddress" // readable s AccessPointPropertyMode = AccessPointInterface + ".Mode" // readable u AccessPointPropertyMaxBitrate = AccessPointInterface + ".MaxBitrate" // readable u AccessPointPropertyStrength = AccessPointInterface + ".Strength" // readable y AccessPointPropertyLastSeen = AccessPointInterface + ".LastSeen" // readable i ) type AccessPoint interface { GetPath() dbus.ObjectPath // GetFlags gets flags describing the capabilities of the access point. GetFlags() uint32 // GetWPAFlags gets flags describing the access point's capabilities // according to WPA (Wifi Protected Access). GetWPAFlags() uint32 // GetRSNFlags gets flags describing the access point's capabilities // according to the RSN (Robust Secure Network) protocol. GetRSNFlags() uint32 // GetSSID returns the Service Set Identifier identifying the access point. GetSSID() string // GetFrequency gets the radio channel frequency in use by the access point, // in MHz. GetFrequency() uint32 // GetHWAddress gets the hardware address (BSSID) of the access point. GetHWAddress() string // GetMode describes the operating mode of the access point. GetMode() Nm80211Mode // GetMaxBitrate gets the maximum bitrate this access point is capable of, in // kilobits/second (Kb/s). GetMaxBitrate() uint32 // GetStrength gets the current signal quality of the access point, in // percent. GetStrength() uint8 MarshalJSON() ([]byte, error) } func NewAccessPoint(objectPath dbus.ObjectPath) (AccessPoint, error) { var a accessPoint return &a, a.init(NetworkManagerInterface, objectPath) } type accessPoint struct { dbusBase } func (a *accessPoint) GetPath() dbus.ObjectPath { return a.obj.Path() } func (a *accessPoint) GetFlags() uint32 { return a.getUint32Property(AccessPointPropertyFlags) } func (a *accessPoint) GetWPAFlags() uint32 { return a.getUint32Property(AccessPointPropertyWpaFlags) } func (a *accessPoint) GetRSNFlags() uint32 { return a.getUint32Property(AccessPointPropertyRsnFlags) } func (a *accessPoint) GetSSID() string { return string(a.getSliceByteProperty(AccessPointPropertySsid)) } func (a *accessPoint) GetFrequency() uint32 { return a.getUint32Property(AccessPointPropertyFrequency) } func (a *accessPoint) GetHWAddress() string { return a.getStringProperty(AccessPointPropertyHwAddress) } func (a *accessPoint) GetMode() Nm80211Mode { return Nm80211Mode(a.getUint32Property(AccessPointPropertyMode)) } func (a *accessPoint) GetMaxBitrate() uint32 { return a.getUint32Property(AccessPointPropertyMaxBitrate) } func (a *accessPoint) GetStrength() uint8 { return a.getUint8Property(AccessPointPropertyStrength) } func (a *accessPoint) MarshalJSON() ([]byte, error) { return json.Marshal(map[string]interface{}{ "Flags": a.GetFlags(), "WPAFlags": a.GetWPAFlags(), "RSNFlags": a.GetRSNFlags(), "SSID": a.GetSSID(), "Frequency": a.GetFrequency(), "HWAddress": a.GetHWAddress(), "Mode": a.GetMode().String(), "MaxBitrate": a.GetMaxBitrate(), "Strength": a.GetStrength(), }) }