problems about hog keyboard

91 views
Skip to first unread message

mikew

unread,
Aug 15, 2023, 6:35:55 AM8/15/23
to btstack-dev
Hi,

I am new in Bluetooth development. I used the latest version of BTstack as hog host, and got stuck in 2 kinds of keyboards for several days:

(1) Acer's keyboard OKW215: 
After connecting with the device, I didn't operate it and the connection is lost in 15 minutes automatically. 
What confused me is that each time it has different error code when disconnected. I try to find some tracks using wireshark and usb dongle but find it is disconnected without warning.

(2) Logitech's keyboard K580
After connecting with the device, the keyboard stop to send HID reports in 30s, and the connect still alive.

Those keyboards looks like trapped in some kind of sleep or power saving mode. I guess I miss something in initializing BTstack.
 
I attach part of my codes here:

    l2cap_init();

    sm_init();
    sm_set_authentication_requirements(
SM_AUTHREQ_MITM_PROTECTION | SM_AUTHREQ_SECURE_CONNECTION  );

    gatt_client_init();
    battery_service_client_init();

    sdp_init();

    gap_inquiry_set_lap(GAP_IAC_GENERAL_INQUIRY);
    gap_set_default_link_policy_settings(
LM_LINK_POLICY_ENABLE_SNIFF_MODE | LM_LINK_POLICY_ENABLE_ROLE_SWITCH  );
    gap_set_allow_role_switch(true);
    gap_set_bondable_mode(1);

    gap_inquiry_set_scan_activity(0x50, 0x40);
    gap_set_scan_parameters(1, 0x50, 0x40);

    gap_set_local_name("BTstack_demo");
    gap_discoverable_control(0);

    gap_random_address_set_mode(GAP_RANDOM_ADDRESS_TYPE_OFF);
    gap_random_address_set_update_period(10000);

    gap_whitelist_clear();

    hci_set_master_slave_policy(HCI_ROLE_MASTER);
    hci_set_inquiry_mode(INQUIRY_MODE_RSSI_AND_EIR);


Please let me know if there are some suggestions.

Thank you!

Matthias Ringwald

unread,
Aug 15, 2023, 6:38:54 AM8/15/23
to btsta...@googlegroups.com
Hi Mike

Does this also happen with the hog_keyboard_demo?

Please post HCI packet log files for analysis. On port/libusb, the log is in /tmp/hci_dump.pklg

Best
Matthias
> --
> You received this message because you are subscribed to the Google Groups "btstack-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to btstack-dev...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/btstack-dev/d43ea3d9-b44d-4128-8d05-85834fa9317an%40googlegroups.com.

348608849

unread,
Aug 15, 2023, 10:58:26 PM8/15/23
to btstack-dev
Hi Matthias,

I have tried many kinds of keyboards as well as hog_keyboard_demo to communicate with my host demo, and all of them except keyboard OKW215 and K580 works well. 

Packet logs of OKW215 and K580 are attached. Is there any suggestions?




okw215.pklg
k580.pklg

Matthias Ringwald

unread,
Aug 16, 2023, 3:51:16 AM8/16/23
to btsta...@googlegroups.com
Hi there

Thanks for the logs. Do you call gap_sniff_mode_exit(..)? There's an HCI Exit Sniff mode command, however, sniff mode is only used for Classic connection. Please remote that. I don't think this causes any problems, as the Bluetooth Controller just rejects it.

In the OKW215, there's a "HCI Disconnect: Reason: 0x0F - Connection Rejected Due To Unacceptable Device Address".
I haven't seen this error yet. Any idea what that could mean in your context?

In the K580 log, there's no disconnect.

Without a better idea, I would try to use a higher slave latency and connection interval, just to be on the safe side and see if that makes any difference.

Best
Matthias
> --
> You received this message because you are subscribed to the Google Groups "btstack-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to btstack-dev...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/btstack-dev/tencent_05F040997499B570D66FE17173BE60964308%40qq.com.
> <okw215.pklg><k580.pklg>

348608849

unread,
Aug 17, 2023, 12:08:39 AM8/17/23
to btstack-dev
Hi Matthias,

Thanks for your note. I will delete code about sniff mode.

I tried a higher slave latency and connection interval, but it makes no difference. 

In the OKW215, each time the report HCI_EVENT_DISCONNECTION_COMPLETE have different reason like 0x0f, 0x71 and so on. I guess the keyboard is disconnect all of a sudden. 

In the K580, it is still connected but I cound not find any HID report.

Since I cannot find the source code of those keyboards, maybe I should try to receive some HOG reports? Is it possible? 

Matthias Ringwald

unread,
Aug 20, 2023, 10:45:14 AM8/20/23
to btsta...@googlegroups.com
Hi there

Could you try with a different Bluetooth Controller (other USB stick) to see if it's a problem with your particular Controller?

Other than that, you can try with the same Controller and a different stack, e.g. bluez on Linux and test if it works correctly there. If yes, you can get an HCI log and compare it to the one from BTstack.

Best
Matthias
> --
> You received this message because you are subscribed to the Google Groups "btstack-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to btstack-dev...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/btstack-dev/tencent_6D6D20AEC7D7CDF2117E28D334131BAEEB05%40qq.com.

348608849

unread,
Aug 20, 2023, 10:59:00 PM8/20/23
to btstack-dev
Hi Matthias,

I try to compare the reports between Windows official stack and BTstack, and find the reason codes when disconnecting in OKW215 are the same. It is my fault to parse those reason codes too strictly.  After I adjust my handler function, the OKW215 works well now.

As for K580, the keyboard sends a Revd Connection Parameter Update Request 30s after connect start, while BTstack send this request before the encryption complete. Considering that it fits the time, I suspect the request will cause the problem. Logs in BTstack and Windows Bluetooth stack are attached, do you have any suggestion?

BTstack.pklg
Windows.cfa
Reply all
Reply to author
Forward
0 new messages