hid_host_demo: only accept incoming connection if status is ok

This commit is contained in:
Matthias Ringwald 2025-02-24 11:00:22 +01:00
parent c72af13194
commit b848f4ec55

View File

@ -343,11 +343,18 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
switch (hci_event_hid_meta_get_subevent_code(packet)){ switch (hci_event_hid_meta_get_subevent_code(packet)){
case HID_SUBEVENT_INCOMING_CONNECTION: case HID_SUBEVENT_INCOMING_CONNECTION:
// There is an incoming connection: we can accept it or decline it. // There is an incoming connection: we can accept it or decline it
// The hid_host_report_mode in the hid_host_accept_connection function
// allows the application to request a protocol mode. // If there are no resources to handle the connection,
// For available protocol modes, see hid_protocol_mode_t in btstack_hid.h file. // the status will be ERROR_CODE_MEMORY_CAPACITY_EXCEEDED
hid_host_accept_connection(hid_subevent_incoming_connection_get_hid_cid(packet), hid_host_report_mode);
// The hid_host_report_mode in the hid_host_accept_connection function
// allows the application to request a protocol mode.
// For available protocol modes, see hid_protocol_mode_t in btstack_hid.h file.
if (hid_subevent_incoming_connection_get_status(packet) == ERROR_CODE_SUCCESS) {
hid_host_accept_connection(hid_subevent_incoming_connection_get_hid_cid(packet), hid_host_report_mode);
}
break; break;
case HID_SUBEVENT_CONNECTION_OPENED: case HID_SUBEVENT_CONNECTION_OPENED: