This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

HID Consumer Control with CC2540

Other Parts Discussed in Thread: CC2540, ASH

Hello

I am trying to implement a little remote for consumer controls (e.g. volume up and down) with the CC2540 Mini Development kit.

The HIDEmuKbd App is my starting point for this.
I have modified the key codes to regular to 'A' and 'B' in order to verify that the central device supports HID over GATT.
This worked like charm.

Now the next step is to modify the HID descriptor in the hidkbdservice in order to additionally include consumer control input. For this purpose I have refactored the hidkbmservice of the HIDAdvREmote to comply with the function signatures of the hidkbdservice. In other words I have changed the  function names so that they have the same names as the original hidkbdservice function names (the two files are very similar). 

My hope was that this change would leave my modified HIDEmuKbd app still functional i.e. the central device would still understand the send reports and interpret them as character a and b. 
Though now the central device does not interpret the report anymore the way I intended.

Does anyone have an idea what could cause this behaviour?

Thanks

Michael

  • If you are trying to implement consumer control, why are you starting with HidEmuKbd (which implements a keyboard and not a consumer control class)? I much easier way to go would be to start with HidAdvRemote (which implements consumer control class) and strip out the unecessary stuff. I think this will be much easier than going the other way.

  • My starting point is the EmuKBD app because it is targeted at the keyfob hardware. The AdvRemote includes a lot of code targeted at the Advanced Remote Hardware. In my understanding my approach should be much easier since I just need to manipulate the HID descriptor that it also includes consumer control and add a function for sending CC reports instead of sending keyboard reports.

  •  Willis ,

    I am trying to implement with the same with sensortag device which has single button I manipulate the code as per that   but didn't succeed . Can you Suggest what changes we need to do

  • Dear Michael, I went through your issue and solution of your problem. I am also facing almost the same issue. As I am newbie. I dont know much more in detail about HID management. At present, I want to control using volume up key through consumer control. Could you please share some example code or something which can help me to resolve my issue. What are the modifications I need to make to use only volume up key. your help'd be highly appreciated~ Thanks /Ash
  • Hi Ash,

    First of you need to have Consumer control Report in your GATT attribute table((Please see hidReportMap in Hidkbdmservice.c file). Once the Report Map is described, you nned to send Consumer control HID reports as shown in HidAdvRemote.c . Please heave alook at the HidAdvRemote project to understand the procedure. you could use the same report map and same HID report structures as in HidAdvRemote example.

    Regards,
    Arun
  • Dear Arun,Thanks for your help.
  • Dear Arun, Thanks for your reply. I followed it and found working on Android well. But there is one issue, I am facing is that, It doesnt working well on iOS (iPAD, iPhone...). The same code I am using to control the function of iOS through KeyFob as HID device. The same volume up key control I want to mange in iOS too. The issues are:
    1. Volume up not supporting iOS (same is supported by Android).
    2. Once I connect the HID device (keyfob) to iOS, Its connected well but when I press key to control its volume up, the iOS gets disconnected. (in fact, there is no relation with key press and disconnection in code). Actual function is not working.
    Please help to solve these issues.Thanks a lot./Ash
  • Hi,

    I do hope that you are releasing the Key(along with sending HID_RESERVE_KEY(0x0) ). Are you sure the disconnection happens because of Volume UP key press only? Are you sending a connection parameter update request to iOS? 

    Can you send the Packet sniffer logs for the transactions done between iOS and your key fob? You need to find the LTK of keyfob by connecting it to BTool and calling "Authenticate Connection" button under the Pairing/Bonding Tab. Then You can use this LTK in the Radio configurations tab( reverse order of Octets) of packet sniffer.

    You may need to try connection multiple times as the Packet sniffer can sniff connection packets only if Connection request came in the same channel that you are sniffing.( if you are using Channel 37, then you may need to retry establishing connection till connection request is sent on Channel 37.)

    Else you can set advertising channel to 37 for getting these logs like shown below in your keyfob code before staring advertisement.

    uint8_t  gapRole_AdvertChannel = GAP_ADVCHAN_37;

    GAPRole_SetParameter(GAPROLE_ADV_CHANNEL_MAP, sizeof(uint8_t),
    &gapRole_AdvertChannel);

    You can check how to re-program the  CC2540 USB  in the wiki processors.wiki.ti.com/.../BLE_sniffer_guide

    Regards,

    Arun

  • Dear Arun,Thanks for your propmt and detailed reply.
    i) Yes, the disconnection is happening because of Keypress. When No key press, no dosconnection.
    ii) Connection parameter update = NO (FALSE)
    I followed as you mentioned the process. Set the channel and MAP in code.
    1. Connected keyfob to TI donggle2. Got the LTK
    3. Open sniffer tool while connected Keyfob to iOS
    4. Set the LTK in sniffer (same from BTool) and set the channel .
    5. Save the sniffering log while connected (Keyfob <--------> iOS (7.0))
    * I didnt see any option here to attach the sniffer log file. How can I do that?
    Please help to resolve this issue. Thanks/Ash
  • Hi,

    Please use rich formatting why replying and attach the log file by clicking the <Insert File> option.

    Regards,

    Arun

  • Dear Arun,

    I found it, as I need to set some setting on my TI page. Thanks

    Anyway, I attached the psd file here, please check it.

    Thanks,


    Regards,
    /Ash20150316_IPad7.0_Keyfob_sniffer.psd

  • Hi,

    What is the iOS version used by iPhone that you are using? I will check the sniffer log and get back to you.

    Regards,
    Arun
  • Hi,

    I checked the logs that you have shared. There is no Link terminate request from Slave device. iPhone may have disconnected because it hit supervision timeout or the slave didnt respond back in time. The connection interval was set to 15 ms with a slave latency of 4, so if there is no response in 75ms, there is a chance of disconnection. Is your key press event running in interrupt perspective? This event may be blocking Stack thread long enough for the host to disconnect on its on.

    Can you check by sending a Volume UP HID report without pressing a key(like periodically every few seconds)

    Are you able to send any other consumer protocol HID reports?

    Regards,
    Arun
  • Dear Arun,I am using iOS version 7.0 (iPad) and 8.2 (iphone).
    Hope to hear soon from you~ThanksRegards