Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SDK16 BLE HID, how to set a value to HID report feature?

I have used nRF5 SDK ver.16 for BLE HID digtiger.

I want to set up some feature value to HID report . Such as Contact count maximum.

I have followed keyboard example, but this not mention.

Is there any example to guide how to do it?

This is feature report descriptor

 

0x85, FEATURE_REP_MAX_COUNT_ID,     //   REPORT_ID (Feature)
0x09, 0x55,                         //   USAGE(Contact Count Maximum)
0x75, 0x08,                         //   REPORT_SIZE (8)
0x95, 0x01,                         //   REPORT_COUNT (1)
0x25, 0x0A,                         //   LOGICAL_MAXIMUM (10)
0xB1, 0x02,                         //   FEATURE (Data,Var,Abs)       

Thank you.

  • Hi,

    There are two options to set the feature report, only choose one of them.

    ---------- OPTIONS 1 - modify ble_hids.c: ---------- 

    Open ble_hids.c and go to on_report_value_read_auth(), then change:
    auth_read_params.params.read.update = 0; // Set to 0.

    Then calling sd_ble_gatts_value_set() after ble_hids_init() should work, for instance:   
    err_code= sd_ble_gatts_value_set(m_conn_handle,
    m_hids.feature_rep_array[FEATURE_REPORT_INDEX]->char_handles.value_handle, &gatts_value);

    ---------- OPTIONS 2 - use ble_hids_feat_rep_set()---------- 

    The HIDS module keeps track of attribute values for each connection object (handle) and uses this tracked state to respond to a GATT client read / write operations. 

    If you want to set a non-zero value for feature reports, you need to use the following function:
    https://gist.github.com/kapi-no/ce902e1aed6aac57eae2c6a3eabf7b58

    You need to call ble_hids_feat_rep_set() for each new connection when you handle the connected event from Softdevice.

    I hope this will help you.

    Best regards,
    Kenneth

Related