wolfeidau / lifx

Minimal lifx api for go
https://github.com/wolfeidau/lifx
MIT License
20 stars 4 forks source link

LIFX protocol v2 #13

Open pdf opened 9 years ago

pdf commented 9 years ago

By the looks this doesn't implement the v2 proto documented here?

wolfeidau commented 9 years ago

This does support the v2 lifx but was written before those docs were released.

I plan to sit down with one of the devs from lifx and do a new version possibly using code generation to make it easier to modify.

Cheers

pdf commented 9 years ago

Ah, gotcha. I'll have a bit of a closer read. I'd just started writing a lib myself before I found this, my thinking was along the lines of splitting the protocol stuff out to separate namespaces, with the client abstracting them away and allowing the user to select a protocol version when instantiating the client.

Code generation would definitely be optimal, in that respect it's a shame they decided against protobuf in the end, but that might have been a perf thing. I thought most of the LIFX guys were in the States now?

In the mean time, I've done a little testing, and I don't seem to be getting good reliability out of this lib right now - discovery finds all the 'gateways' (which are actually bulbs now), but the bulbs don't get populated on the client unless some other packet happens to arrive (I've not looked at this yet). The result is that bulbs take a long time to show up, if they show up at all - I get about 50% of mine showing up after a few minutes.

pdf commented 9 years ago

So, I went ahead and wrote a lib based on the docs. The protocol implementation still needs documentation and testing, but it's not in bad shape, and it's abstracted from the client so that if there's another protocol version released, that can be implemented with minimal effect on the public interface, and the user can choose which protocol version to use at run-time. Currently the lib only exposes a synchronous API (with timeouts and retries), I may add an event-based API at a later date (this would clean up a couple of loops in the client too).

wolfeidau commented 9 years ago

Yeah cool hopefully i will get some time soon to do something similar.