cmd

package
v0.0.0-...-cff5da0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeNetwork

func MakeNetwork() (Network, ReadFunc, WriteFunc)

MakeNetwork opens all resources needed to run the network and returns read and write functions that need to be run on their own goroutines

func ReadFromFile

func ReadFromFile() (model.Store, error)

ReadFromFile reads data from the home.data file

func SaveStore

func SaveStore(store *model.Store)

SaveStore handles updating the store file

func SaveToFile

func SaveToFile(store model.Store) error

SaveToFile writes data to the home.data file

Types

type Network

type Network struct {
	Store              *model.Store
	Controller         mesh.Controller
	UnprovisionedNodes *[][]byte
	NodeAdded          chan uint16
}

Network holds all needed data for the operation of the mesh network

func (*Network) AddAccessKey

func (n *Network) AddAccessKey() ([]byte, error)

AddAccessKey generates and saves a Web Key

func (*Network) AddDevice

func (n *Network) AddDevice(name string, uuid []byte, groupAddr uint16) (uint16, error)

AddDevice provisions configures and adds the device at the given uuid

func (*Network) AddGroup

func (n *Network) AddGroup(name string) (uint16, error)

AddGroup creates a group in the store with the given name

func (*Network) CheckAccessKey

func (n *Network) CheckAccessKey(webKey []byte) bool

CheckAccessKey checks the access key using know access keys

func (*Network) CheckIfConfigured

func (n *Network) CheckIfConfigured() bool

CheckIfConfigured checks if the network is configured

func (*Network) Close

func (n *Network) Close()

Close closes all of the resources that the network depends on

func (*Network) ConfigHub

func (n *Network) ConfigHub() ([]byte, error)

ConfigHub Initializes the hub for the first time

func (*Network) EventBind

func (n *Network) EventBind(groupAddr, devAddr, elemAddr, sceneNumber uint16) error

EventBind sends a event bind msg to the element and sets the elements state to the scene number

func (*Network) GetGroup

func (n *Network) GetGroup(groupAddr uint16) (*model.Group, error)

GetGroup returns a reference to the group with the given address

func (*Network) GetGroups

func (n *Network) GetGroups() map[uint16]*model.Group

GetGroups returns a map of references to all of the groups in the network

func (*Network) GetUnprovisionedNodes

func (n *Network) GetUnprovisionedNodes() [][]byte

GetUnprovisionedNodes returns a list of detected unprovisioned nodes

func (*Network) ReadState

func (n *Network) ReadState(groupAddr, devAddr, elemAddr uint16) ([]byte, error)

ReadState Gets the state from a elem on a device

func (*Network) RemoveDevice

func (n *Network) RemoveDevice(groupAddr, devAddr uint16) error

RemoveDevice sends are reset message and removes the device from the group

func (*Network) RemoveGroup

func (n *Network) RemoveGroup(groupAddr uint16) error

RemoveGroup deletes the group from the store and sends reset messages to all the devices in the group

func (*Network) ResetHub

func (n *Network) ResetHub()

ResetHub Initializes the hub for the first time

func (*Network) SceneDelete

func (n *Network) SceneDelete(groupAddr, sceneNumber uint16) error

SceneDelete sends a delete message to devices in the group and removes the scene from the group

func (*Network) SceneRecall

func (n *Network) SceneRecall(groupAddr, sceneNumber uint16) error

SceneRecall sends a recall message to devices in the group

func (*Network) SceneStore

func (n *Network) SceneStore(groupAddr uint16, name string) (uint16, error)

SceneStore adds a scene to a group and sends a SceneStore message

func (*Network) SetState

func (n *Network) SetState(state []byte, groupAddr, elemAddr uint16) error

SetState sends a state message to the element at the given address

func (*Network) UpdateState

func (n *Network) UpdateState(elemAddr uint16, state byte) error

UpdateState Sets the state of a elem on the device

type ReadFunc

type ReadFunc func(updateState func(), publishEvents func(addr uint16))

ReadFunc is a function that can be called on a seprate thread that will read from the mesh controller

type WriteFunc

type WriteFunc func()

WriteFunc is a function that writes the store to a file every 500 ms

Jump to

Keyboard shortcuts

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