You should be able to modify the report ID within the BLE profile within the BLE Component in the TopDesign file. (Double-click the BLE component to access its settings).
I have two set of keys, and each set with different report id. So how do I change the report id dynamically before sending the key?
Since the HID over BLE uses the standard BLE characteristics to store the data for the Report IDs, it should be a simple Cyble_GattsWriteCharacteristicValue() (or something similar iirc). Basically, write the value as if it is a normal bluetooth characteristic before sending it. So, depending on what key you want to use, write that key to the gatt db, then send the reports/data.
the two set keys: BLE HID consumer keys (Report ID: 0x03) and BLE HID Keyboard (Report ID: 0x02). The existing keyboard example works for BLE HID keyboard, but not HID consumer keys. Please advise. Thanks.
I find there is a method from the generated source code:
CYBLE_API_RESULT_T CyBle_HidssSetCharacteristicValue(uint8 serviceIndex, CYBLE_HIDS_CHAR_INDEX_T charIndex, uint8 attrSize, uint8 *attrValue)
Is it you mentioned? Did you have an example to use it to change the report id?
You would have to change multiple values I suspect to dynamically switch between the two report profiles, and possibly the structure of the bluetooth profile/service(s).
contains information on how to implement the consumer keys for Bluetooth; I assume it should be a conversion between the HID keyboard and this. You might need to have the keyboard and consumer keys setup as two different services rather than trying to dynamically reuse the same service for both.
How to set up with two different services? Is there an example?
Another question, is there an example to implement ONE HID Descriptor (Report Map) containing two usages, and each usage includes one collection with the report ID?
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x06, // USAGE (Keyboard)
0xA1, 0x01, // COLLECTION (Application)
0x85, 0x05, // REPORT_ID
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x08, // REPORT_COUNT (8)
0x05, 0x07, // USAGE_PAGE (Keyboard
0x05, 0x07, // USAGE_PAGE (Keyboard)
0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated))
0x29, 0xFF, // USAGE_MAXIMUM (Reserved (no event indicated))
0x81, 0x00, // INPUT
0xC0, // END_COLLECTION
// User-defined 0 report, USER_DEF0_REPORT_ID
0x05, 0x0C, // USAGE_PAGE(CONSUMER_DEVICES)
0x09, 0x01, // USAGE(REMOTE_CONTROL)
0xA1, 0x01, // COLLECTION(Application)
0x85, 0x06 // REPORT_ID
0x95, 0x04, // REPORT_COUNT(4)
0x75, 0x10, // REPORT_SIZE(16)
0x15, 0x00, // LOGICAL_MINIMUM(0)
0x2A, 0xFF, 0x01, // USAGE_MAXIMUM(0x1FF)
0x81, 0x00, // INPUT
0xC0, // END_COLLECTION
I have not seen an example HID setup for two separate services, but it should be as simple as mimicking the functionality of the current HID service in another service (e.g. HID2), but then change it to behave as the second HID function that you want to implement.
Sorry I don't have an example ready for multiple HID services on the same device, but I think you can definitely achieve your goal :)
This website should explain everything you need to know about HID data transmission to the PC: http://eleccelerator.com/tutorial-about-usb-hid-report-descriptors/
The only difference between an HID device plugged into a PC and a HID BLE device is the way the data reaches the PC, as the BLE part just transmits it between two BLE devices. The link I listed in the above paragraph should hold all the information you need to answer the question with some time and effort.
I only setup with one HID service. In the report map, HID descriptor, (see below screen shot) as mentioned, it contains two sections with different report id defined.
I use this call to send the key data;
apiResult = CyBle_HidssSendNotification(cyBle_connHandle, CYBLE_HUMAN_INTERFACE_DEVICE_SERVICE_INDEX,
CYBLE_HUMAN_INTERFACE_DEVICE_REPORT_IN, KEYBOARD_DATA_SIZE, keyboard_data);
but I am not sure where I can set the report id along with this data sending. Did you know how to set the report id for this?
I don't know how the CyBle_HidssSendNotification() function works, but all you need to do to add a Report ID is to click the plus symbol (circled with red) to add a collection, and then add the Report ID within the collection (plus an other data you want with it, like usage, etc.)
Using the plus icon you can add all of the various metadata for the HID device that you want to specify.
Then, using the notifications, you should be able to manipulate that data :)
I circled an example collection that I added at the bottom in blue.
Thanks e.pratt_1639216. Could you guide me a bit of detail about "using the notifications, you should be able to manipulate that data"?
Once you setup the BLE profile configuration for HID, then it will be stored on the GATT DB just like other bluetooth services/characteristics. Then, to send data to the remote device when connected, you just use GATTSNotification() to send data to the remote device (that is connected). You will also need to call CyBle_GattsReadAttributeValue() if you want the data to be saved on the local device (the one running the code).
The usage and operation should be the same as the original HID profile example that you started with. The only difference is that you are adding more BLE profile attributes to send to the computer.
Is the report ID (0x03) in the part of the data? I need to add explicitly.
such as HID data: '0x03' '00' '00' '23' ....