Discovery LIFX LAN Android

Hi guys,

I am developing an Android app and I want to be able to control my lightbulbs in there. Since the SDK is not supported anymore, I am trying to connect to each bulbs through LAN.
I am currently at this point, and I alway get a SocketTimeoutException:

My problem comes from the sendDiscoveryRequest(), I don’t what to put as “data” value …

How can I do to integrate the GetService methode in Java ? Considering the followed documentation:

Any help would be great :slight_smile:


Probably your packet data is wrong. See this topic
Also you make wrong byte conversion from a string. Check this out
You can dump the array into the string back to check the packet content.

Also I noticed that to receive StateService response frame source in the request should be non zero:

24 00 00 34 BE BA FE C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 02 00 00 00

Which is:

Frame {
FrameAddress {
ProtocolHeader {
Payload = GetService {}

I believe that the getBytes() method on the string object returns the ascii data from the string. So in this case you are sending that exact string as ascii encoded bytes.

What you really want to be sending is the binary data that that string represents. So something along the lines of this Stack Overflow post.

That makes a good starting point of course, but for a full implementation it’d be much better to assemble the packets manually from scratch, rather than strings.

Hi! We’re maintaining a LIFX SDK for Android here:

Let us know if you have any questions.


Hi all and thanks,

unfortunately I didn’t succeed to implement the LAN discovery … I don’t know what’s wrong with my packet data… I someone know or have an example in java it could definitely help me ! :slight_smile:
I am not familiar with packets so i’m kind of stuck here.

So I use for now the sdk provide by @lars.senic but I’ve got some probs. Maybe Lars could help :slight_smile:

  • I lost the connection regularly
  • For the intensity, I have play with the “brightness” value, is there a more efficient way to deal with it ? Because currently it is not smooth at all and I would like to have something very responsive like in the LIFX default app for instance

Thanks all by avance

@mathildegui Please post in the github repository issues page if you want support with the library.