mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Set protocol before establishing interrupt channel
This commit is contained in:
parent
4099314100
commit
253b43c06f
2 changed files with 23 additions and 13 deletions
23
BTHID.cpp
23
BTHID.cpp
|
@ -248,6 +248,7 @@ void BTHID::L2CAP_task() {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nHID Control Successfully Configured"), 0x80);
|
Notify(PSTR("\r\nHID Control Successfully Configured"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
|
setProtocol();
|
||||||
l2cap_state = L2CAP_INTERRUPT_SETUP;
|
l2cap_state = L2CAP_INTERRUPT_SETUP;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -276,19 +277,24 @@ void BTHID::L2CAP_task() {
|
||||||
#endif
|
#endif
|
||||||
identifier++;
|
identifier++;
|
||||||
pBtd->l2cap_config_request(hci_handle, identifier, control_scid);
|
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;
|
l2cap_state = L2CAP_CONTROL_CONFIG_REQUEST;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case L2CAP_CONTROL_CONFIG_REQUEST:
|
case L2CAP_CONTROL_CONFIG_REQUEST:
|
||||||
if (l2cap_config_success_control_flag) {
|
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nSend HID Interrupt Connection Request"), 0x80);
|
Notify(PSTR("\r\nSend HID Interrupt Connection Request"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
identifier++;
|
identifier++;
|
||||||
pBtd->l2cap_connection_request(hci_handle, identifier, interrupt_dcid, HID_INTR_PSM);
|
pBtd->l2cap_connection_request(hci_handle, identifier, interrupt_dcid, HID_INTR_PSM);
|
||||||
l2cap_state = L2CAP_INTERRUPT_CONNECT_REQUEST;
|
l2cap_state = L2CAP_INTERRUPT_CONNECT_REQUEST;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case L2CAP_INTERRUPT_CONNECT_REQUEST:
|
case L2CAP_INTERRUPT_CONNECT_REQUEST:
|
||||||
|
@ -310,7 +316,6 @@ void BTHID::L2CAP_task() {
|
||||||
pBtd->connectToHIDDevice = false;
|
pBtd->connectToHIDDevice = false;
|
||||||
pBtd->pairWithHIDDevice = false;
|
pBtd->pairWithHIDDevice = false;
|
||||||
connected = true;
|
connected = true;
|
||||||
setProtocol();
|
|
||||||
onInit();
|
onInit();
|
||||||
l2cap_state = L2CAP_DONE;
|
l2cap_state = L2CAP_DONE;
|
||||||
}
|
}
|
||||||
|
@ -378,6 +383,10 @@ void BTHID::Run() {
|
||||||
/* HID Commands */
|
/* HID Commands */
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
void BTHID::setProtocol() {
|
void BTHID::setProtocol() {
|
||||||
|
#ifdef DEBUG_USB_HOST
|
||||||
|
Notify(PSTR("\r\nSet protocol mode: "), 0x80);
|
||||||
|
D_PrintHex<uint8_t > (protocolMode, 0x80);
|
||||||
|
#endif
|
||||||
uint8_t command = 0x70 | protocolMode; // Set Protocol, see HID specs page 33
|
uint8_t command = 0x70 | protocolMode; // Set Protocol, see HID specs page 33
|
||||||
pBtd->L2CAP_Command(hci_handle, &command, 1, control_scid[0], control_scid[1]);
|
pBtd->L2CAP_Command(hci_handle, &command, 1, control_scid[0], control_scid[1]);
|
||||||
}
|
}
|
||||||
|
|
13
BTHID.h
13
BTHID.h
|
@ -31,14 +31,15 @@
|
||||||
|
|
||||||
// These states are used if the Arduino is the host
|
// These states are used if the Arduino is the host
|
||||||
#define L2CAP_CONTROL_CONNECT_REQUEST 3
|
#define L2CAP_CONTROL_CONNECT_REQUEST 3
|
||||||
#define L2CAP_CONTROL_CONFIG_REQUEST 4
|
#define L2CAP_SET_PROTOCOL 4
|
||||||
#define L2CAP_INTERRUPT_CONNECT_REQUEST 5
|
#define L2CAP_CONTROL_CONFIG_REQUEST 5
|
||||||
|
#define L2CAP_INTERRUPT_CONNECT_REQUEST 6
|
||||||
|
|
||||||
#define L2CAP_INTERRUPT_CONFIG_REQUEST 6
|
#define L2CAP_INTERRUPT_CONFIG_REQUEST 7
|
||||||
#define L2CAP_DONE 7
|
#define L2CAP_DONE 8
|
||||||
|
|
||||||
#define L2CAP_INTERRUPT_DISCONNECT 8
|
#define L2CAP_INTERRUPT_DISCONNECT 9
|
||||||
#define L2CAP_CONTROL_DISCONNECT 9
|
#define L2CAP_CONTROL_DISCONNECT 10
|
||||||
|
|
||||||
/* L2CAP event flags */
|
/* L2CAP event flags */
|
||||||
#define L2CAP_FLAG_CONTROL_CONNECTED 0x01
|
#define L2CAP_FLAG_CONTROL_CONNECTED 0x01
|
||||||
|
|
Loading…
Reference in a new issue