Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
Does something and returns an error if there's a problem.
func (Action) And ¶
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
type Driver ¶
type Driver struct { APReader APReader BindingChain BindingChain Interval time.Duration }
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)
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
Source Files ¶
Click to show internal directories.
Click to hide internal directories.