Avatar for Joost


Member since Jul 2018 • Last active May 2019
  • 5 conversations

Most recent activity

  • in Puck.js, Pixl.js and MDBT42
    Avatar for Joost

    Thanks for your suggestion! Could not try it for now due to time constraints, but hoping to do itin the coming days!
    Cheers, Joost

  • in Puck.js, Pixl.js and MDBT42
    Avatar for Joost

    Hi everybody / Gordon,

    thanks for Espruino/Puck/Pixl !!
    Right now I am on a project using Puck.js to interface a (at this point unconnected/unused) steering wheel remote control to an Android tablet.
    Generally, I read the wired remote control with the Puck and then send HID events to the Android tablet.
    What I need is the possibility to send multimedia controls and normal keyboard events during the same connection. Right now it seems to me I have to decide up front (before connecting the puck), which role I want. Is there a way around it and connect in both roles? Preliminary testing did not work for me unfortunately, but I am generally clueless on this ...

    Thanks for any hint,


  • Avatar for Joost


    sorry for opening a new topic again already, but I hope that our notes might help somebody else later on.

    Right now I am connecting like this to my bike sensor:

    NRF.requestDevice({ timeout:5000, filters: [{ services: "0x1816"  /* namePrefix: 'Wahoo' */ }] }).then(function(device) {
      return device.gatt.connect();
      }).then(function(gatt_object) {
        gatt = gatt_object;
        s = "Looking for service...";
        g.clear(); g.drawString(s ,0 ,0); g.flip();
        return gatt.getPrimaryService("1816");
        }).then(function(service) {
          s = "Looking for char...";
          g.clear(); g.drawString(s ,0 ,0); g.flip();
          return service.getCharacteristic("0x2A5B");
        }).then(function(characteristic) {
          characteristic.on('characteristicvaluech­anged', OnNotify);
          return characteristic.startNotifications();
          }).then(function() {
            connected = true;
            t = getTime();
            gatt.device.on('gattserverdisconnected',­ function(reason) {console.log("gattserverdisconnected, Grund: "+ reason+" Zeit: " + (getTime() -t) + " sec"); disconnect(reason);} ); 

    Initially, I even had a timeout of 20 seconds in requestDevice, which led to pretty unreliable connection intitation.
    With nrfConnect I see that the sensor starts advertising really fast with an interval of 330ms initially.
    I wonder if it is possible to cut the timeout short (right now it seems that the code scans for the full timeout before handing back scan results) and return a matching device immediately?

    Or is it preferable to cache the sensor's address and do a direct connect to that later on? That would have the (very small) drawback of needing additional logic to do a full scan if the previous/cached device is not successfully connected, to enable connecting to new/other sensors.



  • Avatar for Joost

    Thank you both,

    this works great it seems:

    gatt.device.on('gattserverdisconnected',­ function(reason) {console.log("gattserverdisconnected, Grund: "+ reason+" Zeit: " + (getTime() -t) + " sec"); disconnect(reason);} ); 

    with variable t being set earlier upon successful connect.

    with reason 8 triggered when the BLE server (my sensor) goes out of reach (loss of reception) and reason (int) 19 gets triggered when the sensor shuts down due to inactivity.

    Thanks again,


  • Avatar for Joost

    Hi everybody,

    I'm wondering if there is a callback of some sort if/when the espruino device loses connection to a BLE sensor, when subscribed to it's notifications?

    Otherwise I would reset a timer upon reception of every notification, and check say every 15 seconds if the timer was reset (meaning notifications were still received), and disconnect if not.

    What do you think?

    Thanks, Joost