Do you know a smart way of selecting a BLE peripheral based on its HID service?
Well, ideally you would do a NRF.requestDevice and scan for service 0x1812 which is the human interface device one. However Espruino sticks the services it supports in a scan response packet which is different to the normal advertising one.
It means that when Espruino scans with a normal (non-active) scan it won't request the scan response so won't see the service.
I've just added the option for an active scan though, so if you do:
How can I tell my Pixl.js to send every received character to the LCD?
You need to respond to notifications on the input report characteristic, map the key code to the character, and then either use Terminal.print or if you want access to the REPL itself you can do Terminal.inject.
Responding to the input characteristic should be something like:
However this doesn't work as-is... it looks like you have to do some initialisation work first (setting charactertistics for the type of HID device (boot/normal) and exiting suspend) which you'd need to do a bit of searching around for.
When it's working this would make a great module though.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Well, ideally you would do a
NRF.requestDevice
and scan for service0x1812
which is the human interface device one. However Espruino sticks the services it supports in ascan response
packet which is different to the normal advertising one.It means that when Espruino scans with a normal (non-active) scan it won't request the scan response so won't see the service.
I've just added the option for an active scan though, so if you do:
it should work fine.
You need to respond to notifications on the input report characteristic, map the key code to the character, and then either use
Terminal.print
or if you want access to the REPL itself you can doTerminal.inject
.Responding to the input characteristic should be something like:
However this doesn't work as-is... it looks like you have to do some initialisation work first (setting charactertistics for the type of HID device (boot/normal) and exiting suspend) which you'd need to do a bit of searching around for.
When it's working this would make a great module though.