Most recent activity
-
- 5 comments
- 1,938 views
-
-
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. -
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 pAfter sending the code I disconnect and reconnect
Click on the puck and console saysUncaught Error: Got BLE error 0x8 (INVALID_STATE) at line 1 col 104 ...0,0,0],function(){a&&a()})}) ^ in function "tap" called from line 6 col 36 kb.tap(kb.KEY.P, 0,function(){}); in function called from system >
If I click the puck again I get
Click 2
Here is the full code:
var kb = require("ble_hid_keyboard"); NRF.setServices(undefined, { hid : kb.report }); var clickcount = 0; var clickevent = null; setWatch((e) => { clickcount++; if (clickevent !== null) clearTimeout(clickevent); if (clickcount === 1) { setLEDS(false, true, false); kb.tap(kb.KEY.P, 0,function(){}); } else if (clickcount === 2) { setLEDS(true, false, false); //kb.tap(kb.KEY.Z, 0); } else if (clickcount === 3) { setLEDS(false, false, true); //kb.tap(kb.KEY.S, 0); } else { setLEDS(true, true, true); } clickevent = setTimeout(() => { if (clickcount === 1) { console.log("Click 1"); } else if (clickcount === 2) { console.log("Click 2"); } else if (clickcount === 3) { console.log("Click 3"); } clickcount = 0; }, 350); }, BTN, { edge: "rising", debounce: 50, repeat: true }); setWatch((e) => { setLEDS(false, false, false); setTimeout(() => { clickevent = null; }, 400); }, BTN, { edge: "falling", debounce: 50, repeat: true }); const setLEDS = (LED1on, LED2on, LED3on) => { LED1.reset(); LED2.reset(); LED3.reset(); if (LED1on) LED1.set(); if (LED2on) LED2.set(); if (LED3on) LED3.set(); };
Thank you for helping me. I'm totally confused.
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?