Skip to content

Commit

Permalink
Handle intermediate values between POWER_STATE_ON and OFF from the bulbs
Browse files Browse the repository at this point in the history
It's supposed to be 0xffff or 0 but that's actually not true.
  • Loading branch information
lopter committed Aug 8, 2015
1 parent be1bb5d commit da9c1bb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lifx/wire_proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,16 +342,22 @@ lgtd_lifx_wire_decode_light_status(struct lgtd_lifx_packet_light_status *pkt)
pkt->brightness = le16toh(pkt->brightness);
pkt->kelvin = le16toh(pkt->kelvin);
pkt->dim = le16toh(pkt->dim);
pkt->power = le16toh(pkt->power);
// The bulbs actually return power values between 0 and 0xffff, not sure
// what the intermediate values mean, let's pull them down to 0:
if (pkt->power != LGTD_LIFX_POWER_ON) {
pkt->power = LGTD_LIFX_POWER_OFF;
}
pkt->tags = le64toh(pkt->tags);
}

void
lgtd_lifx_wire_decode_power_state(struct lgtd_lifx_packet_power_state *pkt)
{
(void)pkt;

assert(pkt);

if (pkt->power != LGTD_LIFX_POWER_ON) {
pkt->power = LGTD_LIFX_POWER_OFF;
}
}

void
Expand Down

0 comments on commit da9c1bb

Please sign in to comment.