This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Need help regarding custom HID descriptor for nRF51822

Hi,

I am trying to modify the ble_hids_mouse example project to convert the device into a vendor defined HID device. I need to send 64 bytes of custom sensor data (which I am reading over SPI on nRF51) over custom HID so that my application on the PC can access the data using HID APIs. I have tried multiple HID descriptors but fail to get data on the PC side. I am using the HIDAPI library on a Windows 10 platform to read data from the HID device. The hid_open() function returns a valid handle for the HID device (VID,PID) but hid_read() always returns 0 bytes. Error code from ble_hids_inp_rep_send() function on nRF returns 0 (NRF_SUCCESS), so I am assuming there are no errors in sending HID input reports. 

Following are 2 HID descriptors which do not work:

(I)
0x05, 0x01, // Usage Page (Generic Desktop Page)
0x09, 0x00, // Usage (Undefined)
0xA1, 0x01, // Collection (Application)
0x09, 0x00, // Usage (Undefined)
0x16, 0x00, 0x00, // Logical Minimum (0)
0x26, 0xFF, 0x00, // Logical Maximum (255)
0x36, 0x00, 0x00, // Physical Minimum (0)
0x46, 0xFF, 0x00, // Physical Maximum (255)
0x66, 0x00, 0x00, // Unit (None)
0x75, 0x08, // Report Size (8)
0x95, 0x40, // Report Count (64)
0x81, 0x02, // Input
0xC0, // End Collection

(II)

0x06, 0x00, 0xff, // USAGE_PAGE (Vendor Defined Page 1)
0x09, 0x01, // USAGE (Vendor Usage 1)
0xa1, 0x01, // COLLECTION (Application)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x40, // REPORT_COUNT (64)
0x09, 0x01, // USAGE (Vendor Usage 1)
0x81, 0x00, // INPUT (Data,Ary,Abs)
0x09, 0x01, // USAGE (Vendor Usage 1)
0x91, 0x00, // OUTPUT (Data,Ary,Abs)
0xc0 // END_COLLECTION

I have adjusted the input report length to 64 bytes at multiple places in the code and modified the report id as per the descriptors. 

However, reducing the length of the input report from 64 bytes to 8 bytes seems to work and I am able to receive 8 bytes of data in my application.

Can you please help to debug this issue.

Regards,

Mustafa 

Parents Reply Children
  • Is there any limit on the speed at which HID reports can be sent on nrf51 + S130 ? I need to send an HID IN report every 5 ms. 

  • Hi,

     

    You need to conform to the BLE connection, which gives you a connection interval (from 7.5 ms to 4 sec), typically asked for by the peripheral device as a range (a min and a max).

    If you send data every 5 ms, you must rely on the central device to accept more packets per connection interval. Lets say that you have a connection interval of 10 ms, then you will send 2 packets per interval.

     

    Kind regards,

    Håkon

  • Hi Hakon,

    Thanks for the quick response. 

    My BLE central device is a Windows 10 Dell latitude 3490 laptop. I am trying to understand the connection parameters that would be used by the Windows driver. I found BLE design guidelines for iOS and Android platform but I am unable to find similar information for WIndows. Could you please point me in the direction where I can find this information. 

    Also, from my current understanding communication is active between the central and peripheral only during the connection event. Now, I am using the ble_hids_inp_rep_send() function to send HID IN reports.So, everytime I call the above function, does it queue all the messages and send them all at once during the next connection event. Is there a check on the maximum number of packets nrf device sends per connection interval ? 

    Thank You

    Mustafa

  • Hi Mustafa,

     

    mustafa1802 said:
    My BLE central device is a Windows 10 Dell latitude 3490 laptop. I am trying to understand the connection parameters that would be used by the Windows driver. I found BLE design guidelines for iOS and Android platform but I am unable to find similar information for WIndows. Could you please point me in the direction where I can find this information. 

     Look for the defines MIN_CONN_INTERVAL and MAX_CONN_INTERVAL at the top of main.c. This sets the limits for your peripheral.

    The central will always drive the communication, so you are not always guaranteed the same interval on different centrals, but you are very likely to get within the min and max interval that you set.

    mustafa1802 said:
    Also, from my current understanding communication is active between the central and peripheral only during the connection event. Now, I am using the ble_hids_inp_rep_send() function to send HID IN reports.So, everytime I call the above function, does it queue all the messages and send them all at once during the next connection event. Is there a check on the maximum number of packets nrf device sends per connection interval ? 

     There is no specific command to get this, as it is unique to each chipset and may also be a limitation set in the OS driver.

    You can send until the ble_hids_inp_rep_send() function returns error code NRF_ERROR_RESOURCES (for older SDKs you get error code BLE_ERROR_NO_TX_PACKETS), in which you have to wait until the queue is handled.

    You will get an event "BLE_EVT_TX_COMPLETE" when the transfer is complete.

     

    Kind regards,

    Håkon

Related