• OK - does not work for me either.

    I have not hardcoded the MAC but search for devices with the corresponding service:

    function setLight( r, g, b ) {
      var gatt;
      var c;
    
      console.log( "rgb=", r, g, b );
      NRF.requestDevice(
        {filters:[{services:["FF02"]}]}
      ).then( dev=>{
        console.log( "found", dev.name );
        return dev.gatt.connect();
      }).then( g => {
        console.log( "connected" );
        gatt = g;
        return gatt.getPrimaryService("FF02");
      }).then(function(service) {
        console.log( "service found" );
        return service.getCharacteristic("FFFC");
      }).then(function(characteristic) {
        console.log( "characteristic found" );
        c = characteristic;
        return c.readValue();
      }).then( v => {
        console.log( "value", v );
        return c.writeValue(String.fromCharCode(0,r,g,b­));
      }).then( r => {
        console.log( "result", r );
        gatt.disconnect();
        console.log("Done!");
      });
    }
    
    
    var col = 1;
    
    setWatch(
      evt => {
        var long = ( evt.time - evt.lastTime ) > 0.2;
        if( long ) {
          setLight( 0, 0, 0 );
        }
        else {
          col++;
          if( col > 7 ) col = 1;
    
          console.log( "col", col );
          setLight( 
            col & 1 ? 0xFF : 0, 
            col & 2 ? 0xFF : 0,
            col & 4 ? 0xFF : 0
          );
        }
      },
      BTN,
      { edge: "falling", debounce: 50, repeat: true } 
    );
    

    readValue()correctly returns the 4 bytes (white-red-green-blue) I have written with LightBlue to Service FF02 / Characteristic FFFC before.

    But writeValue()does not do or return anything.

    @Gordon: You are right. LightBlue shows WriteWithoutResponse for the Characteristic in question by the way.

    Is that something the puck BLE code does not handle yet?


    2 Attachments

    • IMG_8475.PNG
    • IMG_8474.PNG
About

Avatar for ChristianW @ChristianW started