Connect external HID device (Keyboard or remote camera trigger) #4078
Replies: 1 comment
-
Posted at 2022-10-26 by @gfwilliams Hi - I'd love it if we could figure this out. It sounds like a really useful thing to be able to do. Maybe the best thing would be to connect to it via NRF Connect on a phone and see if by poking it in the right way you can see what needs doing to make it work. You could look at what has to happen on Espruino to make things work: https://github.com/espruino/Espruino/blob/master/targetlibs/nrf5x_12/components/ble/ble_services/ble_hids/ble_hids.c It's a bit hard to decipher but 2A4D definitely looks like the right characteristic to listen for notifies on (I guess if there are two you just have to make sure you use the right one). As far as I can see Espruino will just send data to that anyway without initialisation. But it may be you also have to set the protocol mode on some devices (2A4E) - maybe to PROTOCOL_MODE_REPORT (which is just Posted at 2022-10-26 by ChristianW Thanks @gfwilliams for the hints. NRF Connect only shows the Service, no peeking or poking possible (iOS here). By the way, this is my code so far:
And this is the output:
Maybe you see something I don't.
What about this BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST? I will have to look at the sourcecode more in-depth though. Posted at 2022-10-27 by ChristianW Just digging into this issue and found this HOGP specification here. Chapter 5 explains details about bonding and how to establish a connection. At some point the Host (normally computer/phone; here: Espruino) writes his address into the HID device (peripheral; here: the remote button) causing a bonding. Posted at 2022-10-27 by @gfwilliams Sorry - I posted the reply in the wrong thread: Ahh - could be, yes! I think some devices will only work when they've been bonded. Maybe try http://www.espruino.com/Reference#l_BluetoothRemoteGATTServer_startBonding ? When the dialog pops up for iOS do you need to enter a pairing code? There might be some more fiddling required on Espruino if so, but it should still be fine with the default firmware. Did you set Espruino itself up as a HID device? Usually when it's a HID device iOS/etc will pick it up and show it in the OS menu - but when it's not a HID device they think it's not important so don't keep it in there Posted at 2022-10-27 by ChristianW Yeah - your other comment about bonding from the neighbor thread did the trick. This is working now:
For a button press I get:
and for a release:
The only thing is that when I pull the power from Espruino the bonding seems to be lost and the blue LED on the remote begins flashing again. This does not happen when bonded to Laptop/Phone. Maybe it's about the whitelisting. But I could live with that. Posted at 2022-10-27 by @gfwilliams That's great! Yes, not sure about the bonding... But this would make a great library! So I guess if you had a Bluetooth LE keyboard, you could conceivably connect it to Bangle.js or Pixl.js and use it as a fully-fledged computer like https://www.espruino.com/Espruino+Home+Computer |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2022-10-25 by ChristianW
There is a HID module for BLE that helps Espruino to emulate a HID device (like keyboard or media controller) itself.
What I want to do is exactly the opposite:
I bought a cheap 1-button camera trigger for smartphones (that sends a "volume up" button command)
want to use it on my Espruino project as a remote switch, but how?
I can:
NRF.requestDevice
(named "AB Shutter3" - prefix "AB" works)1812
) and fetch itThe odd thing is:
0x2a4d
exists twice and is the only characteristic that willnotify
, so this is probably the one I'm looking for, butc..on("characteristicvaluechanged",…
andc.startNotifications()
doesn't workWhen I pair it with my smartphone there is a dialog popping up first.
Will there be something to happen first before both are connected?
Like writing back to one of the other characteristics to say that we'd like to connect?
Any hints or links appreciated.
Attachments:
Beta Was this translation helpful? Give feedback.
All reactions