Now works with Galaxy S running Gingerbread

Thanks to Sebastian for feedback
This commit is contained in:
Kristian Lauszus 2012-07-31 19:07:23 +02:00
parent a8e751bb3f
commit abd6048bab

View file

@ -844,13 +844,13 @@ void RFCOMM::ACL_event_task()
#endif #endif
sendRfcommCredit(rfcommChannelPermanent,rfcommDirection,0,RFCOMM_UIH,0x10,0xFF); // 255 credit sendRfcommCredit(rfcommChannelPermanent,rfcommDirection,0,RFCOMM_UIH,0x10,0xFF); // 255 credit
creditSent = true; creditSent = true;
timer = millis();
waitForLastCommand = true;
} }
} else if(rfcommChannelType == RFCOMM_UIH && l2capinbuf[10] == 0x01) { // UIH Command with credit } else if(rfcommChannelType == RFCOMM_UIH && l2capinbuf[10] == 0x01) { // UIH Command with credit
#ifdef DEBUG #ifdef DEBUG
Notify(PSTR("\r\nReceived UIH Command with credit")); Notify(PSTR("\r\nReceived UIH Command with credit"));
#endif #endif
timer = millis();
waitForLastCommand = true;
} else if(rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_RPN_CMD) { // UIH Remote Port Negotiation Command } else if(rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_RPN_CMD) { // UIH Remote Port Negotiation Command
#ifdef DEBUG #ifdef DEBUG
Notify(PSTR("\r\nReceived UIH Remote Port Negotiation Command")); Notify(PSTR("\r\nReceived UIH Remote Port Negotiation Command"));
@ -1030,11 +1030,7 @@ void RFCOMM::readReport() {
if(rfcommAvailable + length > 256) if(rfcommAvailable + length > 256)
return; // Return if the buffer would be full return; // Return if the buffer would be full
uint8_t offset; uint8_t offset = l2capinbuf[4]-length-4; // See if there is credit
if(l2capinbuf[4] == length+4)
offset = 0;
else
offset = 1; // There must be credit
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];
@ -1042,19 +1038,17 @@ void RFCOMM::readReport() {
#ifdef EXTRADEBUG #ifdef EXTRADEBUG
Notify(PSTR("\r\nRFCOMM Data Available: ")); Notify(PSTR("\r\nRFCOMM Data Available: "));
Serial.print(rfcommAvailable); Serial.print(rfcommAvailable);
if (offset) {
Notify(PSTR(" - Credit: 0x"));
Serial.print(l2capinbuf[11],HEX);
}
#endif #endif
} }
void RFCOMM::printReport() { //Uncomment "#define PRINTREPORT" to print the report send to the Arduino void RFCOMM::printReport() { //Uncomment "#define PRINTREPORT" to print the report send to the Arduino
if(rfcommChannelType != RFCOMM_UIH || rfcommChannel != rfcommChannelPermanent) if(rfcommChannelType != RFCOMM_UIH || rfcommChannel != rfcommChannelPermanent)
return; return;
uint8_t length = l2capinbuf[10] >> 1; // Get length uint8_t length = l2capinbuf[10] >> 1; // Get length
uint8_t offset = l2capinbuf[4]-length-4; // See if there is credit
uint8_t offset;
if(l2capinbuf[4] == length+4)
offset = 0;
else
offset = 1; // There must be credit
for(uint8_t i = 0; i < length; i++) for(uint8_t i = 0; i < length; i++)
Serial.write(l2capinbuf[i+11+offset]); Serial.write(l2capinbuf[i+11+offset]);
} }