mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Now sends credit, so the communication never terminates
The Arduino has to keep sending credit, so the other device knows that it can keep sending bytes to the Arduino
This commit is contained in:
parent
b833daeec7
commit
8b7efc3ed6
2 changed files with 13 additions and 2 deletions
12
RFCOMM.cpp
12
RFCOMM.cpp
|
@ -1001,7 +1001,8 @@ void RFCOMM::RFCOMM_task()
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Notify(PSTR("\r\nRFCOMM Successfully Configured"));
|
Notify(PSTR("\r\nRFCOMM Successfully Configured"));
|
||||||
#endif
|
#endif
|
||||||
rfcommAvailable = 0; // Reset numbers of bytes available
|
rfcommAvailable = 0; // Reset number of bytes available
|
||||||
|
bytesReceived = 0; // Reset number of bytes received
|
||||||
RFCOMMConnected = true;
|
RFCOMMConnected = true;
|
||||||
l2cap_rfcomm_state = L2CAP_RFCOMM_DONE;
|
l2cap_rfcomm_state = L2CAP_RFCOMM_DONE;
|
||||||
}
|
}
|
||||||
|
@ -1035,6 +1036,15 @@ void RFCOMM::readReport() {
|
||||||
for(uint8_t i = 0; i < length; i++)
|
for(uint8_t i = 0; i < length; i++)
|
||||||
rfcommDataBuffer[rfcommAvailable+i] = l2capinbuf[11+i+offset];
|
rfcommDataBuffer[rfcommAvailable+i] = l2capinbuf[11+i+offset];
|
||||||
rfcommAvailable += length;
|
rfcommAvailable += length;
|
||||||
|
bytesReceived += length;
|
||||||
|
if(bytesReceived > 200) {
|
||||||
|
bytesReceived = 0;
|
||||||
|
sendRfcommCredit(rfcommChannelPermanent,rfcommDirection,0,RFCOMM_UIH,0x10,0xFF); // Send 255 more credit
|
||||||
|
#ifdef EXTRADEBUG
|
||||||
|
Notify(PSTR("\r\nSent more credit"));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR("\r\nRFCOMM Data Available: "));
|
Notify(PSTR("\r\nRFCOMM Data Available: "));
|
||||||
Serial.print(rfcommAvailable);
|
Serial.print(rfcommAvailable);
|
||||||
|
|
1
RFCOMM.h
1
RFCOMM.h
|
@ -287,6 +287,7 @@ private:
|
||||||
uint8_t rfcommAvailable;
|
uint8_t rfcommAvailable;
|
||||||
|
|
||||||
bool firstMessage; // Used to see if it's the first SDP request received
|
bool firstMessage; // Used to see if it's the first SDP request received
|
||||||
|
uint8_t bytesReceived; // Counter to see when it's time to send more credit
|
||||||
|
|
||||||
/* State machines */
|
/* State machines */
|
||||||
void HCI_event_task(); //poll the HCI event pipe
|
void HCI_event_task(); //poll the HCI event pipe
|
||||||
|
|
Loading…
Reference in a new issue