From 5045b73fdb3498cbd6b380ef393e974592df684c Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 28 Sep 2023 10:14:20 +0200 Subject: [PATCH] alpakka: test classic hid --- example/hid_host_demo.c | 4 +++- example/hid_keyboard_demo.c | 22 +++++++++------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/example/hid_host_demo.c b/example/hid_host_demo.c index ff6361d5a..b31f85887 100644 --- a/example/hid_host_demo.c +++ b/example/hid_host_demo.c @@ -59,7 +59,7 @@ // MBP 2016 static const char * remote_addr_string = "F4-0F-24-3B-1B-E1"; // iMpulse static const char * remote_addr_string = "64:6E:6C:C1:AA:B5"; // Logitec -static const char * remote_addr_string = "00:1F:20:86:DF:52"; +static const char * remote_addr_string = "00:1A:7D:DA:71:04"; static bd_addr_t remote_addr; @@ -334,6 +334,8 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack } else { printf("Cannot handle input report, HID Descriptor is not available, status 0x%02x\n", status); } + gap_discoverable_control(0); + gap_connectable_control(0); break; case HID_SUBEVENT_REPORT: diff --git a/example/hid_keyboard_demo.c b/example/hid_keyboard_demo.c index 4686fd05b..ecd32bacb 100644 --- a/example/hid_keyboard_demo.c +++ b/example/hid_keyboard_demo.c @@ -363,6 +363,11 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * pack printf("HID Connected, sending demo text...\n"); demo_text_timer_handler(NULL); #endif + hid_device_request_can_send_now_event(hid_cid); + + gap_discoverable_control(0); + gap_connectable_control(0); + break; case HID_SUBEVENT_CONNECTION_CLOSED: btstack_run_loop_remove_timer(&send_timer); @@ -371,19 +376,10 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * pack hid_cid = 0; break; case HID_SUBEVENT_CAN_SEND_NOW: - if (send_keycode){ - send_report(send_modifier, send_keycode); - // schedule key up - send_keycode = 0; - send_modifier = 0; - btstack_run_loop_set_timer_handler(&send_timer, trigger_key_up); - btstack_run_loop_set_timer(&send_timer, TYPING_KEYDOWN_MS); - } else { - send_report(0, 0); - // schedule next key down - btstack_run_loop_set_timer_handler(&send_timer, send_next); - btstack_run_loop_set_timer(&send_timer, TYPING_DELAY_MS); - } + send_report(send_modifier, send_keycode++); + + btstack_run_loop_set_timer_handler(&send_timer, trigger_key_up); + btstack_run_loop_set_timer(&send_timer, 5); btstack_run_loop_add_timer(&send_timer); break; default: