Micro:bit BLE HID Keyboards more keystroke

Posted on
  • Hi!
    I noticed that, using the example code of Bluetooth LE HID Keyboards (here), if i write

    kb.tap(kb.KEY.A,0);
    kb.tap(kb.KEY.N,0);
    

    the micro:bit send only the first letter (a).

    Is there a workaround or somthing to do to allow the board to send more letters?

    Thanks!

  • Hi - you need to send multiple keys like is shown in the example you linked https://www.espruino.com/BLE+Keyboard

    function btnPressed() {
      // Send 'a'
      kb.tap(kb.KEY.A, 0, function() {
        // Followed by capital 'A'
        kb.tap(kb.KEY.N, 0);
      });
    }
    

    Sending the keypress takes time - it has to send 'keydown' followed by 'keyup'. It returns immediately and then calls the function in the third argument when finished. You can't just send multiple taps in commands one after the other

  • @Gordon can this even work on microbit? the sendHIDReport https://github.com/espruino/Espruino/blob/master/libs/bluetooth/jswrap_bluetooth.c#L2471 is marked "ifdef" : "NRF52_SERIES" and the https://www.espruino.com/modules/ble_hid_keyboard.js uses it.

  • I think it's micro:bit 2 most likely :) micro:bit 2 is an nRF52833

  • oh, ok, sorry, was thinking v1 due to uart overflow in the other thread http://forum.espruino.com/conversations/369059/ but now I see yet another thread created by @coat with V2 in name

  • Hi - you need to send multiple keys like is shown in the example you linked

    Hi @Gordon and thank you very much.
    I saw the example, but I was looking for another solution because a keystroke should be sent in a part of the code and another in a different part.
    I imagined that was a problem of time, as you confirmed.
    So I'll try with some other workaround in my code

    oh, ok, sorry, was thinking v1 due to uart overflow in the other thread http://forum.espruino.com/conversations/­369059/ but now I see yet another thread created by @coat with V2 in name

    @fanoush yes, mine is micro:bit v2. I was not precise in my request, I'm sorry and thank you for your help. I really don't know what UART_OVERFLOW error wants from me

    I'm still receiving also this error (or similar) when finally I flash the code

    Uncaught Error: Not connected!
     at line 1 col 104
    ...0,0,0],function(){a&&a()})})
                                  ^
    in function "tap" called from line 48 col 36
                      kb.tap(kb.KEY.G,0);
                                       ^
    

    But again I don't know what it means

  • the {a&&a()})} is end of file https://www.espruino.com/modules/ble_hid_keyboard.min.js which is included automatically by require("ble_hid_keyboard"). Somehow the connection is not really working correctly. Maybe updating firmware to latest/different could help.

  • Do you mean the firmware of the micro:bit?
    I think it's update. How can I check?

  • I mean the espruino firmware, you previously had to install some espruino_XXX_microbit2.hex file from https://www.espruino.com/Download Current version is shown in bottom right corner when you connect via WebIDE or via typing process.env or process.version on left side. If you installed some cutting edge version you might hit some buggy version.

  • I mean the espruino firmware, you previously had to install some espruino_XXX_microbit2.hex file from https://www.espruino.com/Download

    Oh yes! I've done this previously.

    Current version is shown in bottom right corner when you connect via WebIDE or via typing process.env or process.version on left side

    I read 2v10.113
    In download page I see espruino_2v10_microbit2.hex and espruino_2v10.142_microbit2.hex as Cutting Edge build.

    Is it possible that I have installed the previous Cutting Edge Version (113) instead of 2V10?

  • Is it possible that I have installed the previous Cutting Edge Version (113) instead of 2V10?

    yes, 2.10 release has no extra version, should say just 2.10 (I hope). So try different, the 2.10 or latest cutting edge.

  • No way.
    I tried 2v10 and 2v10.142 but nothing changed.
    Still have the error

    Uncaught Error: Not connected!
     at line 1 col 104
    ...0,0,0],function(){a&&a()})})
                                  ^
    in function "tap" called from line 8 col 25
          kb.tap(kb.KEY.A, 0);
                            ^
    in function called from system
    

    Anyway, the code is working, as before, with no problem

  • well at least the overflow could be hopefully gone. The error you have is "Not connected!" so nothing is connected to your microbit as HID keyboard I guess.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Micro:bit BLE HID Keyboards more keystroke

Posted by Avatar for coat @coat

Actions