I purchased the Bluefruit EZ-key breakout from Adafruit recently:
http://learn.adafruit.com/introducing-bluefruit-ez-key-diy-bluetooth-hid-keyboardIts an interesting device as it lets you easily turn just about any switch into a bluetooth keyboard, even without a microcontroller.
With a microcontroller you can send data to it over serial and it will present the data to a bluetooth host as a HID keyboard.
Recently discovered that you can send raw HID reports to it even (i think you can only do the standard 6 key variety) and it will pass those through. So this weekend I hooked it up to an Arduino Pro Micro which is really a teensy-like atmega 32u4 breakout (but fewer pins and no onboard reset button). Anyhow I wired it up to a terminal Model M and now I have a bluetooth Model M
UPDATE: The problem described below existed with the Bluefruit 1.0 only; you must use a Bluefruit 1.1 at least for the keyboard & mouse functions, and you must use Bluefruit 1.2 for consumer keys to workSort of.
I have a pretty serious bug that I need to solve.
Everything works fine as long as I only press one key at a time... if I press two, things get a little strange, I'll try to describe this as best I can...
If I press two keys at once, the first key is typed on my PC just fine, as is the second key. However if I release the first key, another HID report gets sent to and the other key gets typed out again (as if there was a key up in between). To better illustrate here is the debug output from pressing and holding 'g', then pressing and holding 'h', then releasing 'h', then releasing 'g':
$ sudo ./hid_listen
Waiting for device:....
Listening:
Setting host driver...
Initializing serial...
Beginning main loop
rAA wFF [ack]
RESET_RESPONSE: rBF err
RESET: rBF wFF x01wFF x01wFF x01wFF x01wFF [ack]
RESET_RESPONSE: rAA [ok]
KBD_ID: rBF rBF
CONFIG: wF8 [ack]
READY
r34
keys: 000A 0000 0000 0000 0000 0000 mods: 0000 reserved: 0000
r33
keys: 000A 000B 0000 0000 0000 0000 mods: 0000 reserved: 0000
rF0 r33
keys: 000A 0000 0000 0000 0000 0000 mods: 0000 reserved: 0000
rF0 r34
keys: 0000 0000 0000 0000 0000 0000 mods: 0000 reserved: 0000
The result of this is that 'ghg' gets typed out over Bluetooth.
Sorry if I'm not explaining clearly or with the right vocabulary, I'm kind of a helpless noob
Here's the code I'm using to implement the bluefruit protocol... am I sending the HID report incorrectly or could this be a bug or problem with the Bluefruit itself?
void bluefruit_keyboard_print_report(report_keyboard_t *report)
{
dprintf("keys: "); for (int i = 0; i < REPORT_KEYS; i++) { debug_hex16(report->keys[i]); dprintf(" "); }
dprintf(" mods: "); debug_hex16(report->mods);
dprintf(" reserved: "); debug_hex16(report->reserved);
dprintf("\n");
}
void bluefruit_transmit_report(report_keyboard_t *report)
{
serial_send(0xFD);
serial_send(report->mods);
serial_send(0x00);
for (uint8_t i = 0; i < REPORT_KEYS; i++) {
serial_send(report->raw[i]);
}
}
/*------------------------------------------------------------------*
* Host driver
*------------------------------------------------------------------*/
static uint8_t keyboard_leds(void);
static void send_keyboard(report_keyboard_t *report);
static void send_mouse(report_mouse_t *report);
static void send_system(uint16_t data);
static void send_consumer(uint16_t data);
static host_driver_t driver = {
keyboard_leds,
send_keyboard,
send_mouse,
send_system,
send_consumer
};
host_driver_t *bluefruit_driver(void)
{
return &driver;
}
static uint8_t keyboard_leds(void) {
return bluefruit_keyboard_leds;
}
static void send_keyboard(report_keyboard_t *report)
{
bluefruit_keyboard_print_report(report);
bluefruit_transmit_report(report);
}
Thanks in advance for your help