Enum Message

Source
pub enum Message {
Show 61 variants GetService, StateService { service: Service, port: u32, }, GetHostInfo, StateHostInfo { signal: f32, tx: u32, rx: u32, reserved: i16, }, GetHostFirmware, StateHostFirmware { build: u64, reserved: u64, version_minor: u16, version_major: u16, }, GetWifiInfo, StateWifiInfo { signal: f32, reserved6: u32, reserved7: u32, reserved: i16, }, GetWifiFirmware, StateWifiFirmware { build: u64, reserved: u64, version_minor: u16, version_major: u16, }, GetPower, SetPower { level: PowerLevel, }, StatePower { level: u16, }, GetLabel, SetLabel { label: LifxString, }, StateLabel { label: LifxString, }, GetVersion, StateVersion { vendor: u32, product: u32, reserved: u32, }, GetInfo, StateInfo { time: u64, uptime: u64, downtime: u64, }, Acknowledgement { seq: u8, }, GetLocation, SetLocation { location: LifxIdent, label: LifxString, updated_at: u64, }, StateLocation { location: LifxIdent, label: LifxString, updated_at: u64, }, GetGroup, SetGroup { group: LifxIdent, label: LifxString, updated_at: u64, }, StateGroup { group: LifxIdent, label: LifxString, updated_at: u64, }, EchoRequest { payload: EchoPayload, }, EchoResponse { payload: EchoPayload, }, LightGet, LightSetColor { reserved: u8, color: HSBK, duration: u32, }, SetWaveform { reserved: u8, transient: bool, color: HSBK, period: u32, cycles: f32, skew_ratio: i16, waveform: Waveform, }, LightState { color: HSBK, reserved: i16, power: u16, label: LifxString, reserved2: u64, }, LightGetPower, LightSetPower { level: u16, duration: u32, }, LightStatePower { level: u16, }, SetWaveformOptional { reserved: u8, transient: bool, color: HSBK, period: u32, cycles: f32, skew_ratio: i16, waveform: Waveform, set_hue: bool, set_saturation: bool, set_brightness: bool, set_kelvin: bool, }, LightGetInfrared, LightStateInfrared { brightness: u16, }, LightSetInfrared { brightness: u16, }, LightGetHevCycle, LightSetHevCycle { enable: bool, duration: u32, }, LightStateHevCycle { duration: u32, remaining: u32, last_power: bool, }, LightGetHevCycleConfiguration, LightSetHevCycleConfiguration { indication: bool, duration: u32, }, LightStateHevCycleConfiguration { indication: bool, duration: u32, }, LightGetLastHevCycleResult, LightStateLastHevCycleResult { result: LastHevCycleResult, }, SetColorZones { start_index: u8, end_index: u8, color: HSBK, duration: u32, apply: ApplicationRequest, }, GetColorZones { start_index: u8, end_index: u8, }, StateZone { count: u8, index: u8, color: HSBK, }, StateMultiZone { count: u8, index: u8, color0: HSBK, color1: HSBK, color2: HSBK, color3: HSBK, color4: HSBK, color5: HSBK, color6: HSBK, color7: HSBK, }, GetMultiZoneEffect, SetMultiZoneEffect { instance_id: u32, typ: MultiZoneEffectType, reserved: u16, speed: u32, duration: u64, reserved7: u32, reserved8: u32, parameters: [u32; 8], }, StateMultiZoneEffect { instance_id: u32, typ: MultiZoneEffectType, reserved: u16, speed: u32, duration: u64, reserved7: u32, reserved8: u32, parameters: [u32; 8], }, SetExtendedColorZones { duration: u32, apply: ApplicationRequest, zone_index: u16, colors_count: u8, colors: Box<[HSBK; 82]>, }, GetExtendedColorZone, StateExtendedColorZones { zones_count: u16, zone_index: u16, colors_count: u8, colors: Box<[HSBK; 82]>, }, RelayGetPower { relay_index: u8, }, RelaySetPower { relay_index: u8, level: u16, }, RelayStatePower { relay_index: u8, level: u16, },
}
Expand description

Decoded LIFX Messages

This enum lists all of the LIFX message types known to this library.

Note that other message types exist, but are not officially documented (and so are not available here).

Variants§

§

GetService

Sent by a client to acquire responses from all devices on the local network. No payload is required. Causes the devices to transmit a Message::StateService message.

