2014-03-04 128 views
2

我正在實施基於需要恢復或禁用鍵盤功能的TI Bluetooth LE HID示例的加密狗。在iOS設備上使用Apple鍵盤時,按下彈出按鈕將啓用/禁用設備,隱藏/顯示鍵盤。藍牙LE HID彈出鍵碼?

大多數參考文獻指出彈出按鈕沒有關鍵代碼,儘管將其列爲161;這從藍牙LE設備使用時不起作用。從鍵盤發送到設備的關鍵代碼是什麼?

我假設,當然,藍牙LE設備將發送與藍牙設備相同的密鑰代碼,並且Apple LE HID的實現包括隱藏和恢復鍵盤的功能。如果其中一個假設不正確,那也會有所幫助。

+0

你有沒有得到它的工作?如果是的話,你可以發佈完整的解以下回答不夠清楚 – Mojtaba

+0

不完全。不幸的是,這個項目被取消了。 – Mike

回答

4

我已經成功地得到了這方面的工作與Nordic半導體公司nRF51822和S110,使用下面的報告圖:

static uint8_t report_map_data[] = 
{ 
    0x05, 0x01,     // Usage Page (Generic Desktop) 
    0x09, 0x06,     // Usage (Keyboard) 
    0xA1, 0x01,     // Collection (Application) 
    0x85, 0x01,     //  Report Id (1) 
    0x05, 0x07,     //  Usage Page (Key Codes) 
    0x19, 0xe0,     //  Usage Minimum (224) 
    0x29, 0xe7,     //  Usage Maximum (231) 
    0x15, 0x00,     //  Logical Minimum (0) 
    0x25, 0x01,     //  Logical Maximum (1) 
    0x75, 0x01,     //  Report Size (1) 
    0x95, 0x08,     //  Report Count (8) 
    0x81, 0x02,     //  Input (Data, Variable, Absolute) 

    0x95, 0x01,     //  Report Count (1) 
    0x75, 0x08,     //  Report Size (8) 
    0x81, 0x01,     //  Input (Constant) reserved byte(1) 

    0x95, 0x05,     //  Report Count (5) 
    0x75, 0x01,     //  Report Size (1) 
    0x05, 0x08,     //  Usage Page (Page# for LEDs) 
    0x19, 0x01,     //  Usage Minimum (1) 
    0x29, 0x05,     //  Usage Maximum (5) 
    0x91, 0x02,     //  Output (Data, Variable, Absolute), Led report 
    0x95, 0x01,     //  Report Count (1) 
    0x75, 0x03,     //  Report Size (3) 
    0x91, 0x01,     //  Output (Data, Variable, Absolute), Led report padding 

    0x95, 0x06,     //  Report Count (6) 
    0x75, 0x08,     //  Report Size (8) 
    0x15, 0x00,     //  Logical Minimum (0) 
    0x25, 0x65,     //  Logical Maximum (101) 
    0x05, 0x07,     //  Usage Page (Key codes) 
    0x19, 0x00,     //  Usage Minimum (0) 
    0x29, 0x65,     //  Usage Maximum (101) 
    0x81, 0x00,     //  Input (Data, Array) Key array(6 bytes) 

    0x09, 0x05,     //  Usage (Vendor Defined) 
    0x15, 0x00,     //  Logical Minimum (0) 
    0x26, 0xFF, 0x00,   //  Logical Maximum (255) 
    0x75, 0x08,     //  Report Count (2) 
    0x95, 0x02,     //  Report Size (8 bit) 
    0xB1, 0x02,     //  Feature (Data, Variable, Absolute) 

    0xC0,      // End Collection (Application) 
    // Report ID 2: Advanced buttons 
    0x05, 0x0C,      // Usage Page (Consumer) 
    0x09, 0x01,      // Usage (Consumer Control) 
    0xA1, 0x01,      // Collection (Application) 
    0x85, 0x02,      //  Report Id (2) 
    0x15, 0x00,      //  Logical minimum (0) 
    0x25, 0x01,      //  Logical maximum (1) 
    0x75, 0x01,      //  Report Size (1) 
    0x95, 0x01,      //  Report Count (1) 

    0x0A, 0xAE, 0x01,    //  Usage (AL Keyboard Layout) 
    0x81, 0x06,      //  Input (Data,Value,Relative,Bit Field) 
    0xC0       // End Collection 
}; 

有了這個報告的地圖使我發這個一個切換:

static void toggle_send(void) 
{ 
    uint32_t err_code; 

    uint8_t release = 0; 
    uint8_t keyboard_toggle = 0x01; 

    // 1 designates the report index, not report ID. 
    err_code = ble_hids_inp_rep_send(&m_hids, 1, sizeof(keyboard_toggle), &keyboard_toggle); 
    APP_ERROR_CHECK(err_code); 

    err_code = ble_hids_inp_rep_send(&m_hids, 1, sizeof(release), &release); 
    APP_ERROR_CHECK(err_code); 
} 

我不知道TI API的詳細信息,但我希望這可以用於指代。如果您也可以訪問該芯片,則上述修改應該很容易添加到常規nRF51 SDK中的ble_app_hids_keyboard。

+0

現在適合你嗎? – user3428151

+0

我試圖在nRF51822上使用S110在SDK 8中工作。第一次調用'ble_hids_inp_rep_send'會在你的例子中崩潰。我注意到你在第二次調用的第四個參數中忘記了'release'之前的'&'。不過,我無法完成這項工作。建議?你對'hids_keyboard'例子有全面的改變嗎?還有其他一些你沒有提及的因素,比如可能需要將input_report_array的大小加倍,因爲現在有兩個索引,而不僅僅是一個索引等。許多事情都不清楚。提前致謝。 – Mojtaba