• Hi, sorry for hijacking the thread, but..

    I am having similar problem with the BLE, where i have disconnected from the puck, removed the battery and inserted it again, etc.

    What i'm basically is trying to do is a hold-button and release after ½ second.
    Since this isnt inlcuded in the "ble_hid_keyboard" library, i created my own based upon "tap" function in said library.(1)

    
    var keydown = function(keyCode, modifiers, callback) {
      NRF.sendHIDReport([modifiers,0,keyCode,0,0,0,0,0], function() {
        if (callback) callback();
      });
    };
    
    var keyrelease = function(keyCode, modifiers, callback) {
      NRF.sendHIDReport([0,0,0,0,0,0,0,0], function() {
        if (callback) callback();
      });
    };
    // ......
    
    var kb = require("ble_hid_keyboard");
    NRF.setServices(undefined, { hid : kb.report });
    
    function btnPressed() {
      ledBlink();
    //  kb.tap(kb.KEY.A, 0, function() {});
      keydown(kb.KEY.F12);
    }
    
    // trigger btnPressed whenever the button is pressed
    setWatch(btnPressed, BTN, {edge:"rising",repeat:true,debounce:50});
    
    function ledBlink() {
      LED1.write(true);
      setTimeout(function() {
        LED1.write(false);
        keyrelease();
      }, 500);
    
    }
    enter code here
    

    the error i get back is "Uncaught Error: BLE HID not enabled"
    is there a way to check if it is in BLE HID mode before trying to do anything, so ie. i can restart the puck or light up a led to tell me that it isnt ready (besides catching said error in a try-catch)?

    [1]

About

Avatar for Deas @Deas started