Message type 2

§

StateService

Response to Message::GetService message.

You’ll want to save the port number in this message, so you can send future messages directly to this device.

Message type 3

Fields

§service: Service

unsigned 8-bit integer, maps to Service

§port: u32

Port number of the light. If the service is temporarily unavailable, then the port value will be 0.

§

GetHostInfo

Get Host MCU information. No payload is required. Causes the device to transmit a Message::StateHostInfo message.

Message type 12

§

StateHostInfo

Response to Message::GetHostInfo message.

Provides host MCU information.

Message type 13

Fields

§signal: f32

radio receive signal strength in milliWatts

§tx: u32

Bytes transmitted since power on

§rx: u32

Bytes received since power on

§reserved: i16
§

GetHostFirmware

Gets Host MCU firmware information

Causes the device to transmit a Message::StateHostFirmware message.

Message type 14

§

StateHostFirmware

Response to Message::GetHostFirmware message.

Provides host firmware information.

Message type 15

Fields

§build: u64

Firmware build time (absolute time in nanoseconds since epoch)

§reserved: u64
§version_minor: u16

The minor component of the firmware version

§version_major: u16

The major component of the firmware version

§

GetWifiInfo

Get Wifi subsystem information. No payload is required. Causes the device to transmit a Message::StateWifiInfo message.

Message type 16

§

StateWifiInfo

StateWifiInfo - 17

Response to Message::GetWifiInfo message.

Provides Wifi subsystem information.

Message type 17

Fields

§signal: f32

Radio receive signal strength

The units of this field varies between different products. See this LIFX doc for more info: https://lan.developer.lifx.com/docs/information-messages#statewifiinfo---packet-17

§reserved6: u32

Reserved

This field used to store bytes transmitted since power on

§reserved7: u32

Reserved

This field used to store bytes received since power on

§reserved: i16
§

GetWifiFirmware

Get Wifi subsystem firmware

Causes the device to transmit a Message::StateWifiFirmware message.

Message type 18

§

StateWifiFirmware

Response to Message::GetWifiFirmware message.

Provides Wifi subsystem information.

Message type 19

Fields

§build: u64

firmware build time (absolute time in nanoseconds since epoch)

§reserved: u64
§version_minor: u16

The minor component of the firmware version

§version_major: u16

The major component of the firmware version

§

GetPower

Get device power level

Causes the device to transmit a Message::StatePower message

Message type 20

§

SetPower

Set device power level.

Message type 21

Fields

§level: PowerLevel

normally a u16, but only 0 and 65535 are supported.

Zero implies standby and non-zero sets a corresponding power draw level.

§

StatePower

Response to Message::GetPower message.

Provides device power level.

Message type 22

Fields

§level: u16

The current level of the device’s power

A value of 0 means off, and any other value means on. Note that 65535 is full power and during a power transition the value may be any value between 0 and 65535.

§

GetLabel

Get device label

Causes the device to transmit a Message::StateLabel message.

Message type 23

§

SetLabel

Set the device label text.

Message type 24

Fields

§

StateLabel

Response to Message::GetLabel message.

Provides device label.

Message type 25

Fields

§

GetVersion

Get the hardware version

Causes the device to transmit a Message::StateVersion message.

Message type 32

§

StateVersion

Response to Message::GetVersion message.

Provides the hardware version of the device. To get more information about this product, use the get_product_info function.

Message type 33

Fields

§vendor: u32

vendor ID

For LIFX products, this value is 1.

§product: u32

product ID

§reserved: u32

Reserved

Previously, this field stored the hardware version

§

GetInfo

Get run-time information

Causes the device to transmit a Message::StateInfo message.

Message type 34

§

StateInfo

Response to Message::GetInfo message.

Provides run-time information of device.

Message type 35

Fields

§time: u64

The current time according to the device

Note that this is most likely inaccurate.

(absolute time in nanoseconds since epoch)

§uptime: u64

The amount of time in nanoseconds the device has been online since last power on

§downtime: u64

The amount of time in nanseconds of power off time accurate to 5 seconds.

§

Acknowledgement

Response to any message sent with ack_required set to 1. See message header frame address.

(Note that technically this message has no payload, but the frame sequence number is stored here for convenience).

Message type 45

Fields

§seq: u8
§

