diff --git a/SPP.cpp b/SPP.cpp index 061a85de..d13e2621 100644 --- a/SPP.cpp +++ b/SPP.cpp @@ -72,9 +72,10 @@ void SPP::disconnect(){ // First the two L2CAP channels has to be disconencted and then the HCI connection if(RFCOMMConnected) pBtd->l2cap_disconnection_request(hci_handle,0x0A, rfcomm_scid, rfcomm_dcid); + if(RFCOMMConnected && SDPConnected) + delay(1); // Add delay between commands if(SDPConnected) pBtd->l2cap_disconnection_request(hci_handle,0x0B, sdp_scid, sdp_dcid); - l2cap_event_flag = 0; // Reset flags l2cap_sdp_state = L2CAP_DISCONNECT_RESPONSE; } void SPP::ACLData(uint8_t* l2capinbuf) { @@ -430,6 +431,7 @@ void SPP::SDP_task() { RFCOMMConnected = false; SDPConnected = false; pBtd->hci_disconnect(hci_handle); + l2cap_event_flag = 0; // Reset flags l2cap_sdp_state = L2CAP_SDP_WAIT; l2cap_rfcomm_state = L2CAP_RFCOMM_WAIT; }