This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

When should I start to send HID Keyboard Reports

Hi there,


I am trying to make my own BLE keyboard as a hobby project. I have a question about when to start sending HID reports from peripheral to central device.
 My device sends a string "abcdefghijklm....." rightafter peripheral device switches to "GAPBOND_PAIRING_STATE_BONDED" GAP state, so that I am sending my key string once I have done with bonding. However, on different trials I am missing some characters from the beginning of the string. For example:

- "cdefghijklm..."

- "bcdefhijklm..."

- "ijklm..."

I would like to know when should I start sending from peripheral to HID host? I would really appreciate any kind of help or guidance.


Thank you and have a great day you all!

  • Hi dnz,

    Have you taken a look at the HID over GATT Profile (HOGP) documents from the BT SIG website? The Profile & Service are documented there.
    Otherwise, you can refer to the HIDEmuKbd project in the BLE SDK.

    Also worth noting is a TI Designs Bluetooth low energy keyboard reference design: www.ti.com/.../TIDM-BLE-KEYBOARD;tisearch=tidesigns

    Hopefully these examples will help get you in the right direction.

    Best wishes
  • Hi again,

    I have been still trying to find when should I send HID Key reports on right time. I have read a lot about HoGP documents from BT SIG and chip vendors, I still don't know when should I start sending HID Key Strokes.

    Any help on this? I will really appreciate.

    Thank you,
  • Hi dnz,

    In addition to studying the documents, did you have a chance to follow the aforementioned HIDEmuKbd example project for the Keyfob? Using the CC Debugger to investigate the code should be a good next step.

    Best wishes
  • Hi JXS,


    I think I spent quite amount of time on HIDEmuKbd project for the Keyfob. You know this is like a general problem of wireless keyboards. If a computer is logged off, then to active computer from sleep mode, you press enter couple of times where one single enter sometimes is not enough since host computer does not receive HID key stroke. Or if your screen is not sleeping when you enter start typing, sometime you miss first 1-2 characters.


    What I would like to do, once I enumerate my device as HID keyboard, I would like to send a stream of key strokes. However, I am not sure when should I start to send it. If I give 500 ms delay after my device enumurate itself as HID keyboard, and then start sending. This is fine but giving a constant time is not a good solution which may vary from device to device.

    What I am looking for some sort of like a flag that host is ready to receive HID reports. I have checked different characteristics like hidReportKeyInClientCharCfg to figure out when is the right time to send, but still not a good luck yet.

    Any hint will be appreciated a lot.

  • Hi dnz,

    Once you are in a connection (our example requires you to be bonded in a secure connection iirc) you could theoretically start sending HID reports.
    However the central side might receive them and simply not forward them to the application if it choses to (say if the phone it is e.g. busy doing something else).
    Android and iOS BLE stack behavior is at times badly documented and is subject to constant change with each new OS revision. I would suggest getting hold of a BLE sniffer to check whether the problem occurs over the air or if the problem lies on the central device.

    .:Svend
  • Hi,

    Normally when a Master device(Android or iOS) connects to your keyboard, it goes ahead and reads your report map. Once it has understood your report map the Android or iOS device will write to your Key In/CC In client characteristic configuration descriptor to enable HID report notifications. So all the HID reports that you have created will get send after this is enabled.

    Now the HID profile(in hiddev.c) queues up the HID reports upto a certain length, You could try increasing this length so that no over flow happens till the point host device enables HID report notifications. But my suggestion is to wait until the host device enables notifications(writing to Key In CCCFG Descriptor) and then you can start sending HID reports as you wish.

    Regards,

    Arun