Fixed bug SPP in library

This commit is contained in:
Kristian Sloth Lauszus 2013-02-04 08:38:10 +01:00
parent b97caf84de
commit 131550aa73
3 changed files with 13 additions and 4 deletions

View file

@ -708,7 +708,11 @@ void BTD::HCI_task() {
}
PrintHex<uint8_t>(disc_bdaddr[0]);
#endif
l2capConnectionClaimed = false;
// Clear these flags for a new connection
l2capConnectionClaimed = false;
sdpConnectionClaimed = false;
rfcommConnectionClaimed = false;
hci_event_flag = 0;
hci_state = HCI_DONE_STATE;
}

2
BTD.h
View file

@ -180,6 +180,8 @@ public:
uint8_t disc_bdaddr[6]; // Last incoming devices Bluetooth address
uint8_t remote_name[30]; // First 30 chars of last remote name
uint8_t hci_version;
bool sdpConnectionClaimed;
bool rfcommConnectionClaimed;
bool connectToWii; // Used to only send the ACL data to the wiimote
bool incomingWii;

View file

@ -79,12 +79,15 @@ void SPP::disconnect(){
l2cap_sdp_state = L2CAP_DISCONNECT_RESPONSE;
}
void SPP::ACLData(uint8_t* l2capinbuf) {
if(!pBtd->l2capConnectionClaimed && !connected && !RFCOMMConnected && !SDPConnected) {
if(!connected) {
if (l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) {
if(((l2capinbuf[12] | (l2capinbuf[13] << 8)) == SDP_PSM) || ((l2capinbuf[12] | (l2capinbuf[13] << 8)) == RFCOMM_PSM)) {
pBtd->l2capConnectionClaimed = true; // Claim that the incoming connection belongs to this service
if((l2capinbuf[12] | (l2capinbuf[13] << 8)) == SDP_PSM && !pBtd->sdpConnectionClaimed) {
pBtd->sdpConnectionClaimed = true;
hci_handle = pBtd->hci_handle; // Store the HCI Handle for the connection
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
}
}