Hello @giovanni!
I also struggle with the same issue - I want to create homebridge integration for Pesetech Skylight lamps, but without any documentation it is difficult to make the connection and set some colours or brightness.
I contacted manufacturer asking for API documentation or at least their BLE protocol description, but they replied me they cannot share any of it. They are not even into fixing their own app (it noticed it doesn’t handle summer time transition properly!), so I don’t think they are up to add any home integration (cc: @Ateus). So fck them. I did some investigation on my own and I’ll share you my findings.
API Connection
I connected the lamps to their official iOS app using guest 2.4 GHz wi-fi network. I was able to control the lamps and ProxyMan working in the background showed me HTTP requests very nicely
Basically the lights are controlled through API hosted on http://service.lepuiot[.]com
. Just note that Pesetech’s official name is “Shenzhen Lepu Lighting Technology Co.,Ltd”, so Lepu API is their own service.
Here you can see example data of with single lamp unit, especially take a look on extendJson
value:
BLE connection
But I’m really not into opening my local network traffic for any of the Chinese companies, and I still need to implement a good integration, so I decided to go harder way and try with Bluetooth.
First, I turned off my guest wi-fi network. I observed that despite of this fact, I could still control lamps in the app! Connection error messages were displayed as soon as I change emission colour, but lamps still got updated in realtime, which suggested me that there is paired and working Bluetooth connection.
So, following great NovelBits tutorial, I installed Bluetooth Profile and using Xcode PacketLogger I got a tons of pretty readable bluetooth packets! But they are still very unclear and guessing the meaning of specific bytes with try-and-compare method would take ages.
So using koying suggestion, I downloaded Pesetech apk from apkcombo[.]com and de-obfuscated it using brilliant jadx tool and it was it!
jadx decompiled classes, and because they were not very obfuscated, I got pretty readable Java code with meaningful names. Remember mentioning Lepu services? Their main lib is called lepu.smart
and it is the place where magic happens. Short search and I found function responsible for sending colour to the lamp. You can even see original Chinese log informing developer about changing rgb parameter.
private void sendRgb(int[] iArr) {
String str = "A06904" + SendCommand.toHex(iArr[0], 2) + SendCommand.toHex(iArr[1], 2) + SendCommand.toHex(iArr[2], 2) + SendCommand.toHex(100, 2);
Log.i(getClass().getName(), "发送rgb参数" + str);
this.bleConnect.sendData(Utils.hexToByteArray(str), 0);
}
Next steps
So now it is a great starting point! If you are still up to decoding the communication and getting working BLE commands, we can join the forces and try to take a look on it together