Set PlayBulb Candle Color

Posted on
  • The idea for my first Puck.js project is to use the puck a wall switch to control three BLE lamps ( i have. Based on some other code (­odelabs/candle-bluetooth/index.html) this should be a simple task. So far i can connect, read the current color and set the name of the light. But setting the color doesn't work.

    NRF.connect("bb:df:4b:17:ac:e6").then(fu­nction(gat) {
      console.log("Gat: " + gat);
      gat.getPrimaryService("0xFF02").then(fun­ction(service) {
        console.log("Service: " + service);
        service.getCharacteristic("0xFFFC").then­(function(characteristic) {
          //characteristic.readValue().then(data => {
          //  console.log(typeof data);
          //  console.log(data);
          //  console.log(JSON.stringify(data));
          characteristic.writeValue(new Uint8Array([0x00, 255, 0, 0])).then(function() {
          }).catch(function() {
        }).catch(function() {
      }).catch(function() {
    }).catch(function() {

    No catch block is called but the color of the light does not change. Im not really sure if new Uint8Array([0x00, 255, 0, 0]) is the write type here but 00FF0000 or \x00\xFF\x00\x00 does not work either. When i read the characteristic i get:


    I am thankful for any help or ideas.

  • You could try changing gat.getPrimaryService("0xFF02") to gat.getPrimaryService(0xFF02) (and the same for the characteristic too) - I'm not 100% sure but that might make some difference.

    What you're doing with Uint8Array sounds fine, but then "\x00\xFF\x00\x00" or even just [0,255,0,0] should work as well.

    And if you do the same from an app like nRF connect, you can change the light's colour?

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Set PlayBulb Candle Color

Posted by Avatar for Jan71099 @Jan71099