You are reading a single comment by @furuskog and its replies. Click here to read the full conversation.
  • Finally some success

    var currentSevice = false;
    
    function getData() {
      var gatt;
      NRF.connect("C4:7C:8D:62:0D:5A").then(function(g) {
        gatt = g;
        return gatt.getPrimaryService("00001204-0000-1000-8000-00805f9b34fb");
      })
      .then(function(service) {
        currentService = service;
        return service.getCharacteristic("00001a00-0000-1000-8000-00805f9b34fb");
     })
     .then(function(characteristic) {
         return characteristic.writeValue([0xa0, 0x1f]);
     })
     .then(() => {
         return currentService.getCharacteristic("00001a01-0000-1000-8000-00805f9b34fb");
     })
     .then((characteristic) => {
        return characteristic.readValue();
     })
     .then(function(value) {
       console.log(value);
       gatt.disconnect();
       console.log("Done!");
     })
       .catch(function(error){
         console.log("error", error);
       });
    }
    
    setWatch(function() {
      getData();
    }, BTN, { repeat:true, edge:"rising", debounce:50 });
    

    Output

    DataView {
      "buffer": new ArrayBuffer([207, 0, 0, 209, 12, 0, 0, 24, 124, 1, 2, 60, 0, 251, 52, 155])
       }
    

    Next is to format the values but I save that for this weekend :)

About

Avatar for furuskog @furuskog started