cancel
Showing results for 
Search instead for 
Did you mean: 

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

MTurn
Associate

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Winfred LU
ST Employee

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

View solution in original post

1 REPLY 1
Winfred LU
ST Employee

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