68 lines
3.5 KiB
Diff
68 lines
3.5 KiB
Diff
|
From fafe1fc716a9482e2ea883fb79edf90a7c89d33d Mon Sep 17 00:00:00 2001
|
||
|
From: Dylan Van Assche <me@dylanvanassche.be>
|
||
|
Date: Thu, 14 Apr 2022 20:43:42 +0200
|
||
|
Subject: [PATCH 13/26] bluetooth: support more AT+CIND? indicators
|
||
|
|
||
|
If ModemManager is available, report service status, roaming status and
|
||
|
signal strength as well when an AT+CIND? command is received.
|
||
|
---
|
||
|
src/modules/bluetooth/backend-native.c | 24 +++++++++++++++++-------
|
||
|
1 file changed, 17 insertions(+), 7 deletions(-)
|
||
|
|
||
|
diff --git a/src/modules/bluetooth/backend-native.c b/src/modules/bluetooth/backend-native.c
|
||
|
index 19ca497d5..fcbae5540 100644
|
||
|
--- a/src/modules/bluetooth/backend-native.c
|
||
|
+++ b/src/modules/bluetooth/backend-native.c
|
||
|
@@ -123,7 +123,9 @@ typedef enum pa_bluetooth_ag_to_hf_indicators {
|
||
|
CIND_CALL_HELD_INDICATOR = 3,
|
||
|
CIND_SERVICE_INDICATOR = 4,
|
||
|
CIND_BATT_CHG_INDICATOR = 5,
|
||
|
- CIND_INDICATOR_MAX = 6
|
||
|
+ CIND_ROAMING_INDICATOR = 6,
|
||
|
+ CIND_SIGNAL_STRENGTH_INDICATOR = 7,
|
||
|
+ CIND_INDICATOR_MAX = 8
|
||
|
} pa_bluetooth_ag_to_hf_indicators_t;
|
||
|
|
||
|
/* gateway features we support, which is as little as we can get away with */
|
||
|
@@ -822,14 +824,16 @@ static bool hfp_rfcomm_handle(int fd, pa_bluetooth_transport *t, const char *buf
|
||
|
|
||
|
return true;
|
||
|
} else if (c->state >= 1 && pa_startswith(buf, "AT+CIND=?")) {
|
||
|
- /* UPower backend available, declare support for more indicators */
|
||
|
- if (discovery->native_backend->upower) {
|
||
|
+ /* UPower and ModemManager backends available, declare support for more indicators */
|
||
|
+ if (discovery->native_backend->upower && discovery->native_backend->modemmanager && pa_modemmanager_has_modem(discovery->native_backend->modemmanager)) {
|
||
|
rfcomm_write_response(fd, "+CIND: "
|
||
|
MANDATORY_CALL_INDICATORS ","
|
||
|
"(\"service\",(0-1)),"
|
||
|
- "(\"battchg\",(0-5))");
|
||
|
+ "(\"battchg\",(0-5)),"
|
||
|
+ "(\"roam\",(0-1)),"
|
||
|
+ "(\"signal\",(0-5))");
|
||
|
|
||
|
- /* Minimal indicators supported without any additional backend */
|
||
|
+ /* Minimal indicators supported without any additional backends */
|
||
|
} else {
|
||
|
rfcomm_write_response(fd, "+CIND: "
|
||
|
MANDATORY_CALL_INDICATORS ","
|
||
|
@@ -845,8 +849,14 @@ static bool hfp_rfcomm_handle(int fd, pa_bluetooth_transport *t, const char *buf
|
||
|
|
||
|
return true;
|
||
|
} else if (c->state >= 2 && pa_startswith(buf, "AT+CIND?")) {
|
||
|
- if (discovery->native_backend->upower)
|
||
|
- rfcomm_write_response(fd, "+CIND: 0,0,0,0,%u", pa_upower_get_battery_level(discovery->native_backend->upower));
|
||
|
+ if (discovery->native_backend->upower && discovery->native_backend->modemmanager && pa_modemmanager_has_modem(discovery->native_backend->modemmanager))
|
||
|
+ rfcomm_write_response(fd, "+CIND: %u,%u,0,%u,%u,%u,%u",
|
||
|
+ discovery->native_backend->cind_call_indicator,
|
||
|
+ discovery->native_backend->cind_call_setup_indicator,
|
||
|
+ pa_modemmanager_has_service(discovery->native_backend->modemmanager),
|
||
|
+ pa_upower_get_battery_level(discovery->native_backend->upower),
|
||
|
+ pa_modemmanager_is_roaming(discovery->native_backend->modemmanager),
|
||
|
+ pa_modemmanager_get_signal_strength(discovery->native_backend->modemmanager));
|
||
|
else
|
||
|
rfcomm_write_response(fd, "+CIND: 0,0,0,0");
|
||
|
|
||
|
--
|
||
|
2.35.1
|
||
|
|