This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nRF51422 HID example modification

Hello

I'm using nRF51422 with S310 softdevice. I've been testing HID example (keyboard) for a while. What I'm trying to do is to send as much as possible bytes at once in a single report. I do like this:

uint8_t ucData[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

ble_hids_inp_rep_send(&m_hids,
                                 INPUT_REPORT_KEYS_INDEX,
                                 INPUT_REPORT_KEYS_MAX_LEN,
                                 ucData);

All works well until INPUT_REPORT_KEYS_MAX_LEN is not more than 8, otherwise it does not work. So 8 bytes is the maximum for now.

My question is: what is the max number of bytes that can be sent at a time and how to do that? And, of course, the same question applies for receiving side.

I have a feeling that report_map_data[] descriptor should be modified, but I don't know how to do that and also I can't find any documentation on this. Forget mouse, forget keyboard, I would like to make HID as generic as possible.

Regards

  • You can use custom HID report map like this:

    #define INPUT_REPORT_MAX_LEN             20                                             /**< Maximum length of the Input Report characteristic. */
    #define OUTPUT_REPORT_MAX_LEN            22                                             /**< Maximum length of Output Report. */
    
    static uint8_t report_map_data[] =
    {
        0x06, 0x00, 0xFF,       // Usage Page = 0xFF00 (Vendor Defined Page 1)
        0x09, 0x01,             // Usage (Vendor Usage 1)
        0xA1, 0x01,             // Collection (Application)
        0x19, 0x01,             //      Usage Minimum 
        0x29, INPUT_REPORT_MAX_LEN,             //      Usage Maximum 
        0x15, 0x00,             //      Logical Minimum (data bytes in the report may have minimum value = 0x00)
        0x26, 0xFF, 0x00,       //      Logical Maximum (data bytes in the report may have maximum value = 0x00FF = unsigned 255)
        0x75, 0x08,             //      Report Size: 8-bit field size
        0x95, INPUT_REPORT_MAX_LEN,             //      Report Count: Make sixty-four 8-bit fields (the next time the parser hits an "Input", "Output", or "Feature" item)
        0x81, 0x00,             //      Input (Data, Array, Abs): Instantiates input packet fields based on the above report size, count, logical min/max, and usage.
        0x19, 0x01,             //      Usage Minimum 
        0x29, OUTPUT_REPORT_MAX_LEN,             //      Usage Maximum
        0x91, 0x00,             //      Output (Data, Array, Abs): Instantiates output packet fields.  Uses same report size and count as "Input" fields, since nothing new/different was specified to the parser since the "Input" item.
        0xC0                    // End Collection
    };
    

    And send your data like this:

    err_code = ble_hids_inp_rep_send(&m_hids, 
                                     INPUT_REPORT_KEYS_INDEX,
                                     data_len,
                                     data);
    
  • Hi Nikita,

    Thank you very much, it works. Sorry for my late reply.

    Best regards

  • Hi,Nikita: I'm using nRF51422 with S110 softdevice.I use your Report Map(little modify,I just defined INPUT_REPORT_MAX_LEN = 8.OUTPUT_REPORT_MAX_LEN = 1),and send data the same as you post。then all work ok。but In PC, The BusHound can't received any data.Is other place need to modify? Sorry for disturb。

Related