Documentation ¶
Overview ¶
Package uiot provides functionality for building your own smart home network.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Close ¶
func Close()
Close notifies all known remote devices that this device is disconnecting from the network.
func CloseHandler ¶
func CloseHandler()
CloseHandler adds a SIGTERM handler to automatically disconnect from the network.
Types ¶
type Device ¶
type Device struct { Name string Type Type Room Room Funcs map[string]*Func // contains filtered or unexported fields }
Device represents a device's location and functionality within a home.
func NewDevice ¶
NewDevice creates a new device with the provided name, room, and type. This device is intended to be used locally, as a place to define functions that can be called remotely.
func (*Device) AddFunction ¶
AddFunction adds a function f to device d. Remote devices can call this function using the provided name and params, p.
type Event ¶
Event represents a change in state in the network. Used in the Network struct, specifically when the user has enabled eventing via network.EnableEvents().
type EventType ¶
type EventType int
EventType represents the different types of events that are supported by the eventing interface.
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
Network contains a list of all devices on the network, updated dynamically as devices connect and disconnect.
func Bootstrap ¶
Bootstrap starts networking services and broadcasts device information dev to the rest of the network.
func (Network) CallAll ¶
CallAll calls a function on all devices that match the provided room and type.
func (*Network) EnableEvents ¶
EnableEvents provides access to the Event channel, allowing a device to detect when a remote device connects or disconnects from the network.
func (Network) GetDevices ¶
GetDevices returns all known devices from the network.
type Room ¶
type Room int
Room represents various rooms a device could be placed in.
func RoomFromString ¶
RoomFromString converts a room string (in the same form as one returned from room.String()) into a valid Room. Supports wildcard (*) for use in network.CallAll().
type Type ¶
type Type int
Type represents the various types of devices that can exist on the network.
func TypeFromString ¶
TypeFromString converts a type string (in the same form as one returned from type.String()) into a valid Type. Supports wildcard (*) for use in network.CallAll().