diff --git a/BTD.cpp b/BTD.cpp index a5ade81c..585d8f2b 100644 --- a/BTD.cpp +++ b/BTD.cpp @@ -273,7 +273,6 @@ void BTD::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto if(pollInterval < pep->bInterval) // Set the polling interval as the largest polling interval obtained from endpoints pollInterval = pep->bInterval; bNumEP++; - return; } void BTD::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) { Notify(PSTR("\r\nEndpoint descriptor:")); @@ -914,7 +913,6 @@ void BTD::setBdaddr(uint8_t* BDADDR) { } PrintHex(my_bdaddr[0]); #endif - return; } void BTD::setMoveBdaddr(uint8_t* BDADDR) { /* Set the internal bluetooth address */ @@ -939,5 +937,4 @@ void BTD::setMoveBdaddr(uint8_t* BDADDR) { } PrintHex(my_bdaddr[0]); #endif - return; } \ No newline at end of file diff --git a/SPP.cpp b/SPP.cpp index ae9f4745..5a155e00 100644 --- a/SPP.cpp +++ b/SPP.cpp @@ -243,30 +243,30 @@ void SPP::ACLData(uint8_t* l2capinbuf) { } if(connected) { /* Read the incoming message */ - if(rfcommChannelType != RFCOMM_UIH || rfcommChannel != rfcommChannelConnection) - return; - uint8_t length = l2capinbuf[10] >> 1; // Get length - if(rfcommAvailable + length > 256) - return; // Return if the buffer would be full - uint8_t offset = l2capinbuf[4]-length-4; // See if there is credit - for(uint8_t i = 0; i < length; i++) - rfcommDataBuffer[rfcommAvailable+i] = l2capinbuf[11+i+offset]; - rfcommAvailable += length; + if(rfcommChannelType == RFCOMM_UIH && rfcommChannel == rfcommChannelConnection) { + uint8_t length = l2capinbuf[10] >> 1; // Get length + if(rfcommAvailable + length <= 256) { // Don't add data to buffer if it would be full + uint8_t offset = l2capinbuf[4]-length-4; // See if there is credit + for(uint8_t i = 0; i < length; i++) + rfcommDataBuffer[rfcommAvailable+i] = l2capinbuf[11+i+offset]; + rfcommAvailable += length; + } #ifdef EXTRADEBUG - Notify(PSTR("\r\nRFCOMM Data Available: ")); - Serial.print(rfcommAvailable); - if (offset) { - Notify(PSTR(" - Credit: 0x")); - Serial.print(l2capinbuf[11],HEX); - } + Notify(PSTR("\r\nRFCOMM Data Available: ")); + Serial.print(rfcommAvailable); + if (offset) { + Notify(PSTR(" - Credit: 0x")); + Serial.print(l2capinbuf[11],HEX); + } #endif + } #ifdef PRINTREPORT // Uncomment "#define PRINTREPORT" to print the report send to the Arduino via Bluetooth - if(rfcommChannelType != RFCOMM_UIH || rfcommChannel != rfcommChannelConnection) - return; - uint8_t length = l2capinbuf[10] >> 1; // Get length - uint8_t offset = l2capinbuf[4]-length-4; // See if there is credit - for(uint8_t i = 0; i < length; i++) - Serial.write(l2capinbuf[i+11+offset]); + if(rfcommChannelType == RFCOMM_UIH && rfcommChannel == rfcommChannelConnection) { + uint8_t length = l2capinbuf[10] >> 1; // Get length + uint8_t offset = l2capinbuf[4]-length-4; // See if there is credit + for(uint8_t i = 0; i < length; i++) + Serial.write(l2capinbuf[i+11+offset]); + } #endif } else { if(rfcommChannelType == RFCOMM_SABM) { // SABM Command - this is sent twice: once for channel 0 and then for the channel to establish