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:
Kristian Lauszus 2012-08-02 00:48:14 +02:00
parent b833daeec7
commit 8b7efc3ed6
2 changed files with 13 additions and 2 deletions

View file

@ -1001,7 +1001,8 @@ void RFCOMM::RFCOMM_task()
#ifdef DEBUG
Notify(PSTR("\r\nRFCOMM Successfully Configured"));
#endif
rfcommAvailable = 0; // Reset numbers of bytes available
rfcommAvailable = 0; // Reset number of bytes available
bytesReceived = 0; // Reset number of bytes received
RFCOMMConnected = true;
l2cap_rfcomm_state = L2CAP_RFCOMM_DONE;
}
@ -1035,6 +1036,15 @@ void RFCOMM::readReport() {
for(uint8_t i = 0; i < length; i++)
rfcommDataBuffer[rfcommAvailable+i] = l2capinbuf[11+i+offset];
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
Notify(PSTR("\r\nRFCOMM Data Available: "));
Serial.print(rfcommAvailable);

View file

@ -286,7 +286,8 @@ private:
uint8_t rfcommDataBuffer[256]; // Create a 256 sized buffer for incoming data
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 */
void HCI_event_task(); //poll the HCI event pipe