That being said, the first thing I did was use a BTLE utility app to connect to the lamps and find where it stored the relevant info: RGB values, white led brightness value, on/off and modes etc.
The picture shows these values which are as of now the only ones I care about. I got the adafruit sniffer too and I have all the info on the various modes recorded into a file so I can play with those later.
I copied the relevant service and characteristic UUIDs into one of the example sketches for the ESP32/Arduino board and successfully connected to the lamp and sent it the string the sketch generates, causing it to flash wildly(great success).
Basically I need to send an array of 20 bytes that looks like what is shown in the app screenshot and I don't know how to do it:
02:f9:f9:f9:f9:00:00:00:00:00:00:00:00:00:00:00:00:01:00:00 -- On
or
32:f9:f9:f9:f9:00:00:00:00:00:00:00:00:00:00:00:00:01:00:00 -- Off
02 and 32 are the codes for on/off, respectively.
Here is the code for the example:
https://pastebin.com/KQABJ82d
Here is the relevant part of the code where the value is sent to the lamp:
Code: Select all
// If we are connected to a peer BLE Server, update the characteristic each time we are reached
// with the current time since boot.
if (connected) {
String newValue = "Time since boot: " + String(millis()/1000);
Serial.println("Setting new characteristic value to \"" + newValue + "\"");
// Set the characteristic's value to be the array of bytes that is actually a string.
pRemoteCharacteristic->writeValue(newValue.c_str(), newValue.length());
}
delay(1000); // Delay a second between loops.
I'm stuck here.