GetLocation

Ask the bulb to return its location information

Causes the device to transmit a Message::StateLocation message.

Message type 48

§

SetLocation

Set the device location

Message type 49

Fields

§location: LifxIdent

GUID byte array

§label: LifxString

The name assigned to this location

§updated_at: u64

An epoch in nanoseconds of when this location was set on the device

§

StateLocation

Device location.

Message type 50

Fields

§location: LifxIdent
§updated_at: u64
§

GetGroup

Ask the bulb to return its group membership information

Causes the device to transmit a Message::StateGroup message.

Message type 51

§

SetGroup

Set the device group

Message type 52

Fields

§updated_at: u64
§

StateGroup

Device group.

Message type 53

Fields

§group: LifxIdent

The unique identifier of this group as a uuid.

§label: LifxString

The name assigned to this group

§updated_at: u64

An epoch in nanoseconds of when this group was set on the device

§

EchoRequest

Request an arbitrary payload be echoed back

Causes the device to transmit an Message::EchoResponse message.

Message type 58

Fields

§payload: EchoPayload
§

EchoResponse

Response to Message::EchoRequest message.

Echo response with payload sent in the EchoRequest.

Message type 59

Fields

§payload: EchoPayload
§

LightGet

Sent by a client to obtain the light state.

Causes the device to transmit a Message::LightState message.

Note: this message is also known as GetColor in the LIFX docs. Message type 101

§

LightSetColor

Sent by a client to change the light state.

If the Frame Address res_required field is set to one (1) then the device will transmit a State message.

Message type 102

Fields

§reserved: u8
§color: HSBK

Color in HSBK

§duration: u32

Color transition time in milliseconds

§

SetWaveform

Apply an effect to the bulb.

Message type 103

Fields

§reserved: u8
§transient: bool
§color: HSBK
§period: u32

Duration of a cycle in milliseconds

§cycles: f32

Number of cycles

§skew_ratio: i16

Waveform Skew, [-32768, 32767] scaled to [0, 1].

§waveform: Waveform

Waveform to use for transition.

§

LightState

Sent by a device to provide the current light state.

This message is sent in reply to Message::LightGet, Message::LightSetColor, Message::SetWaveform, and Message::SetWaveformOptional

Message type 107

Fields

§color: HSBK
§reserved: i16
§power: u16

The current power level of the device

§label: LifxString

The current label on the device

§reserved2: u64
§

LightGetPower

Sent by a client to obtain the power level

Causes the device to transmit a Message::LightStatePower message.

Message type 116

§

LightSetPower

Sent by a client to change the light power level.

The duration is the power level transition time in milliseconds.

If the Frame Address res_required field is set to one (1) then the device will transmit a StatePower message.

Message type 117

Fields

§level: u16
§duration: u32
§

LightStatePower

Sent by a device to provide the current power level.

Message type 118

Fields

§level: u16
§

SetWaveformOptional

Apply an effect to the bulb.

Message type 119

Fields

§reserved: u8
§transient: bool
§color: HSBK
§period: u32

Duration of a cycle in milliseconds

§cycles: f32

Number of cycles

§skew_ratio: i16
§waveform: Waveform
§set_hue: bool
§set_saturation: bool
§set_brightness: bool
§set_kelvin: bool
§

LightGetInfrared

Gets the current maximum power level of the Infrared channel

Message type 120

§

LightStateInfrared

Indicates the current maximum setting for the infrared channel.

Message type 121

Fields

§brightness: u16
§

LightSetInfrared

Set the current maximum brightness for the infrared channel.

Message type 122

Fields

§brightness: u16
§

LightGetHevCycle

Get the state of the HEV LEDs on the device

Causes the device to transmite a [Messages::LightStateHevCycle] message.

This message requires the device has the hev capability

Message type 142

§

LightSetHevCycle

Message type 143

Fields

§enable: bool

Set this to false to turn off the cycle and true to start the cycle

§duration: u32

The duration, in seconds that the cycle should last for

A value of 0 will use the default duration set by SetHevCycleConfiguration (146).

§

LightStateHevCycle

Whether a HEV cycle is running on the device

Message type 144

Fields

§duration: u32

The duration, in seconds, this cycle was set to

§remaining: u32

The duration, in seconds, remaining in this cycle

§last_power: bool

