packet

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package packet implements a LIFX LAN protocol version 2 packet.

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

Index

Constants

This section is empty.

Variables

View Source
var (
	ClientID uint32
)

Functions

This section is empty.

Types

type Chan

type Chan chan Response

type Frame

type Frame struct {
	Size uint16 `struc:"little"` // Size of entire message in bytes including this field
	// Origin (2-bit): Message origin indicator: must be zero (0)
	// Tagged (1-bit): Determines usage of Frame Address *target* field
	// Addressable (1-bit): Message includes a target address: must be one (1)
	// Protocol (12-bit): Protocol number: must be 1024 (decimal)
	OriginTaggedAddressableProtocol uint16 `struct:"little"`
	Source                          uint32 `struc:"little"` // Source identifier: unique value set by the client, used by responses
}

func (*Frame) GetAddressable

func (f *Frame) GetAddressable() bool

func (*Frame) GetProtocol

func (f *Frame) GetProtocol() uint16

func (*Frame) GetSource

func (f *Frame) GetSource() uint32

func (*Frame) GetTagged

func (f *Frame) GetTagged() bool

func (*Frame) SetAddressable

func (f *Frame) SetAddressable(addressable bool)

func (*Frame) SetProtocol

func (f *Frame) SetProtocol(protocol uint16)

func (*Frame) SetSize

func (f *Frame) SetSize(size uint16)

func (*Frame) SetSource

func (f *Frame) SetSource(source uint32)

func (*Frame) SetTagged

func (f *Frame) SetTagged(tagged bool)

type FrameAddress

type FrameAddress struct {
	Target   uint64   `struc:"little"` // Device address (MAC address) or zero (0) means all devices
	Reserved [6]uint8 `struc:"little"`
	// Reserved(6-bit)
	// AckRequired(1-bit): Acknowledgement message required
	// ResRequired(1-bit): Response message required
	ReservedAckRequiredResRequired uint8 `struc:"little"`
	Sequence                       uint8 `struc:"little"`
}

func (*FrameAddress) GetAckRequired

func (f *FrameAddress) GetAckRequired() bool

func (*FrameAddress) GetResRequired

func (f *FrameAddress) GetResRequired() bool

func (*FrameAddress) GetSequence

func (f *FrameAddress) GetSequence() uint8

func (*FrameAddress) GetTarget

func (f *FrameAddress) GetTarget() uint64

func (*FrameAddress) SetAckRequired

func (f *FrameAddress) SetAckRequired(ackRequired bool)

func (*FrameAddress) SetResRequired

func (f *FrameAddress) SetResRequired(resRequired bool)

func (*FrameAddress) SetSequence

func (f *FrameAddress) SetSequence(sequence uint8)

func (*FrameAddress) SetTarget

func (f *FrameAddress) SetTarget(target uint64)

type Packet

type Packet struct {
	Frame
	FrameAddress
	ProtocolHeader
	// contains filtered or unexported fields
}

func Decode

func Decode(buf []byte) (*Packet, error)

func New

func New(destination *net.UDPAddr, socket *net.UDPConn) *Packet

func (*Packet) DecodePayload

func (p *Packet) DecodePayload(dest interface{}) error

func (*Packet) GetPayload

func (p *Packet) GetPayload() []byte

func (*Packet) SetPayload

func (p *Packet) SetPayload(payload interface{}) error

func (*Packet) Write

func (p *Packet) Write() error

type ProtocolHeader

type ProtocolHeader struct {
	Reserved0 uint64 `struc:"little"` // Reserved
	Type      uint16 `struc:"little"` // Message type determines the payload being used
	Reserved1 uint16 `struc:"little"` // Reserved
}

func (*ProtocolHeader) GetType

func (h *ProtocolHeader) GetType() shared.Message

func (*ProtocolHeader) SetType

func (h *ProtocolHeader) SetType(msgType shared.Message)

type Response

type Response struct {
	Result Packet
	Error  error
}

Jump to

Keyboard shortcuts

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