You are reading a single comment by @ayoganandan1984 and its replies. Click here to read the full conversation.
  • Hello,

    I have hooked up a button to my puck.js and emulating HID keyboard clicks on the button press. It works fine for the most part, except once in a few times, it misses sending a key press over with the a 'BLE HID already sending' error.

    error messageBLE HID already sending
    error messageBLE HID already sending
    Uncaught Error: BLE HID already sending
    at line 1 col 55


    in function called from system

    Looks like some of them get past the try-catch but others don't.

    This happens even if I'm doing these button presses slowly, so it is not an issue of too many button presses going through in a short time frame. Does the port need to be flushed or something?

    I tried upgrading to 2v02.6 cutting edge firmware, but the problem still exists.

    The essence of my code can be found below.

    var kb = require("ble_hid_keyboard");
    NRF.setServices(undefined, { hid : });
    var lastButtonState = 0;
    var busy = 0;
    function on_button_pressed() {
      var currentButtonState = digitalRead(D28);
      if ( currentButtonState === 0) {
      else if (currentButtonState === 1) {
      if(lastButtonState !== currentButtonState){
          digitalWrite(LED2, 1);
          lastButtonState = currentButtonState;
                busy = 1;
                if(lastButtonState === 0){
                  kb.tap(kb.KEY.B, 0, function(){});
                }else if(lastButtonState === 1){
                  kb.tap(kb.KEY.A, 0, function(){});
                busy = 0;
            console.log("error message " + err.message);
            busy = 0;
          digitalWrite(LED2, 0);
    setInterval(function() {
    }, 5);