The power state before the HEV cycle started, which will be the power state once the cycle completes.

This is only relevant if remaining is larger than 0.

§

LightGetHevCycleConfiguration

Getthe default configuration for using the HEV LEDs on the device

This message requires the device has the hev capability

Message type 145

§

LightSetHevCycleConfiguration

Message type 146

Fields

§indication: bool
§duration: u32
§

LightStateHevCycleConfiguration

Message type 147

Fields

§indication: bool
§duration: u32
§

LightGetLastHevCycleResult

Message type 148

§

LightStateLastHevCycleResult

Message type 149

Fields

§

SetColorZones

This message is used for changing the color of either a single or multiple zones. The changes are stored in a buffer and are only applied once a message with either ApplicationRequest::Apply or ApplicationRequest::ApplyOnly set.

Message type 501

Fields

§start_index: u8
§end_index: u8
§color: HSBK
§duration: u32
§

GetColorZones

GetColorZones is used to request the zone colors for a range of zones.

The bulb will respond with either Message::StateZone or Message::StateMultiZone messages as required to cover the requested range. The bulb may send state messages that cover more than the requested zones. Any zones outside the requested indexes will still contain valid values at the time the message was sent.

Message type 502

Fields

§start_index: u8
§end_index: u8
§

StateZone

The StateZone message represents the state of a single zone with the index field indicating which zone is represented. The count field contains the count of the total number of zones available on the device.

Message type 503

Fields

§count: u8
§index: u8
§color: HSBK
§

StateMultiZone

The StateMultiZone message represents the state of eight consecutive zones in a single message. As in the StateZone message the count field represents the count of the total number of zones available on the device. In this message the index field represents the index of color0 and the rest of the colors are the consecutive zones thus the index of the color_n zone will be index + n.

Message type 506

Fields

§count: u8
§index: u8
§color0: HSBK
§color1: HSBK
§color2: HSBK
§color3: HSBK
§color4: HSBK
§color5: HSBK
§color6: HSBK
§color7: HSBK
§

GetMultiZoneEffect

Message type 507

§

SetMultiZoneEffect

Message type 508

Fields

§instance_id: u32

The unique value identifying this effect

§reserved: u16
§speed: u32

The time it takes for one cycle of the effect in milliseconds

§duration: u64

The amount of time left in the current effect in nanoseconds

§reserved7: u32
§reserved8: u32
§parameters: [u32; 8]

The parameters that was used in the request.

§

StateMultiZoneEffect

Message type 509

Fields

§instance_id: u32

The unique value identifying this effect

§reserved: u16
§speed: u32

The time it takes for one cycle of the effect in milliseconds

§duration: u64

The amount of time left in the current effect in nanoseconds

§reserved7: u32
§reserved8: u32
§parameters: [u32; 8]

The parameters that was used in the request.

§

SetExtendedColorZones

Message type 510

Fields

§duration: u32
§zone_index: u16
§colors_count: u8
§colors: Box<[HSBK; 82]>
§

GetExtendedColorZone

Message type 511

§

StateExtendedColorZones

Message type 512

Fields

§zones_count: u16
§zone_index: u16
§colors_count: u8
§colors: Box<[HSBK; 82]>
§

RelayGetPower

Get the power state of a relay

This requires the device has the relays capability.

Message type 816

Fields

§relay_index: u8

The relay on the switch starting from 0

§

RelaySetPower

Message ty 817

Fields

§relay_index: u8

The relay on the switch starting from 0

§level: u16

The value of the relay

Current models of the LIFX switch do not have dimming capability, so the two valid values are 0 for off and 65535 for on.

§

RelayStatePower

The state of the device relay

Message type 818

Fields

§relay_index: u8

The relay on the switch starting from 0

§level: u16

The value of the relay

Current models of the LIFX switch do not have dimming capability, so the two valid values are 0 for off and 65535 for on.

Implementations§

Source§

impl Message

Source

pub fn get_num(&self) -> u16

Get the message type

This will be used in the typ field of the ProtocolHeader.

Source

pub fn from_raw(msg: &RawMessage) -> Result<Message, Error>

Tries to parse the payload in a RawMessage, based on its message type.

Trait Implementations§

Source§

impl Clone for Message

Source§

fn clone(&self) -> Message

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Message

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Message

Source§

fn eq(&self, other: &Message) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Message

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.