mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Fixed bug SPP in library
This commit is contained in:
parent
b97caf84de
commit
131550aa73
3 changed files with 13 additions and 4 deletions
4
BTD.cpp
4
BTD.cpp
|
@ -708,7 +708,11 @@ void BTD::HCI_task() {
|
||||||
}
|
}
|
||||||
PrintHex<uint8_t>(disc_bdaddr[0]);
|
PrintHex<uint8_t>(disc_bdaddr[0]);
|
||||||
#endif
|
#endif
|
||||||
|
// Clear these flags for a new connection
|
||||||
l2capConnectionClaimed = false;
|
l2capConnectionClaimed = false;
|
||||||
|
sdpConnectionClaimed = false;
|
||||||
|
rfcommConnectionClaimed = false;
|
||||||
|
|
||||||
hci_event_flag = 0;
|
hci_event_flag = 0;
|
||||||
hci_state = HCI_DONE_STATE;
|
hci_state = HCI_DONE_STATE;
|
||||||
}
|
}
|
||||||
|
|
2
BTD.h
2
BTD.h
|
@ -180,6 +180,8 @@ public:
|
||||||
uint8_t disc_bdaddr[6]; // Last incoming devices Bluetooth address
|
uint8_t disc_bdaddr[6]; // Last incoming devices Bluetooth address
|
||||||
uint8_t remote_name[30]; // First 30 chars of last remote name
|
uint8_t remote_name[30]; // First 30 chars of last remote name
|
||||||
uint8_t hci_version;
|
uint8_t hci_version;
|
||||||
|
bool sdpConnectionClaimed;
|
||||||
|
bool rfcommConnectionClaimed;
|
||||||
|
|
||||||
bool connectToWii; // Used to only send the ACL data to the wiimote
|
bool connectToWii; // Used to only send the ACL data to the wiimote
|
||||||
bool incomingWii;
|
bool incomingWii;
|
||||||
|
|
9
SPP.cpp
9
SPP.cpp
|
@ -79,12 +79,15 @@ void SPP::disconnect(){
|
||||||
l2cap_sdp_state = L2CAP_DISCONNECT_RESPONSE;
|
l2cap_sdp_state = L2CAP_DISCONNECT_RESPONSE;
|
||||||
}
|
}
|
||||||
void SPP::ACLData(uint8_t* l2capinbuf) {
|
void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
if(!pBtd->l2capConnectionClaimed && !connected && !RFCOMMConnected && !SDPConnected) {
|
if(!connected) {
|
||||||
if (l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) {
|
if (l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) {
|
||||||
if(((l2capinbuf[12] | (l2capinbuf[13] << 8)) == SDP_PSM) || ((l2capinbuf[12] | (l2capinbuf[13] << 8)) == RFCOMM_PSM)) {
|
if((l2capinbuf[12] | (l2capinbuf[13] << 8)) == SDP_PSM && !pBtd->sdpConnectionClaimed) {
|
||||||
pBtd->l2capConnectionClaimed = true; // Claim that the incoming connection belongs to this service
|
pBtd->sdpConnectionClaimed = true;
|
||||||
hci_handle = pBtd->hci_handle; // Store the HCI Handle for the connection
|
hci_handle = pBtd->hci_handle; // Store the HCI Handle for the connection
|
||||||
l2cap_sdp_state = L2CAP_SDP_WAIT; // Reset state
|
l2cap_sdp_state = L2CAP_SDP_WAIT; // Reset state
|
||||||
|
} else if((l2capinbuf[12] | (l2capinbuf[13] << 8)) == RFCOMM_PSM && !pBtd->rfcommConnectionClaimed) {
|
||||||
|
pBtd->rfcommConnectionClaimed = true;
|
||||||
|
hci_handle = pBtd->hci_handle; // Store the HCI Handle for the connection
|
||||||
l2cap_rfcomm_state = L2CAP_RFCOMM_WAIT; // Reset state
|
l2cap_rfcomm_state = L2CAP_RFCOMM_WAIT; // Reset state
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue