-
• #2
One additional piece of info. I tested this while connected bluetooth to my mac, everything worked without error. This only occurs when puck is connected to raspberry pi.
I also used a much simpler codevar kb = require("ble_hid_keyboard"); NRF.setServices(undefined, { hid : kb.report }); function btnPressed() { // Send 'a' kb.tap(kb.KEY.A, 0, function() { // Followed by capital 'A' kb.tap(kb.KEY.A, kb.MODIFY.SHIFT); }); } // trigger btnPressed whenever the button is pressed setWatch(btnPressed, BTN, {edge:"rising",repeat:true,debounce:50});
got the exact same error.
there is something wrong with ble_hid_keyboard on the raspberry pi. -
• #3
replacing tap with
NRF.sendHIDReport([2,0,4], function() { NRF.sendHIDReport([0,0,0]); });
results in the same error. so probably not ble_hid_keyboard issue.
-
• #4
I believe the issue is just that when you connect to Puck.js from the EspruinoHub IDE on the Raspberry Pi, it is connecting to just the Bluetooth Serial port. It's not connecting as a Keyboard device, so when you go to send keypresses the command fails.
If you don't connect from the EspruinoHub IDE and instead connect via the Raspberry Pi's Bluetooth GUI, it'll might start treating it as a keyboard and it'd work fine.
However looking at this post from a year ago, it's possible the Raspberry Pi doesn't support Bluetooth HID devices at all: https://www.raspberrypi.org/forums/viewtopic.php?t=176808
Things may have changed in the last year though.
-
• #5
[Puck.js a766]# info E5:DD:7B:99:A7:66 Device E5:DD:7B:99:A7:66 Name: Puck.js a766 Alias: Puck.js a766 Paired: yes Trusted: yes Blocked: no Connected: yes LegacyPairing: no
still doesnt work.
What confuses me is that I can connect using EspruinoHub and send code to the device so I know that the Raspberry Pi is supporting BLE but it doesnt seem to support HID.
Does anyone know why?
Sorry for this newbie question, first day playing with this.
Everything is latest. Have EspruinoHub started in systemctl.
I can connect to the raspberrypi EspruinoHub ide, connect to Puck and upload code.
Puck firmware 2v00
Found some code in tutorials and hacked it together. All I want to achieve is to have a button press result in a keyboard type the letter p
After sending the code I disconnect and reconnect
Click on the puck and console says
If I click the puck again I get
Here is the full code:
Thank you for helping me. I'm totally confused.