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:

Thanks
Mathilde

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 {
  size={0x0024}
  origin={00}
  tagged=1
  addressable=1
  protocol={0x0400}
  source={0xC0FEBABE}
}
FrameAddress {
  target={000000000000}
  reserved1={00}{00}{00}{00}{00}{00}
  reserved2=0
  ackRequired=0
  resRequired=1
  sequence={00}
}
ProtocolHeader {
  reserved1={0000000000000000}
  type={0002}
  reserved2={0000}
}
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.

2 Likes

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.