diff --git a/BTD.h b/BTD.h index becc3da3..cfbc2023 100755 --- a/BTD.h +++ b/BTD.h @@ -30,7 +30,7 @@ #define IOGEAR_GBU521_PID 0x21E8 /* Bluetooth dongle data taken from descriptors */ -#define BULK_MAXPKTSIZE 64 // max size for ACL data +#define BULK_MAXPKTSIZE 64 // Max size for ACL data // Used in control endpoint header for HCI Commands #define bmREQ_HCI_OUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_DEVICE @@ -117,17 +117,16 @@ /* Used for SDP channel */ #define L2CAP_SDP_WAIT 10 -#define L2CAP_SDP_REQUEST 11 #define L2CAP_SDP_SUCCESS 12 #define L2CAP_SDP_DONE 13 -#define L2CAP_DISCONNECT_RESPONSE 14 /* Used for RFCOMM channel */ #define L2CAP_RFCOMM_WAIT 15 -#define L2CAP_RFCOMM_REQUEST 16 #define L2CAP_RFCOMM_SUCCESS 17 #define L2CAP_RFCOMM_DONE 18 +#define L2CAP_DISCONNECT_RESPONSE 14 // Used for both SDP and RFCOMM channel + /* Bluetooth states used by some drivers */ #define TURN_ON_LED 19 #define PS3_ENABLE_SIXAXIS 20 @@ -149,13 +148,11 @@ /* L2CAP event flags for SDP channel */ #define L2CAP_FLAG_CONNECTION_SDP_REQUEST 0x00000100 -#define L2CAP_FLAG_CONFIG_SDP_REQUEST 0x00000200 #define L2CAP_FLAG_CONFIG_SDP_SUCCESS 0x00000400 #define L2CAP_FLAG_DISCONNECT_SDP_REQUEST 0x00000800 /* L2CAP event flags for RFCOMM channel */ #define L2CAP_FLAG_CONNECTION_RFCOMM_REQUEST 0x00001000 -#define L2CAP_FLAG_CONFIG_RFCOMM_REQUEST 0x00002000 #define L2CAP_FLAG_CONFIG_RFCOMM_SUCCESS 0x00004000 #define L2CAP_FLAG_DISCONNECT_RFCOMM_REQUEST 0x00008000 diff --git a/SPP.cpp b/SPP.cpp index 7a13ca1d..f21b6770 100644 --- a/SPP.cpp +++ b/SPP.cpp @@ -151,12 +151,10 @@ void SPP::ACLData(uint8_t* l2capinbuf) { } else if (l2capinbuf[8] == L2CAP_CMD_CONFIG_REQUEST) { if (l2capinbuf[12] == sdp_dcid[0] && l2capinbuf[13] == sdp_dcid[1]) { //Notify(PSTR("\r\nSDP Configuration Request"), 0x80); - identifier = l2capinbuf[9]; - l2cap_set_flag(L2CAP_FLAG_CONFIG_SDP_REQUEST); + pBtd->l2cap_config_response(hci_handle, l2capinbuf[9], sdp_scid); } else if (l2capinbuf[12] == rfcomm_dcid[0] && l2capinbuf[13] == rfcomm_dcid[1]) { //Notify(PSTR("\r\nRFCOMM Configuration Request"), 0x80); - identifier = l2capinbuf[9]; - l2cap_set_flag(L2CAP_FLAG_CONFIG_RFCOMM_REQUEST); + pBtd->l2cap_config_response(hci_handle, l2capinbuf[9], rfcomm_scid); } } else if (l2capinbuf[8] == L2CAP_CMD_DISCONNECT_REQUEST) { if (l2capinbuf[12] == sdp_dcid[0] && l2capinbuf[13] == sdp_dcid[1]) { @@ -403,7 +401,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) { connected = true; // The RFCOMM channel is now established sppIndex = 0; } -#ifdef DEBUG_USB_HOST +#ifdef EXTRADEBUG else if (rfcommChannelType != RFCOMM_DISC) { Notify(PSTR("\r\nUnsupported RFCOMM Data - ChannelType: "), 0x80); D_PrintHex (rfcommChannelType, 0x80); @@ -453,16 +451,6 @@ void SPP::SDP_task() { identifier++; delay(1); pBtd->l2cap_config_request(hci_handle, identifier, sdp_scid); - l2cap_sdp_state = L2CAP_SDP_REQUEST; - } - break; - case L2CAP_SDP_REQUEST: - if (l2cap_check_flag(L2CAP_FLAG_CONFIG_SDP_REQUEST)) { - l2cap_clear_flag(L2CAP_FLAG_CONFIG_SDP_REQUEST); // Clear flag -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nSDP Configuration Request"), 0x80); -#endif - pBtd->l2cap_config_response(hci_handle, identifier, sdp_scid); l2cap_sdp_state = L2CAP_SDP_SUCCESS; } break; @@ -520,16 +508,6 @@ void SPP::RFCOMM_task() { identifier++; delay(1); pBtd->l2cap_config_request(hci_handle, identifier, rfcomm_scid); - l2cap_rfcomm_state = L2CAP_RFCOMM_REQUEST; - } - break; - case L2CAP_RFCOMM_REQUEST: - if (l2cap_check_flag(L2CAP_FLAG_CONFIG_RFCOMM_REQUEST)) { - l2cap_clear_flag(L2CAP_FLAG_CONFIG_RFCOMM_REQUEST); // Clear flag -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nRFCOMM Configuration Request"), 0x80); -#endif - pBtd->l2cap_config_response(hci_handle, identifier, rfcomm_scid); l2cap_rfcomm_state = L2CAP_RFCOMM_SUCCESS; } break;