Set protocol shouldn’t have it’s own state, as it will then sometimes not call the other states afterwards

This commit is contained in:
Kristian Lauszus 2013-11-25 19:01:20 +01:00
parent 627c390191
commit bcc4afede5
2 changed files with 15 additions and 19 deletions

View file

@ -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:

13
BTHID.h
View file

@ -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