Avatar for Jan71099

Jan71099

Member since Dec 2016 • Last active Dec 2016
  • 1 conversations
  • 1 comments

Most recent activity

    • 2 comments
    • 1,822 views
  • in Puck.js, Pixl.js and MDBT42
    Avatar for Jan71099

    The idea for my first Puck.js project is to use the puck a wall switch to control three BLE lamps (https://www.amazon.de/dp/B00PB4VXDS) i have. Based on some other code (https://codelabs.developers.google.com/c­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) {
          console.log(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() {
            console.log("Hit!!!");
          }).catch(function() {
            console.log("4");
          });
    
        }).catch(function() {
          console.log("3");
        });
    
      }).catch(function() {
        console.log("2");
      });
    
    }).catch(function() {
      console.log("1");
    });
    

    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:

    string
    ÿ
    "\x00\x18\x98\xFF"
    

    I am thankful for any help or ideas.

Actions