Skip to main content
MTurn
Visitor II
May 21, 2019
Solved

How do you add a custom GATT service to a HID peripheral.

  • May 21, 2019
  • 1 reply
  • 797 views

I'm trying to add a custom GATT service to a HID peripheral. I'm using a BlueNRG-2 and following the BLE_HID_Peripheral example. In the hidService_Type ther are two fileds that look like they might be used for this. They are includedServiceEnabled and includedService. I think I need to set includedServiceEnabled to true. However, I'm not sure what includedService should be. The type for this field is includSer_Type. This type ahs three fields:

uuid - which only holds 16-bits. How can I provide the 128 bits needed for a custom service?

start_handle - where do I get this?

stop_handle - where do I get this?

Are service handles assigned in order such that there is a first and last?

If I have one service, would start_handle and stop_handle be the same?

Also, should I add the custom service and characteristics using aci_gatt_add_service and aci_gatt_add_char just prior to the call to hidAddServices?

    This topic has been closed for replies.
    Best answer by Winfred LU

    Hi Mark,

    includedServiceEnabled and includedService are used for the HID library to add include declarations

    to reference other services when creating the HID service.

    By include declaration, it means SIG defined declaration with UUID 0x2802. The value contains the start and end handles of the included service, and also its UUID. Typical usage is to include the battery service, as described in HID Service Spec, Appendix A, GATT Database example.

    To add a custom GATT service, please instead use aci_gatt_add_service() and aci_gatt_add_char() according the needs.

    Either prior to or after the call to hidAddServices shall be fine.

    Best Regards,

    Winfred

    1 reply

    Winfred LU
    Winfred LUBest answer
    ST Employee
    May 22, 2019

    Hi Mark,

    includedServiceEnabled and includedService are used for the HID library to add include declarations

    to reference other services when creating the HID service.

    By include declaration, it means SIG defined declaration with UUID 0x2802. The value contains the start and end handles of the included service, and also its UUID. Typical usage is to include the battery service, as described in HID Service Spec, Appendix A, GATT Database example.

    To add a custom GATT service, please instead use aci_gatt_add_service() and aci_gatt_add_char() according the needs.

    Either prior to or after the call to hidAddServices shall be fine.

    Best Regards,

    Winfred