presence

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package presence provides the core functionality of the wifi-presence app.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Daemon

type Daemon struct {
	// contains filtered or unexported fields
}

Daemon runs the main wifi-presence program loop.

func NewDaemon

func NewDaemon(opts ...Opt) (*Daemon, error)

NewDaemon returns a Daemon, configured via the Opt arguments.

func (*Daemon) Run

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

Run starts the Daemon processing hostapd events and publishing to MQTT. It blocks until it encounters an error or when the context is cancelled.

type MAC

type MAC [6]byte

MAC is a hardware MAC address.

func (*MAC) Decode

func (m *MAC) Decode(s string) error

Decode converts a string of form "XX:XX:XX:XX:XX" to a MAC.

func (MAC) MarshalJSON

func (m MAC) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON representation of m.

func (MAC) String

func (m MAC) String() string

String returns the address in a "XX:XX:XX:XX:XX" formatted string (lower-case letters).

func (*MAC) UnmarshalJSON

func (m *MAC) UnmarshalJSON(b []byte) error

UnmarshalJSON decodes the JSON representation of a mac into m.

type Opt

type Opt func(*Daemon)

Opt is a configuration option for Daemon.

func WithAPName

func WithAPName(name string) Opt

WithAPName sets the name of the Access Point. This name is used for station attributes and topic path creation.

func WithDebounce

func WithDebounce(db time.Duration) Opt

WithDebounce is optionally and sets the debounce time for station connect/disconnect events.

func WithHASSAutodiscovery

func WithHASSAutodiscovery(ad bool) Opt

WithHASSAutodiscovery configures whether daemon will publish MQTT autodiscovery messages for Home Assistant.

func WithHassOpt

func WithHassOpt(hm *hass.MQTT) Opt

WithHassOpt is required and sets the hass.MQTT the daemon will use.

func WithHostAPD

func WithHostAPD(ha *hostapd.Client) Opt

WithHostAPD is required at least once and sets the hostapd.Client the daemon will use. Multple hostapd.Clients may be used.

func WithLogger

func WithLogger(l *log.Logger) Opt

WithLogger is optional and defines a logger for the daemon to use.

Jump to

Keyboard shortcuts

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