Verified Commit aff9bf69 authored by Dylan Van Assche's avatar Dylan Van Assche
Browse files

bluetooth: strip additional out-of-spec '\r\n' chars

Some HF devices do not comply strictly with the HFP specification
and send additional '\r\n' sequences besides the expected ones.
This breaks AT command parsing in PulseAudio.

To work around this problem, strip these characters before processing
the AT command and responses.
parent d2748e19
Pipeline #580575 passed with stages
in 2 minutes and 35 seconds
......@@ -1556,19 +1556,33 @@ static void rfcomm_io_callback(pa_mainloop_api *io, pa_io_event *e, int fd, pa_i
}
if (events & PA_IO_EVENT_INPUT) {
char buf[512];
char buf[512], raw_buf[512];
ssize_t len;
int gain, dummy;
bool do_reply = false;
int vendor, product, version, features;
int num;
int num, i, j;
len = pa_read(fd, buf, 511, NULL);
len = pa_read(fd, raw_buf, 511, NULL);
if (len < 0) {
pa_log_error("RFCOMM read error: %s", pa_cstrerror(errno));
goto fail;
}
buf[len] = 0;
raw_buf[len] = 0;
/*
* Filter '\r' and '\n' characters out since some HF devices
* send too much \r\n sequences in their responses
*/
memset(buf, '\0', sizeof(char) * 512);
j=0;
for (i=0; i<512; i++) {
if (raw_buf[i] == '\r' || raw_buf[i] == '\n')
continue;
buf[j] = raw_buf[i];
j++;
}
buf[j] = 0;
pa_log_debug("RFCOMM << %s", buf);
/* There are only four HSP AT commands:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment