• Hi,

    I have the same error as the topic starter, not sure if my problem is related, I'm rather new to Espruino/BLE so it may be a "user error".

    Here's my code, and the output it produces. It seems to run OK until the point when Notifications are enabled:

    var d;
    var out="";
    
    function getData(){
      print("Getting data now");
      g.drawString("Getting data now",0,60);
        NRF.connect("A4:C1:38:4E:75:A0 public").then(function(device) {
          print("Device connected:",device.device.id);
          out=device.device.id;
          g.drawString(out,0,80);
          d=device;
          return d.getPrimaryService("EBE0CCB0-7A0A-4B0C-­8A1A-6FF2997DA3A6");
        }).then(function(s) {
          out=s.uuid;
          g.drawString(out,0,105);
          if(s) { print("Service:",s.uuid); }
          else { print("S-error"); }
          return s.getCharacteristic("EBE0CCC1-7A0A-4B0C-­8A1A-6FF2997DA3A6");
        }).then(function(c) {
          print("Characteristic:",c.uuid);
          print("C:",c);
          out=c.uuid;
          g.drawString(out,0,130);
          c.on('characteristicvaluechanged', function(event) {
            buf =E.toString(event.target.value.buffer);
            g.drawString(buf,0,155);
            print(buf);
            print(event.target.value.buffer);
            // For 26.0 degrees and 54% is like : new Uint8Array([47, 10, 54, 98, 10]).buffer
            b=event.target.value.buffer;
            temp=b[1]*256+b[0];
            hum=b[2];
            print("temp:",temp, " Hum:",hum);
          }); // c.on
          return c.startNotifications();
        }).then(function() {
        console.log("Done!");
    
      });
    } // end getData function
    
    
    
    setWatch(function(){
      print("Bangle setwatch on TOP button activated");
      g.clear();
      g.setFont("Vector",15);
      getData();
    },BTN ,{ repeat:true,debounce:25 }
    );
    
    /*
    WEBIDE OUTPUT
    
                     _
    |  __|___ ___ ___ _ _|_|___ ___
    |  __|_ -| . |  _| | | |   | . |
    |____|___|  _|_| |___|_|_|_|___|
             |_| espruino.com
     2v06 (c) 2019 G.Williams
    >
    Bangle setwatch on TOP button activated
    Getting data now
    Device connected: A4:C1:38:4E:75:A0 public
    Service: ebe0ccb0-7a0a-4b0c-8a1a-6ff2997da3a6
    Characteristic: ebe0ccc1-7a0a-4b0c-8a1a-6ff2997da3a6
    C: BluetoothRemoteGATTCharacteristic: {
      "uuid": "ebe0ccc1-7a0a-4b0c-8a1a-6ff2997da3a6",
      "handle_value": 54, "handle_decl": 53,
      "properties": { "broadcast": false, "read": true, "writeWithoutResponse": false, "write": false,
        "notify": true, "indicate": false, "authenticatedSignedWrites": false }
     }
    Uncaught Error: Unhandled promise rejection: CCCD Handle not found
    > 
    
    */
    

    The NrfConnect output for the Notification is below.

    I know the handle for the notification is 0x0038. When I connect to the device using RPI-gatttool using this handle it starts Notifications immediately.:

    pi@raspberrypi3:~/Mydata/python/Xiaomi $ gatttool -b a4:c1:38:4e:75:a0 --char-write-req --handle='0x0038' --value="0100" --listen
    Characteristic value was written successfully
    Notification handle = 0x0036 value: c5 09 3a 4e 0a 
    Notification handle = 0x0036 value: c4 09 39 4e 0a 
    

    Do I need to specify this handle specifically before using startNotifcations, and if so, how do I do that?

    Any help is welcome.


    1 Attachment

    • Schermafbeelding 2020-08-21 om 20.47.13.png
About

Avatar for gerardwr @gerardwr started