device

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2016 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package device implements a LIFX LAN protocol version 2 device.

This package is not designed to be accessed by end users, all interaction should occur via the Client in the golifx package.

Index

Constants

View Source
const (
	GetService        shared.Message = 2
	StateService      shared.Message = 3
	GetHostInfo       shared.Message = 12
	StateHostInfo     shared.Message = 13
	GetHostFirmware   shared.Message = 14
	StateHostFirmware shared.Message = 15
	GetWifiInfo       shared.Message = 16
	StateWifiInfo     shared.Message = 17
	GetWifiFirmware   shared.Message = 18
	StateWifiFirmware shared.Message = 19
	GetPower          shared.Message = 20
	SetPower          shared.Message = 21
	StatePower        shared.Message = 22
	GetLabel          shared.Message = 23
	SetLabel          shared.Message = 24
	StateLabel        shared.Message = 25
	GetVersion        shared.Message = 32
	StateVersion      shared.Message = 33
	GetInfo           shared.Message = 34
	StateInfo         shared.Message = 35
	Acknowledgement   shared.Message = 45
	GetLocation       shared.Message = 48
	StateLocation     shared.Message = 50
	GetGroup          shared.Message = 51
	StateGroup        shared.Message = 53
	EchoRequest       shared.Message = 58
	EchoResponse      shared.Message = 59

	VendorLifx = 1

	ProductLifxOriginal1000        uint32 = 1
	ProductLifxColor650            uint32 = 3
	ProductLifxWhite800LowVoltage  uint32 = 10
	ProductLifxWhite800HighVoltage uint32 = 11
	ProductLifxWhite900BR30        uint32 = 18
	ProductLifxColor1000BR30       uint32 = 20
	ProductLifxColor1000           uint32 = 22
)
View Source
const (
	Get             shared.Message = 101
	SetColor        shared.Message = 102
	State           shared.Message = 107
	LightGetPower   shared.Message = 116
	LightSetPower   shared.Message = 117
	LightStatePower shared.Message = 118
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New(addr *net.UDPAddr, requestSocket *net.UDPConn, timeout *time.Duration, retryInterval *time.Duration, reliable bool, pkt *packet.Packet) (*Device, error)

func (*Device) CachedFirmwareVersion added in v0.4.1

func (d *Device) CachedFirmwareVersion() string

func (*Device) CachedGroup added in v0.3.4

func (d *Device) CachedGroup() string

func (*Device) CachedHardwareProduct added in v0.4.0

func (d *Device) CachedHardwareProduct() uint32

func (*Device) CachedHardwareVendor added in v0.4.0

func (d *Device) CachedHardwareVendor() uint32

func (*Device) CachedHardwareVersion added in v0.4.0

func (d *Device) CachedHardwareVersion() uint32

func (*Device) CachedLabel added in v0.4.0

func (d *Device) CachedLabel() string

func (*Device) CachedLocation added in v0.3.4

func (d *Device) CachedLocation() string

func (*Device) CachedPower added in v0.3.0

func (d *Device) CachedPower() bool

func (*Device) Close

func (d *Device) Close() error

Close cleans up Device resources

func (*Device) CloseSubscription added in v0.1.0

func (d *Device) CloseSubscription(sub *common.Subscription) error

CloseSubscription is a callback for handling the closing of subscriptions.

func (*Device) Discover

func (d *Device) Discover() error

func (*Device) GetAddress

func (d *Device) GetAddress() *net.UDPAddr

func (*Device) GetFirmwareVersion added in v0.4.1

func (d *Device) GetFirmwareVersion() (ret string, err error)

func (*Device) GetGroup added in v0.2.0

func (d *Device) GetGroup() (ret string, err error)

func (*Device) GetHardwareProduct

func (d *Device) GetHardwareProduct() (uint32, error)

func (*Device) GetHardwareVendor

func (d *Device) GetHardwareVendor() (uint32, error)

func (*Device) GetHardwareVersion

func (d *Device) GetHardwareVersion() (uint32, error)

func (*Device) GetLabel

func (d *Device) GetLabel() (string, error)

func (*Device) GetLocation added in v0.2.0

func (d *Device) GetLocation() (ret string, err error)

func (*Device) GetPower

func (d *Device) GetPower() (bool, error)

func (*Device) Handle

func (d *Device) Handle(pkt *packet.Packet)

func (*Device) ID

func (d *Device) ID() uint64

func (*Device) NewSubscription added in v0.1.0

func (d *Device) NewSubscription() (*common.Subscription, error)

NewSubscription returns a new *common.Subscription for receiving events from this device.

func (*Device) Provisional added in v0.4.1

func (d *Device) Provisional() bool

func (*Device) ResetLimiter

func (d *Device) ResetLimiter()

func (*Device) Seen

func (d *Device) Seen() time.Time

func (*Device) Send

func (d *Device) Send(pkt *packet.Packet, ackRequired, responseRequired bool) (packet.Chan, error)

func (*Device) SetLabel

func (d *Device) SetLabel(label string) error

func (*Device) SetPower

func (d *Device) SetPower(state bool) error

func (*Device) SetProvisional added in v0.4.1

func (d *Device) SetProvisional(provisional bool)

func (*Device) SetSeen

func (d *Device) SetSeen(seen time.Time)

func (*Device) SetStateGroup added in v0.2.0

func (d *Device) SetStateGroup(pkt *packet.Packet) error

func (*Device) SetStateHostFirmware added in v0.4.1

func (d *Device) SetStateHostFirmware(pkt *packet.Packet) error

func (*Device) SetStateLabel

func (d *Device) SetStateLabel(pkt *packet.Packet) error

func (*Device) SetStateLocation added in v0.2.0

func (d *Device) SetStateLocation(pkt *packet.Packet) error

func (*Device) SetStatePower

func (d *Device) SetStatePower(pkt *packet.Packet) error

type GenericDevice

type GenericDevice interface {
	common.Device
	Handle(*packet.Packet)
	Close() error
	Seen() time.Time
	SetSeen(time.Time)
	Provisional() bool
	SetProvisional(bool)
	SetStatePower(*packet.Packet) error
	SetStateLabel(*packet.Packet) error
	SetStateLocation(*packet.Packet) error
	SetStateGroup(*packet.Packet) error
	GetLocation() (string, error)
	CachedLocation() string
	GetGroup() (string, error)
	CachedGroup() string
	GetHardwareVendor() (uint32, error)
	GetHardwareProduct() (uint32, error)
	ResetLimiter()
}

type Group added in v0.2.0

type Group struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewGroup added in v0.2.0

func NewGroup(pkt *packet.Packet) (*Group, error)

func (*Group) AddDevice added in v0.2.0

func (g *Group) AddDevice(dev GenericDevice) error

func (*Group) CachedColor added in v0.3.0

func (g *Group) CachedColor() common.Color

func (*Group) CachedPower added in v0.3.0

func (g *Group) CachedPower() bool

func (*Group) Close added in v0.2.0

func (g *Group) Close() error

Close cleans up Group resources

func (*Group) CloseSubscription added in v0.2.0

func (g *Group) CloseSubscription(sub *common.Subscription) error

CloseSubscription is a callback for handling the closing of subscriptions.

func (*Group) Devices added in v0.2.0

func (g *Group) Devices() (devices []common.Device)

func (*Group) GetColor added in v0.2.0

func (g *Group) GetColor() (common.Color, error)

func (*Group) GetLabel added in v0.2.0

func (g *Group) GetLabel() string

func (*Group) GetPower added in v0.2.0

func (g *Group) GetPower() (bool, error)

func (*Group) ID added in v0.2.0

func (g *Group) ID() string

func (*Group) Lights added in v0.2.0

func (g *Group) Lights() []common.Light

func (*Group) NewSubscription added in v0.2.0

func (g *Group) NewSubscription() (*common.Subscription, error)

NewSubscription returns a new *common.Subscription for receiving events from this group.

func (*Group) Parse added in v0.2.0

func (g *Group) Parse(pkt *packet.Packet) error

func (*Group) RemoveDevice added in v0.2.0

func (g *Group) RemoveDevice(dev GenericDevice) error

func (*Group) SetColor added in v0.2.0

func (g *Group) SetColor(color common.Color, duration time.Duration) error

func (*Group) SetPower added in v0.2.0

func (g *Group) SetPower(state bool) error

func (*Group) SetPowerDuration added in v0.2.0

func (g *Group) SetPowerDuration(state bool, duration time.Duration) error

type Light

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

func (*Light) CachedColor added in v0.3.0

func (l *Light) CachedColor() common.Color

func (*Light) Get

func (l *Light) Get() error

func (*Light) GetColor

func (l *Light) GetColor() (common.Color, error)

func (*Light) SetColor

func (l *Light) SetColor(color common.Color, duration time.Duration) error

func (*Light) SetPowerDuration

func (l *Light) SetPowerDuration(state bool, duration time.Duration) error

func (*Light) SetState

func (l *Light) SetState(pkt *packet.Packet) error

type Location added in v0.2.0

type Location struct {
	// Location is a Group
	Group
}

func NewLocation added in v0.2.0

func NewLocation(pkt *packet.Packet) (*Location, error)

Jump to

Keyboard shortcuts

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