wifitriggers

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NilAction = Action(func(ctx context.Context) error { return nil })

Does nothing.

View Source
var NilBindingChain = BindingChain(
	func(connectedClients []net.HardwareAddr) Action { return NilAction })

Functions

func MACMustParse

func MACMustParse(s string) net.HardwareAddr

Utility that parses a MAC address or panics.

Types

type APReader

type APReader interface {
	ConnectedClients(ctx context.Context) ([]net.HardwareAddr, error)
}

type Action

type Action func(ctx context.Context) error

Does something and returns an error if there's a problem.

func (Action) And

func (a Action) And(b Action) Action

Returns an action that runs the two actions it is comprised of concurrently. golang.org/x/sync/errgroup.WithContext's semantics are used: the context will be cancelled if any member action fails and the returned error will be the error that caused the context to be cancelled.

actionA.And(actionB).And(actionC.And(actionD))

type Binding

type Binding func(connectedClients []net.HardwareAddr) Action

Represents a Cond bound to an Action. Can be created using a fluent syntax:

wifitriggers.If(someCond).Then(someAction)

type BindingChain

type BindingChain Binding

func (BindingChain) AddBinding

func (c BindingChain) AddBinding(b Binding) BindingChain

Adds a Binding to the chain.

func (BindingChain) And

func (c BindingChain) And(other BindingChain) BindingChain

Combines two chains.

type Cond

type Cond func(connectedClients []net.HardwareAddr) bool

func (Cond) And

func (a Cond) And(b Cond) Cond

Takes the logical AND of two Conds. E.g.:

condA.And(condB)

func (Cond) Or

func (a Cond) Or(b Cond) Cond

Takes the logical OR of two Conds. E.g.:

condA.Or(condB)

type Driver

type Driver struct {
	APReader     APReader
	BindingChain BindingChain
	Interval     time.Duration
}

func (*Driver) Run

func (d *Driver) Run(ctx context.Context) error

type HostapdReader

type HostapdReader struct {
	hostapd.HostapdControlClient
}

func (HostapdReader) ConnectedClients

func (h HostapdReader) ConnectedClients(ctx context.Context) ([]net.HardwareAddr, error)

type If

type If Cond

Type alias used to create a Binding. Intended to be used as

wifitriggers.If(someCond).Then(someAction)

func (If) Then

func (i If) Then(action Action) Binding

type SwitchOnIFTTT

type SwitchOnIFTTT struct {
	Key    string
	OnCmd  string
	OffCmd string
	// contains filtered or unexported fields
}

func (*SwitchOnIFTTT) OffAction

func (s *SwitchOnIFTTT) OffAction() Action

func (*SwitchOnIFTTT) OnAction

func (s *SwitchOnIFTTT) OnAction() Action

type SwitchOnSlack

type SwitchOnSlack struct {
	WebhookURL string
	OnMsg      string
	OffMsg     string
	// contains filtered or unexported fields
}

func (*SwitchOnSlack) OffAction

func (s *SwitchOnSlack) OffAction() Action

func (*SwitchOnSlack) OnAction

func (s *SwitchOnSlack) OnAction() Action

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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