diff --git a/BTHID.cpp b/BTHID.cpp index ec0535af..02b9a884 100644 --- a/BTHID.cpp +++ b/BTHID.cpp @@ -254,7 +254,7 @@ void BTHID::L2CAP_task() { #ifdef DEBUG_USB_HOST Notify(PSTR("\r\nHID Control Successfully Configured"), 0x80); #endif - setProtocol(); + setProtocol(); // Set protocol before establishing HID interrupt channel l2cap_state = L2CAP_INTERRUPT_SETUP; } break; @@ -283,24 +283,21 @@ void BTHID::L2CAP_task() { #endif identifier++; pBtd->l2cap_config_request(hci_handle, identifier, control_scid); - l2cap_state = L2CAP_SET_PROTOCOL; - } - break; - - case L2CAP_SET_PROTOCOL: - if (l2cap_config_success_control_flag) { - setProtocol(); l2cap_state = L2CAP_CONTROL_CONFIG_REQUEST; } break; case L2CAP_CONTROL_CONFIG_REQUEST: + if (l2cap_config_success_control_flag) { + setProtocol(); // Set protocol before establishing HID interrupt channel + delay(1); // Short delay between commands - just to be sure #ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nSend HID Interrupt Connection Request"), 0x80); + Notify(PSTR("\r\nSend HID Interrupt Connection Request"), 0x80); #endif - identifier++; - pBtd->l2cap_connection_request(hci_handle, identifier, interrupt_dcid, HID_INTR_PSM); - l2cap_state = L2CAP_INTERRUPT_CONNECT_REQUEST; + identifier++; + pBtd->l2cap_connection_request(hci_handle, identifier, interrupt_dcid, HID_INTR_PSM); + l2cap_state = L2CAP_INTERRUPT_CONNECT_REQUEST; + } break; case L2CAP_INTERRUPT_CONNECT_REQUEST: diff --git a/BTHID.h b/BTHID.h index 21b92720..ddd26d59 100644 --- a/BTHID.h +++ b/BTHID.h @@ -31,15 +31,14 @@ // These states are used if the Arduino is the host #define L2CAP_CONTROL_CONNECT_REQUEST 3 -#define L2CAP_SET_PROTOCOL 4 -#define L2CAP_CONTROL_CONFIG_REQUEST 5 -#define L2CAP_INTERRUPT_CONNECT_REQUEST 6 +#define L2CAP_CONTROL_CONFIG_REQUEST 4 +#define L2CAP_INTERRUPT_CONNECT_REQUEST 5 -#define L2CAP_INTERRUPT_CONFIG_REQUEST 7 -#define L2CAP_DONE 8 +#define L2CAP_INTERRUPT_CONFIG_REQUEST 6 +#define L2CAP_DONE 7 -#define L2CAP_INTERRUPT_DISCONNECT 9 -#define L2CAP_CONTROL_DISCONNECT 10 +#define L2CAP_INTERRUPT_DISCONNECT 8 +#define L2CAP_CONTROL_DISCONNECT 9 /* L2CAP event flags */ #define L2CAP_FLAG_CONTROL_CONNECTED 0x01