Documentation ¶
Index ¶
- Constants
- func BToStr(b []byte) string
- type AcknowledgementLanMessage
- type Connection
- func (o Connection) Close() error
- func (o Connection) DiscoverAllDevices(timeout int) ([]Device, error)
- func (o Connection) DiscoverDevices(timeout int, filter DiscoverFilter) (devices []Device, err error)
- func (o Connection) SendTo(msg SendableLanMessage, devices []Device) error
- func (o Connection) SendToAll(msg SendableLanMessage) error
- func (o Connection) SendToAllAndGet(timeout int, msg SendableLanMessage, filter Filter) (recMsgs map[Device]ReceivableLanMessage, err error)
- func (o Connection) SendToAndGet(msg SendableLanMessage, devices []Device, filter Filter) (recMsgs map[Device]ReceivableLanMessage, err error)
- type Device
- type DiscoverFilter
- type EchoRequestLanMessage
- type EchoResponseLanMessage
- type Filter
- type HSBK
- type LanHeader
- type LanHeaderFrame
- type LanHeaderFrameAddress
- type LanHeaderProtocolHeader
- type LightSetColorLanMessage
- type LightSetPowerLanMessage
- type LightStateLanMessage
- type LightStatePowerLanMessage
- type ReceivableLanMessage
- type SendableLanMessage
- func EchoRequest(payload EchoRequestLanMessage) SendableLanMessage
- func GetGroup() SendableLanMessage
- func GetHostFirmware() SendableLanMessage
- func GetHostInfo() SendableLanMessage
- func GetInfo() SendableLanMessage
- func GetLabel() SendableLanMessage
- func GetLocation() SendableLanMessage
- func GetOwner() SendableLanMessage
- func GetPower() SendableLanMessage
- func GetService() SendableLanMessage
- func GetVersion() SendableLanMessage
- func GetWifiFirmware() SendableLanMessage
- func GetWifiInfo() SendableLanMessage
- func LightGet() SendableLanMessage
- func LightGetPower() SendableLanMessage
- func LightSetColor(payload LightSetColorLanMessage) SendableLanMessage
- func LightSetPower(payload LightSetPowerLanMessage) SendableLanMessage
- func SetLabel(payload SetLabelLanMessage) SendableLanMessage
- func SetOwner(payload SetOwnerLanMessage) SendableLanMessage
- func SetPower(payload SetPowerLanMessage) SendableLanMessage
- type SetLabelLanMessage
- type SetOwnerLanMessage
- type SetPowerLanMessage
- type StateGroupLanMessage
- type StateHostFirmwareLanMessage
- type StateHostInfoLanMessage
- type StateInfoLanMessage
- type StateLabelLanMessage
- type StateLocationLanMessage
- type StateOwnerLanMessage
- type StatePowerLanMessage
- type StateServiceLanMessage
- type StateVersionLanMessage
- type StateWifiFirmwareLanMessage
- type StateWifiInfoLanMessage
Constants ¶
const ( // NormalTimeout is a sane number of milliseconds to wait before timing out during discovery. NormalTimeout = 250 MaxReadSize = LanHeaderSize + 64 DefaultPort = 56700 DefaultPortStr = "56700" )
const ( // MessageRate is the maximum recommended number of messages a device should // receive in a second. MessageRate = 20 // The LanHeaderSize is the size of the header for a LAN message in bytes. LanHeaderSize = 36 )
const ( SetSiteType = 1 GetServiceType = 2 StateServiceType = 3 GetTimeType = 4 SetTimeType = 5 StateTimeType = 6 GetResetSwitchType = 7 StateResetSwitchType = 8 GetDummyLoadType = 9 SetDummyLoadType = 10 StateDummyLoadType = 11 GetHostInfoType = 12 StateHostInfoType = 13 GetHostFirmwareType = 14 StateHostFirmwareType = 15 GetWifiInfoType = 16 StateWifiInfoType = 17 GetWifiFirmwareType = 18 StateWifiFirmwareType = 19 GetPowerType = 20 SetPowerType = 21 StatePowerType = 22 GetLabelType = 23 SetLabelType = 24 StateLabelType = 25 GetTagsType = 26 SetTagsType = 27 StateTagsType = 28 GetTagLabelsType = 29 SetTagLabelsType = 30 StateTagLabelsType = 31 GetVersionType = 32 StateVersionType = 33 GetInfoType = 34 StateInfoType = 35 GetMcuRailVoltageType = 36 StateMcuRailVoltageType = 37 SetRebootType = 38 SetFactoryTestModeType = 39 DisableFactoryTestModeType = 40 StateFactoryTestModeType = 41 StateSiteType = 42 StateRebootType = 43 SetPanGatewayType = 44 AcknowledgementType = 45 SetFactoryResetType = 46 StateFactoryResetType = 47 GetLocationType = 48 SetLocationType = 49 StateLocationType = 50 GetGroupType = 51 SetGroupType = 52 StateGroupType = 53 GetOwnerType = 54 SetOwnerType = 55 StateOwnerType = 56 GetFactoryTestModeType = 57 EchoRequestType = 58 EchoResponseType = 59 LightGetType = 101 LightSetColorType = 102 LightSetWaveformType = 103 LightSetDimAbsoluteType = 104 LightSetDimRelativeType = 105 LightSetRgbwType = 106 LightStateType = 107 LightGetRailVoltageType = 108 LightStateRailVoltageType = 109 LightGetTemperatureType = 110 LightStateTemperatureType = 111 LightSetCalibrationCoefficientsType = 112 LightSetSimpleEventType = 113 LightGetSimpleEventType = 114 LightStateSimpleEventType = 115 LightGetPowerType = 116 LightSetPowerType = 117 LightStatePowerType = 118 LightSetWaveformOptionalType = 119 WanGetType = 201 WanSetType = 202 WanStateType = 203 WanGetAuthKeyType = 204 WanSetAuthKeyType = 205 WanStateAuthKeyType = 206 WanSetKeepAliveType = 207 WanStateKeepAliveType = 208 WanSetHostType = 209 WanGetHostType = 210 WanStateHostType = 211 WifiGetType = 301 WifiSetType = 302 WifiStateType = 303 WifiGetAccessPointsType = 304 WifiSetAccessPointType = 305 WifiStateAccessPointsType = 306 WifiGetAccessPointType = 307 WifiStateAccessPointType = 308 WifiSetAccessPointBroadcastType = 309 SensorGetAmbientLightType = 401 SensorStateAmbientLightType = 402 SensorGetDimmerVoltageType = 403 SensorStateDimmerVoltageType = 404 // Misc. UdpService = 1 TcpService = 2 OnboardingService = 3 OtaService = 4 SawWaveform = 0 SineWaveform = 1 HalfSineWaveform = 2 TriangleWaveform = 3 PulseWaveform = 4 OffWanStatus = 0 ConnectedWanStatus = 1 ErrorOverCapacityWanStatus = 3 ErrorOverRateWanStatus = 4 ErrorNoRouteWanStatus = 5 ErrorInternalClientWanStatus = 6 ErrorInternalServerWanStatus = 7 ErrorDnsFailureWanStatus = 8 ErrorSslFailureWanStatus = 9 ErrorConnectionRefusedWanStatus = 10 ConnectingWanStatus = 11 SoftApWifiNetworkInterface = 1 StationWifiNetworkInterface = 2 ConnectingWifiStatus = 0 ConnectedWifiStatus = 1 FailedWifiStatus = 2 OffWifistatus = 3 UnknownWifiSecurity = 0 OpenWifiSecurity = 1 WepPskWifiSecurity = 2 WpaTkipPskWifiSecurity = 3 WpaAesPskWifiSecurity = 4 Wpa2AesPskWifiSecurity = 5 Wpa2TkipPskWifiSecurity = 6 Wpa2MixedPskWifiSecurity = 7 Original1000VendorId = 1 Color650VendorId = 1 White800LowVVendorId = 1 White800HighVVendorId = 1 White900Br30LowVVendorId = 1 Color1000Br30VendorId = 1 Color1000VendorId = 1 Original1000ProductId = 1 Color650ProductId = 3 White800LowVProductId = 10 White800HighVProductId = 11 White900Br30LowVProductId = 18 Color1000Br30ProductId = 20 Color1000ProductId = 22 Original1000Color = true Color650Color = true White800LowVColor = false White800HighVColor = false White900Br30LowVColor = false Color1000Br30Color = true Color1000Color = true )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AcknowledgementLanMessage ¶
type AcknowledgementLanMessage struct{}
func (*AcknowledgementLanMessage) UnmarshalBinary ¶
func (o *AcknowledgementLanMessage) UnmarshalBinary(data []byte) error
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection is the connection between the client and the network devices.
func Connect ¶
func Connect() (_ Connection, err error)
func ManualConnect ¶
func ManualConnect(bcastAddr *net.UDPAddr) (o Connection, err error)
func (Connection) Close ¶
func (o Connection) Close() error
func (Connection) DiscoverAllDevices ¶
func (o Connection) DiscoverAllDevices(timeout int) ([]Device, error)
DiscoverAllDevices discovers as many devices as possible on the network within the timeout.
func (Connection) DiscoverDevices ¶
func (o Connection) DiscoverDevices(timeout int, filter DiscoverFilter) (devices []Device, err error)
DiscoverDevices discovers as many devices as possible on the network within the timeout and filters devices.
func (Connection) SendTo ¶
func (o Connection) SendTo(msg SendableLanMessage, devices []Device) error
SendTo sends the message to the devices without expecting responses.
func (Connection) SendToAll ¶
func (o Connection) SendToAll(msg SendableLanMessage) error
SendToAll sends the message to all devices on the network without expecting responses.
func (Connection) SendToAllAndGet ¶
func (o Connection) SendToAllAndGet(timeout int, msg SendableLanMessage, filter Filter) (recMsgs map[Device]ReceivableLanMessage, err error)
SendToAllAndGet sends the message to all devices on the network, filters the responses, and builds a mapping between a responding device and its response.
func (Connection) SendToAndGet ¶
func (o Connection) SendToAndGet(msg SendableLanMessage, devices []Device, filter Filter) (recMsgs map[Device]ReceivableLanMessage, err error)
SendToAndGet sends the message to the devices, filters the responses, and builds a mapping between a responding device and its response.
type Device ¶
type Device struct { // Addr is the remote address of the device. Addr *net.UDPAddr // Mac is the MAC address of the device. Mac uint64 }
Device is a LIFX device on the network.
type DiscoverFilter ¶
type DiscoverFilter func(ReceivableLanMessage, Device) (register bool, cont bool)
DiscoverFilter first returns whether or not the device should be registered and later returned after discovery. The second return value specifies if discovery should continue if there's still time left.
type EchoRequestLanMessage ¶
type EchoRequestLanMessage struct {
Payload [64]byte
}
func (EchoRequestLanMessage) MarshalBinary ¶
func (o EchoRequestLanMessage) MarshalBinary() ([]byte, error)
type EchoResponseLanMessage ¶
type EchoResponseLanMessage struct {
Payload [64]byte
}
func (*EchoResponseLanMessage) UnmarshalBinary ¶
func (o *EchoResponseLanMessage) UnmarshalBinary(data []byte) error
type Filter ¶
type Filter func(ReceivableLanMessage) bool
Filter returns false for messages that should not be further processed.
func TypeFilter ¶
TypeFilter filters out responses that do not have the payload type.
type LanHeader ¶
type LanHeader struct { Frame LanHeaderFrame FrameAddress LanHeaderFrameAddress ProtocolHeader LanHeaderProtocolHeader }
func (LanHeader) MarshalBinary ¶
func (*LanHeader) UnmarshalBinary ¶
type LanHeaderFrame ¶
func (LanHeaderFrame) MarshalBinary ¶
func (o LanHeaderFrame) MarshalBinary() (data []byte, _ error)
func (*LanHeaderFrame) UnmarshalBinary ¶
func (o *LanHeaderFrame) UnmarshalBinary(data []byte) error
type LanHeaderFrameAddress ¶
type LanHeaderFrameAddress struct { Target uint64 AckRequired bool ResRequired bool Sequence uint8 }
func (LanHeaderFrameAddress) MarshalBinary ¶
func (o LanHeaderFrameAddress) MarshalBinary() (data []byte, _ error)
func (*LanHeaderFrameAddress) UnmarshalBinary ¶
func (o *LanHeaderFrameAddress) UnmarshalBinary(data []byte) error
type LanHeaderProtocolHeader ¶
type LanHeaderProtocolHeader struct {
Type uint16
}
func (LanHeaderProtocolHeader) MarshalBinary ¶
func (o LanHeaderProtocolHeader) MarshalBinary() (data []byte, _ error)
func (*LanHeaderProtocolHeader) UnmarshalBinary ¶
func (o *LanHeaderProtocolHeader) UnmarshalBinary(data []byte) error
type LightSetColorLanMessage ¶
func (LightSetColorLanMessage) MarshalBinary ¶
func (o LightSetColorLanMessage) MarshalBinary() (data []byte, err error)
type LightSetPowerLanMessage ¶
func (LightSetPowerLanMessage) MarshalBinary ¶
func (o LightSetPowerLanMessage) MarshalBinary() (data []byte, _ error)
type LightStateLanMessage ¶
func (*LightStateLanMessage) UnmarshalBinary ¶
func (o *LightStateLanMessage) UnmarshalBinary(data []byte) error
type LightStatePowerLanMessage ¶
type LightStatePowerLanMessage struct {
Level uint16
}
func (*LightStatePowerLanMessage) UnmarshalBinary ¶
func (o *LightStatePowerLanMessage) UnmarshalBinary(data []byte) error
type ReceivableLanMessage ¶
type ReceivableLanMessage struct { Header LanHeader Payload encoding.BinaryUnmarshaler }
func (*ReceivableLanMessage) UnmarshalBinary ¶
func (o *ReceivableLanMessage) UnmarshalBinary(data []byte) error
type SendableLanMessage ¶
type SendableLanMessage struct { Header LanHeader Payload encoding.BinaryMarshaler }
func EchoRequest ¶
func EchoRequest(payload EchoRequestLanMessage) SendableLanMessage
func GetGroup ¶
func GetGroup() SendableLanMessage
func GetHostFirmware ¶
func GetHostFirmware() SendableLanMessage
func GetHostInfo ¶
func GetHostInfo() SendableLanMessage
func GetInfo ¶
func GetInfo() SendableLanMessage
func GetLabel ¶
func GetLabel() SendableLanMessage
func GetLocation ¶
func GetLocation() SendableLanMessage
func GetOwner ¶
func GetOwner() SendableLanMessage
func GetPower ¶
func GetPower() SendableLanMessage
func GetService ¶
func GetService() SendableLanMessage
func GetVersion ¶
func GetVersion() SendableLanMessage
func GetWifiFirmware ¶
func GetWifiFirmware() SendableLanMessage
func GetWifiInfo ¶
func GetWifiInfo() SendableLanMessage
func LightGet ¶
func LightGet() SendableLanMessage
func LightGetPower ¶
func LightGetPower() SendableLanMessage
func LightSetColor ¶
func LightSetColor(payload LightSetColorLanMessage) SendableLanMessage
func LightSetPower ¶
func LightSetPower(payload LightSetPowerLanMessage) SendableLanMessage
func SetLabel ¶
func SetLabel(payload SetLabelLanMessage) SendableLanMessage
func SetOwner ¶
func SetOwner(payload SetOwnerLanMessage) SendableLanMessage
func SetPower ¶
func SetPower(payload SetPowerLanMessage) SendableLanMessage
func (SendableLanMessage) MarshalBinary ¶
func (o SendableLanMessage) MarshalBinary() (data []byte, err error)
type SetLabelLanMessage ¶
type SetLabelLanMessage struct {
Label string
}
func (SetLabelLanMessage) MarshalBinary ¶
func (o SetLabelLanMessage) MarshalBinary() (data []byte, _ error)
type SetOwnerLanMessage ¶
func (SetOwnerLanMessage) MarshalBinary ¶
func (o SetOwnerLanMessage) MarshalBinary() (data []byte, _ error)
type SetPowerLanMessage ¶
type SetPowerLanMessage struct {
Level uint16
}
func (SetPowerLanMessage) MarshalBinary ¶
func (o SetPowerLanMessage) MarshalBinary() (data []byte, _ error)
type StateGroupLanMessage ¶
func (*StateGroupLanMessage) UnmarshalBinary ¶
func (o *StateGroupLanMessage) UnmarshalBinary(data []byte) error
type StateHostFirmwareLanMessage ¶
func (*StateHostFirmwareLanMessage) UnmarshalBinary ¶
func (o *StateHostFirmwareLanMessage) UnmarshalBinary(data []byte) error
type StateHostInfoLanMessage ¶
func (*StateHostInfoLanMessage) UnmarshalBinary ¶
func (o *StateHostInfoLanMessage) UnmarshalBinary(data []byte) error
type StateInfoLanMessage ¶
func (*StateInfoLanMessage) UnmarshalBinary ¶
func (o *StateInfoLanMessage) UnmarshalBinary(data []byte) error
type StateLabelLanMessage ¶
type StateLabelLanMessage struct {
Label string
}
func (*StateLabelLanMessage) UnmarshalBinary ¶
func (o *StateLabelLanMessage) UnmarshalBinary(data []byte) error
type StateLocationLanMessage ¶
func (*StateLocationLanMessage) UnmarshalBinary ¶
func (o *StateLocationLanMessage) UnmarshalBinary(data []byte) error
type StateOwnerLanMessage ¶
func (*StateOwnerLanMessage) UnmarshalBinary ¶
func (o *StateOwnerLanMessage) UnmarshalBinary(data []byte) error
type StatePowerLanMessage ¶
type StatePowerLanMessage struct {
Level uint16
}
func (*StatePowerLanMessage) UnmarshalBinary ¶
func (o *StatePowerLanMessage) UnmarshalBinary(data []byte) error
type StateServiceLanMessage ¶
func (*StateServiceLanMessage) UnmarshalBinary ¶
func (o *StateServiceLanMessage) UnmarshalBinary(data []byte) error
type StateVersionLanMessage ¶
func (*StateVersionLanMessage) UnmarshalBinary ¶
func (o *StateVersionLanMessage) UnmarshalBinary(data []byte) error
type StateWifiFirmwareLanMessage ¶
func (*StateWifiFirmwareLanMessage) UnmarshalBinary ¶
func (o *StateWifiFirmwareLanMessage) UnmarshalBinary(data []byte) error
type StateWifiInfoLanMessage ¶
func (*StateWifiInfoLanMessage) UnmarshalBinary ¶
func (o *StateWifiInfoLanMessage) UnmarshalBinary(data []byte) error