pub enum Message {
Show 59 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,
StateMultiZoneEffect {
instance_id: u32,
typ: MultiZoneEffectType,
reserved: u16,
speed: u32,
duration: u64,
reserved7: u32,
reserved8: u32,
parameters: [u8; 32],
},
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
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.
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
GetHostInfo
Get Host MCU information. No payload is required. Causes the device to transmit a Message::StateHostInfo message.
Message type 12
StateHostInfo
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
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
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
StateWifiInfo - 17
Response to Message::GetWifiInfo message.
Provides Wifi subsystem information.
Message type 17
GetWifiFirmware
Get Wifi subsystem firmware
Causes the device to transmit a Message::StateWifiFirmware message.
Message type 18
StateWifiFirmware
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
SetPower
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.
Set device power level.
Message type 21
StatePower
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
SetLabel
Fields
label: LifxString
Set the device label text.
Message type 24
StateLabel
Fields
label: LifxString
GetVersion
Get the hardware version
Causes the device to transmit a Message::StateVersion message.
Message type 32
StateVersion
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
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
GetInfo
Get run-time information
Causes the device to transmit a Message::StateInfo message.
Message type 34
StateInfo
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
Fields
seq: u8
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
GetLocation
Ask the bulb to return its location information
Causes the device to transmit a Message::StateLocation message.
Message type 48
SetLocation
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
Set the device location
Message type 49
StateLocation
Device location.
Message type 50
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
StateGroup
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
Device group.
Message type 53
EchoRequest
Fields
payload: EchoPayload
Request an arbitrary payload be echoed back
Causes the device to transmit an Message::EchoResponse message.
Message type 58
EchoResponse
Fields
payload: EchoPayload
Response to Message::EchoRequest message.
Echo response with payload sent in the EchoRequest.
Message type 59
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
SetWaveform
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.
Apply an effect to the bulb.
Message type 103
LightState
Fields
color: HSBK
reserved: i16
power: u16
The current power level of the device
label: LifxString
The current label on the device
reserved2: u64
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
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
LightStatePower
Fields
level: u16
Sent by a device to provide the current power level.
Message type 118
SetWaveformOptional
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
Apply an effect to the bulb.
Message type 119
LightGetInfrared
Gets the current maximum power level of the Infrared channel
Message type 120
LightStateInfrared
Fields
brightness: u16
Indicates the current maximum setting for the infrared channel.
Message type 121
LightSetInfrared
Fields
brightness: u16
Set the current maximum brightness for the infrared channel.
Message type 122
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
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).
Message type 143
LightStateHevCycle
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.
Whether a HEV cycle is running on the device
Message type 144
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
LightStateHevCycleConfiguration
Message type 147
LightGetLastHevCycleResult
Message type 148
LightStateLastHevCycleResult
Fields
result: LastHevCycleResult
Message type 149
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
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
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
StateMultiZone
Fields
count: u8
index: u8
color0: HSBK
color1: HSBK
color2: HSBK
color3: HSBK
color4: HSBK
color5: HSBK
color6: HSBK
color7: HSBK
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
GetMultiZoneEffect
Message type 507
StateMultiZoneEffect
Fields
instance_id: u32
The unique value identifying this effect
typ: MultiZoneEffectType
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
Message type 509
GetExtendedColorZone
Message type 511
StateExtendedColorZones
Message type 512
RelayGetPower
Fields
relay_index: u8
The relay on the switch starting from 0
Get the power state of a relay
This requires the device has the relays
capability.
Message type 816
RelaySetPower
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.
Message ty 817
RelayStatePower
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.
The state of the device relay
Message type 818
Implementations
sourceimpl Message
impl Message
sourcepub fn get_num(&self) -> u16
pub fn get_num(&self) -> u16
Get the message type
This will be used in the typ
field of the ProtocolHeader.
sourcepub fn from_raw(msg: &RawMessage) -> Result<Message, Error>
pub fn from_raw(msg: &RawMessage) -> Result<Message, Error>
Tries to parse the payload in a RawMessage, based on its message type.
Trait Implementations
impl StructuralPartialEq for Message
Auto Trait Implementations
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more