Was using the Happylighting application on android and I try to make a simple web application to control the led color, but can't figure how to do it, and witch 'gatt' I've to request, I'm really new to bluetooth thing.
UPDATED I know with service is available thanks to a android sniffer
const service = "0000ffd5-0000-1000-8000-00805f9b34fb"
const characteristic = "0000ffd9-0000-1000-8000-00805f9b34fb"
function onRequestBluetoothDeviceButtonClick() {
navigator.bluetooth.requestDevice({
filters: [{name:"QHM-0A0B"}],
optionalServices: [service],
})
.then(device => {
return device.gatt.connect()
}).then(server =>{
return server.getPrimaryService(service);
}).then(service =>{
return service.getCharacteristics(characteristic);
}).then(characteristic=>{
let colorArray = Uint8Array.from([86, 0, 255, 0, 25, 240, 170]);
return characteristic[0].writeValue(colorArray);
}).then(()=>{
console.log("Send")
})
.catch(error => {
console.log('Argh! ' + error);
});
}
But I don't figure what's next to send data to this and what is byte array mentionned in the git repo
You already have the relevant UUID of the characteristic to write to from the github repository you posted in the comments. The repository also tells us how to compose the data to send using the colors we want.
These are the relevant lines:
print("RED: ")
red = int(input())
print("GREEN: ")
green = int(input())
print("BLUE: ")
blue = int(input())
lista = [86, red, green, blue, (int(10 * 255 / 100) & 0xFF), 256-16, 256-86]
values = bytearray(lista)
values will then be written to the device. So if we wanted to set the color green, our lista would contain the values red = 0, green = 255 and blue = 0 and look like this:
[86, 0, 255, 0, 25, 240, 170] or 5600FF0019F0AA in hex.
In fact, only the second, third and fourth number will need to change to a value between 0 and 255 if we want different colors.
Now to start setting the color on your LED device please always start using a generic BLE scanner tool like nRF Connect to test the connection before attempting to write something yourself. When scanning using the tool you should be able to find your led device and connect to it. After scanning the services you should find a characteristic with the UUID 0000ffd9-0000-1000-8000-00805f9b34fb. Write the value 5600FF0019F0AA to it and see if your device turns green.
Now that this is working and you understand how to compose the data you can start working on your own code.