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.

CC2541 BLE Keyboard + Mouse 的應用 (得知系統 NumLock LED 狀態)



您好:

小弟目前使用 1.3.2 版 FW,Profile 是使用 HIDEmuKbd,測試Keyboard + Mouse 的HID 宣告無法得到系統 LED 的狀態

範例程式中有註冊 hidEmuKbdRptCB

static hidDevCB_t hidEmuKbdHidCBs =
{
  hidEmuKbdRptCB,
  hidEmuKbdEvtCB,
  NULL
};

所以當系統的 NumLock  有狀態變化的時候會進入到hidEmuKbdRptCB

static uint8 hidEmuKbdRptCB( uint8 id, uint8 type, uint16 uuid,
                             uint8 oper, uint8 *pLen, uint8 *pData )

接著會進入到 hidEmuKbdRcvReport 去點LED的狀態,關於這點在HIDEmuKbd範例程式中是沒有問題的

status = hidEmuKbdRcvReport( *pLen, pData );

但是由於此範例是Keyboard Only 的 HID Service

所以小弟將  HidKbd_AddService 改成 HidKbM_AddService之後

發現當系統的 NumLock  有狀態變化的時候,不會進入到hidEmuKbdRptCB

請問該怎麼改善這個問題

附件為小弟測試的code

  • Hi Mars,

    你有照 hidkbdservice.c 中HidKbd_AddServce() 来添加 HidKbM_AddService() 吗?

    特别是  status = GATTServApp_RegisterService( hidAttrTbl, GATT_NUM_ATTRS( hidAttrTbl ), &hidKbdCBs ); 里面的 hidKbdCBs .

    请确认一下.

  • Hi Yan:

    我直接使用hidkbmservice.c 裡的 HidKbM_AddService() 添加在 hidemukbd.c

    Add Path : BLE-CC254x-1.3.2\Projects\ble\Profiles\HIDDevKbM

    在 hidkbmservice.c 這裡面有註冊    

    // Register GATT attribute list and CBs with GATT Server App
    status = GATTServApp_RegisterService( hidAttrTbl, GATT_NUM_ATTRS( hidAttrTbl ), &hidKbdMsCBs );

    // Service Callbacks
    CONST gattServiceCBs_t hidKbdMsCBs =
    {
      HidDev_ReadAttrCB,  // Read callback function pointer
      HidDev_WriteAttrCB, // Write callback function pointer
      NULL                // Authorization callback function pointer
    };

    替換成下面也一樣

    // Register GATT attribute list and CBs with GATT Server App
    status = GATTServApp_RegisterService( hidAttrTbl, GATT_NUM_ATTRS( hidAttrTbl ), &hidKbdCBs );

    // Service Callbacks
    CONST gattServiceCBs_t hidKbdCBs =
    {
      HidDev_ReadAttrCB,  // Read callback function pointer
      HidDev_WriteAttrCB, // Write callback function pointer
      NULL                // Authorization callback function pointer
    };

    目前測試 Mouse & Keyboard & Consumer 功能都可以送的出來,唯讀Keyboard Led狀態無法得知

  •    你们好!

            我现在也正在学习2540。

            想模拟一个HID设备, 这是需要进行读和写功能的, 目前参考键盘的例程。

            可知道如何进行设备到PC端是数据传输,但是无法从PC端发送数据到设备上。

            这与键盘上Keyboard Led 的功能相似,请问如Mars的操作, 还有哪一步是忽略的, 请指明一下。

            谢谢。

  • 您好,现在我也是遇到了这个问题,时间过去这么久了,不知道您是否已经解决了这个问题呢?如果有解决办法,望不吝赐教,万分感激!!