mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-16 08:56:40 -05:00
bt/native: Parse specified number of arguments in IPHONEACCEV
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/482>
This commit is contained in:
parent
e6157c8b1f
commit
d2c97190ef
1 changed files with 36 additions and 17 deletions
|
|
@ -742,25 +742,44 @@ static void rfcomm_io_callback(pa_mainloop_api *io, pa_io_event *e, int fd, pa_i
|
||||||
rfcomm_write_response(fd, "+XAPL=iPhone,6");
|
rfcomm_write_response(fd, "+XAPL=iPhone,6");
|
||||||
do_reply = true;
|
do_reply = true;
|
||||||
} else if (sscanf(buf, "AT+IPHONEACCEV=%d", &num) == 1) {
|
} else if (sscanf(buf, "AT+IPHONEACCEV=%d", &num) == 1) {
|
||||||
char *substr = strchr(buf, ',');
|
char *substr = buf, *keystr;
|
||||||
bool isval = false;
|
int key, val, i;
|
||||||
int key, val;
|
|
||||||
|
|
||||||
for (; substr; substr = strchr(substr, ',')) {
|
|
||||||
substr++;
|
|
||||||
if (!isval) {
|
|
||||||
key = atoi(substr);
|
|
||||||
} else {
|
|
||||||
val = atoi(substr);
|
|
||||||
if (key == 1) {
|
|
||||||
pa_log_notice("Battery Level: %d0%%", val + 1);
|
|
||||||
} else if (key == 2) {
|
|
||||||
pa_log_notice("Dock Status: %s", val ? "docked" : "undocked");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
isval = !isval;
|
|
||||||
}
|
|
||||||
do_reply = true;
|
do_reply = true;
|
||||||
|
|
||||||
|
for (i = 0; i < num; ++i) {
|
||||||
|
keystr = strchr(substr, ',');
|
||||||
|
if (!keystr) {
|
||||||
|
pa_log_warn("%s misses key for argument #%d", buf, i);
|
||||||
|
do_reply = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
keystr++;
|
||||||
|
substr = strchr(keystr, ',');
|
||||||
|
if (!substr) {
|
||||||
|
pa_log_warn("%s misses value for argument #%d", buf, i);
|
||||||
|
do_reply = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
substr++;
|
||||||
|
|
||||||
|
key = atoi(keystr);
|
||||||
|
val = atoi(substr);
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case 1:
|
||||||
|
pa_log_notice("Battery Level: %d0%%", val + 1);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
pa_log_notice("Dock Status: %s", val ? "docked" : "undocked");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
pa_log_debug("Unexpected IPHONEACCEV key %#x", key);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!do_reply)
|
||||||
|
rfcomm_write_response(fd, "ERROR");
|
||||||
} else if (t->config) { /* t->config is only non-null for hfp profile */
|
} else if (t->config) { /* t->config is only non-null for hfp profile */
|
||||||
do_reply = hfp_rfcomm_handle(fd, t, buf);
|
do_reply = hfp_rfcomm_handle(fd, t, buf);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue