protocol

package
v0.0.0-...-6ead6c4 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SetPowerConst uint16 = 21
	GetColorConst uint16 = 102
)
View Source
const (
	HeaderLength = 36
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HSBK

type HSBK struct {
	Hue        uint16
	Saturation uint16
	Brightness uint16
	Kelvin     uint16
}
type Header struct {
	// contains filtered or unexported fields
}

func DefaultHeader

func DefaultHeader() *Header

type HeaderRaw

type HeaderRaw struct {
	Size uint16
	// 2 bits origin
	// 1 bit tagged
	// 1 bit addressable
	// 12 bits protocol
	Bitfield1 uint16
	Source    uint32
	Target    [8]byte
	Reserved1 [6]byte
	// 6 bits reserved
	// 1 bit ack_required
	// 1 bit res_required
	Bitfield2 uint8
	Sequence  uint8
	Reserved2 uint64
	Type      uint16
	Reserved3 uint16
}

https://lan.developer.lifx.com/docs/header-description

type Light

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

Light details

func FindAllDevices

func FindAllDevices() ([]*Light, error)

FindAllDevices Lights on the network

func (*Light) GetLabel

func (l *Light) GetLabel()

GetLabel for light

func (*Light) SetColor

func (l *Light) SetColor()

SetColor Light colour

func (*Light) SetPower

func (l *Light) SetPower(isOn bool)

SetPower power on or off

type Message

type Message struct {
	*Header
	Payload
	// contains filtered or unexported fields
}

func DecodeBinary

func DecodeBinary(data []byte) (Message, error)

DecodeBinary Decodes Lifx native packets and auto detects payload interface required.

func DecodeBinaryExplicit

func DecodeBinaryExplicit(data []byte, payload interface{}) (Message, error)

DecodeBinaryExplicit Decodes Lifx native packets and requires passing of explicit payload interface to decode binary light messages.

func SendPacket

func SendPacket(data []byte, addr net.Addr) ([]Message, error)

SendPacket Sends packet to light/broadcast

func (Message) EncodeBinary

func (m Message) EncodeBinary() ([]byte, error)

type Payload

type Payload interface{}

type Response

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

Response Response received back

type SetColor

type SetColor struct {
	Reserved uint8
	Color    HSBK
	Duration uint32
}

type SetPower

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

SetPower https://lan.developer.lifx.com/docs/light-messages#section-setpower-117 If the Frame Address res_required field is set to one (1) then the device will transmit a StatePower message.

type StateLabel

type StateLabel struct {
	Label label // string
}

type StatePower

type StatePower struct {
	Level uint32
}

type StateService

type StateService struct {
	Service uint8  // Maps to Service. 1 is UDP. Ignore others
	Port    uint32 // Usually devices listen on 56700
}

StateService https://lan.developer.lifx.com/docs/device-messages#section-stateservice-3

Jump to

Keyboard shortcuts

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