iotwifi: Index | Files

package iotwifi

import ""


Package Files

commands.go iotwifi.go types.go wpacfg.go

func RunWifi Uses

func RunWifi(log bunyan.Logger, messages chan CmdMessage, cfgLocation string)

RunWifi starts AP and Station modes.

type CmdMessage Uses

type CmdMessage struct {
    Id      string
    Command string
    Message string
    Error   bool
    Cmd     *exec.Cmd
    Stdin   *io.WriteCloser

CmdMessage structures command output.

type CmdRunner Uses

type CmdRunner struct {
    Log      bunyan.Logger
    Messages chan CmdMessage
    Handlers map[string]func(CmdMessage)
    Commands map[string]*exec.Cmd

CmdRunner runs internal commands allows output handlers to be attached.

func (*CmdRunner) HandleFunc Uses

func (c *CmdRunner) HandleFunc(cmdId string, handler func(cmdMessage CmdMessage))

HandleFunc is a function that gets all channel messages for a command id

func (*CmdRunner) ProcessCmd Uses

func (c *CmdRunner) ProcessCmd(id string, cmd *exec.Cmd)

ProcessCmd processes an internal command.

type Command Uses

type Command struct {
    Log      bunyan.Logger
    Runner   CmdRunner
    SetupCfg *SetupCfg

Command for device network commands.

func (*Command) AddApInterface Uses

func (c *Command) AddApInterface()

AddApInterface adds the AP interface.

func (*Command) CheckApInterface Uses

func (c *Command) CheckApInterface()

CheckInterface checks the AP interface.

func (*Command) ConfigureApInterface Uses

func (c *Command) ConfigureApInterface()

ConfigureApInterface configured the AP interface.

func (*Command) RemoveApInterface Uses

func (c *Command) RemoveApInterface()

RemoveApInterface removes the AP interface.

func (*Command) StartDnsmasq Uses

func (c *Command) StartDnsmasq()

StartDnsmasq starts dnsmasq.

func (*Command) StartWpaSupplicant Uses

func (c *Command) StartWpaSupplicant()

StartWpaSupplicant starts wpa_supplicant.

func (*Command) UpApInterface Uses

func (c *Command) UpApInterface()

UpApInterface ups the AP Interface.

type DnsmasqCfg Uses

type DnsmasqCfg struct {
    Address     string `json:"address"`      // --address=/#/",
    DhcpRange   string `json:"dhcp_range"`   // "--dhcp-range=,,1h",
    VendorClass string `json:"vendor_class"` // "--dhcp-vendorclass=set:device,IoT",

DnsmasqCfg configures dnsmasq and is used by SetupCfg.

type HostApdCfg Uses

type HostApdCfg struct {
    Ssid          string `json:"ssid"`           // ssid=iotwifi2
    WpaPassphrase string `json:"wpa_passphrase"` // wpa_passphrase=iotwifipass
    Channel       string `json:"channel"`        //  channel=6
    Ip            string `json:"ip"`             //

HostApdCfg configures hostapd and is used by SetupCfg.

type SetupCfg Uses

type SetupCfg struct {
    DnsmasqCfg       DnsmasqCfg       `json:"dnsmasq_cfg"`
    HostApdCfg       HostApdCfg       `json:"host_apd_cfg"`
    WpaSupplicantCfg WpaSupplicantCfg `json:"wpa_supplicant_cfg"`

SetupCfg is the main configuration structure.

type WpaCfg Uses

type WpaCfg struct {
    Log    bunyan.Logger
    WpaCmd []string
    WpaCfg *SetupCfg

WpaCfg for configuring wpa

func NewWpaCfg Uses

func NewWpaCfg(log bunyan.Logger, cfgLocation string) *WpaCfg

NewWpaCfg produces WpaCfg configuration types.

func (*WpaCfg) ConfiguredNetworks Uses

func (wpa *WpaCfg) ConfiguredNetworks() string

ConfiguredNetworks returns a list of configured wifi networks.

func (*WpaCfg) ConnectNetwork Uses

func (wpa *WpaCfg) ConnectNetwork(creds WpaCredentials) (WpaConnection, error)

ConnectNetwork connects to a wifi network

func (*WpaCfg) ScanNetworks Uses

func (wpa *WpaCfg) ScanNetworks() (map[string]WpaNetwork, error)

ScanNetworks returns a map of WpaNetwork data structures.

func (*WpaCfg) StartAP Uses

func (wpa *WpaCfg) StartAP()

StartAP starts AP mode.

func (*WpaCfg) Status Uses

func (wpa *WpaCfg) Status() (map[string]string, error)

Status returns the WPA wireless status.

type WpaConnection Uses

type WpaConnection struct {
    Ssid    string `json:"ssid"`
    State   string `json:"state"`
    Ip      string `json:"ip"`
    Message string `json:"message"`

WpaConnection defines a WPA connection.

type WpaCredentials Uses

type WpaCredentials struct {
    Ssid string `json:"ssid"`
    Psk  string `json:"psk"`

WpaCredentials defines wifi network credentials.

type WpaNetwork Uses

type WpaNetwork struct {
    Bssid       string `json:"bssid"`
    Frequency   string `json:"frequency"`
    SignalLevel string `json:"signal_level"`
    Flags       string `json:"flags"`
    Ssid        string `json:"ssid"`

WpaNetwork defines a wifi network to connect to.

type WpaSupplicantCfg Uses

type WpaSupplicantCfg struct {
    CfgFile string `json:"cfg_file"` // /etc/wpa_supplicant/wpa_supplicant.conf

WpaSupplicantCfg configures wpa_supplicant and is used by SetupCfg

Package iotwifi imports 12 packages (graph) and is imported by 1 packages. Updated 2018-04-18. Refresh now. Tools for package owners.