• Yeah - your other comment about bonding from the neighbor thread did the trick.

    This is working now:

    var gatt;
    
    function onInit() {
    
      NRF.requestDevice({
        filters: [{namePrefix: "AB"}]
      }).then((device)=> {
        console.log("FOUND", device.id, device.name);
        return device.gatt.connect();
      }).then((device)=>{
        gatt = device;
        console.log("CONNECTED", device);
        return gatt.startBonding();
      }).then(function() {
        console.log("BONDED", gatt.getSecurityStatus());
        return gatt.getPrimaryService(0x1812);
      }).then((service)=>{
        console.log("SERVICE", service);
        return service.getCharacteristic(0x2a4d);
      }).then((char)=>{
        console.log("CHAR", char);
        char.on("characteristicvaluechanged",(e)=>{
          console.log("EVENT", e.target.value);
        });
        return char.startNotifications();
      }).then(()=>{
        console.log("DONE");
        return true;
      }).catch((err)=>{
        console.log("ERROR", err);
      });
    }
    
    onInit();
    

    For a button press I get:

    EVENT DataView: {
      "buffer": new Uint8Array([2, 0]).buffer,
      "byteOffset": 0, "byteLength": 2 }
    

    and for a release:

    EVENT DataView: {
      "buffer": new ArrayBuffer(2),
      "byteOffset": 0, "byteLength": 2 }
    

    The only thing is that when I pull the power from Espruino the bonding seems to be lost and the blue LED on the remote begins flashing again.

    This does not happen when bonded to Laptop/Phone. Maybe it's about the whitelisting.

    But I could live with that.
    Thanks @Gordon for the hint!

About

Avatar for ChristianW @ChristianW started