wpaconnect

package module
v0.0.0-...-10297d2 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2020 License: MIT Imports: 8 Imported by: 0

README

wpa-connect

Package provides API for connection Linux device to Wi-Fi Network.

wpa-connect communicates with WPA supplicant over D-Bus (linux message bus system).

This package was developed as part of IoT project in order to add Wi-Fi connectivity to headless Raspberry Pi like devices. No need for connman or Network Manager be installed.

Setup

On Linux:

wpa_supplicant service should run with -u flag in order to enable DBus interface. Run it as Linux service before first call to wpa_supplicant. Otherwise system will start it automatically without -u flag.

Systemd service configuration file - /etc/systemd/system/wpa_supplicant@wlan0.service

[Unit]
Description=WPA supplicant for %i

[Service]
ExecStart=/usr/sbin/wpa_supplicant -u -i%i -c/etc/wpa_supplicant.conf -Dwext

[Install]
WantedBy=multi-user.target

On Project:

go get github.com/armPelionEdge/wpa-connect

Usage

Please see godoc.org for documentation. (Not ready yet)

Examples

Connect to Wi-Fi network
import wifi "github.com/armPelionEdge/wpa-connect"

if conn, err := wifi.ConnectManager.Connect(ssid, password, time.Second * 60); err == nil {
	fmt.Println("Connected", conn.NetInterface, conn.SSID, conn.IP4.String(), conn.IP6.String())
} else {
	fmt.Println(err)
}
Scan for Wi-Fi networks
import wifi "github.com/armPelionEdge/wpa-connect"

if bssList, err := wifi.ScanManager.Scan(); err == nil {
	for _, bss := range bssList {
		print(bss.SSID, bss.Signal, bss.KeyMgmt)
	}
}

Package release under a MIT license.

Documentation

Overview

Copyright (c) 2020 ARM Limited and affiliates. Copyright (c) 2016 Mark Berner SPDX-License-Identifier: MIT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2020 ARM Limited and affiliates. Copyright (c) 2016 Mark Berner SPDX-License-Identifier: MIT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2020 ARM Limited and affiliates. Copyright (c) 2016 Mark Berner SPDX-License-Identifier: MIT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

View Source
var (
	ConnectManager = &connectManager{NetInterface: "wlan0"}
)
View Source
var (
	ScanManager = &scanManager{NetInterface: "wlan0"}
)

Functions

func SetDebugMode

func SetDebugMode()

func SetInfoMode

func SetInfoMode()

func SetSilentMode

func SetSilentMode()

func SetVerboseMode

func SetVerboseMode()

Types

type BSS

type BSS struct {
	BSSID     string
	SSID      string
	KeyMgmt   []string
	WPS       string
	Frequency uint16
	Signal    int16
	Age       uint32
	Mode      string
	Privacy   bool
}

type ConnectionInfo

type ConnectionInfo struct {
	NetInterface string
	SSID         string
	IP4          net.IP
	IP6          net.IP
}

Directories

Path Synopsis
examples
internal
log

Jump to

Keyboard shortcuts

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