diff --git a/example/hid_host_demo.c b/example/hid_host_demo.c index cfb36e7ab..71826bc24 100644 --- a/example/hid_host_demo.c +++ b/example/hid_host_demo.c @@ -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)){ case HID_SUBEVENT_INCOMING_CONNECTION: - // 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. - // For available protocol modes, see hid_protocol_mode_t in btstack_hid.h file. - hid_host_accept_connection(hid_subevent_incoming_connection_get_hid_cid(packet), hid_host_report_mode); + // There is an incoming connection: we can accept it or decline it + + // If there are no resources to handle the connection, + // the status will be ERROR_CODE_MEMORY_CAPACITY_EXCEEDED + + // 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; case HID_SUBEVENT_CONNECTION_OPENED: