aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzxzxwu <92432172+zxzxwu@users.noreply.github.com>2024-05-02 01:17:17 +0800
committerGitHub <noreply@github.com>2024-05-02 01:17:17 +0800
commit26e6650038380acd3ea0d2e9796ea861b181404e (patch)
tree58090f00e7a3aaa5fa7438790bfc7bbbf3f998f8
parent1b33c9eb74b2cf131d1a4cc271852db931232a76 (diff)
parentc48568aabefc43b61ea50c91bfe43b3c9ed00bc7 (diff)
downloadbumble-26e6650038380acd3ea0d2e9796ea861b181404e.tar.gz
Merge pull request #477 from zxzxwu/hfp-ag
Fix HFP query call status
-rw-r--r--bumble/hfp.py20
-rw-r--r--tests/hfp_test.py4
2 files changed, 14 insertions, 10 deletions
diff --git a/bumble/hfp.py b/bumble/hfp.py
index ea64589..6727b3d 100644
--- a/bumble/hfp.py
+++ b/bumble/hfp.py
@@ -951,7 +951,7 @@ class HfProtocol(pyee.EventEmitter):
self.supported_ag_call_hold_operations = [
CallHoldOperation(operation.decode())
- for operation in response.parameters
+ for operation in response.parameters[0]
]
# 4.2.1.4 HF Indicators
@@ -1081,8 +1081,9 @@ class HfProtocol(pyee.EventEmitter):
mode=CallInfoMode(int(response.parameters[3])),
multi_party=CallInfoMultiParty(int(response.parameters[4])),
)
+ if len(response.parameters) >= 6:
+ call_info.number = response.parameters[5].decode()
if len(response.parameters) >= 7:
- call_info.number = response.parameters[5]
call_info.type = int(response.parameters[6])
calls.append(call_info)
return calls
@@ -1422,9 +1423,11 @@ class AgProtocol(pyee.EventEmitter):
return
self.send_response(
- '+CHLD:'
- + ','.join(
- operation.value for operation in self.supported_ag_call_hold_operations
+ '+CHLD: ({})'.format(
+ ','.join(
+ operation.value
+ for operation in self.supported_ag_call_hold_operations
+ )
)
)
self.send_ok()
@@ -1557,15 +1560,16 @@ class AgProtocol(pyee.EventEmitter):
def _on_clcc(self) -> None:
for call in self.calls:
+ number_text = f',\"{call.number}\"' if call.number is not None else ''
+ type_text = f',{call.type}' if call.type is not None else ''
response = (
f'+CLCC: {call.index}'
f',{call.direction.value}'
f',{call.status.value}'
f',{call.mode.value}'
f',{call.multi_party.value}'
- f',\"{call.number}\"'
- if call.number is not None
- else '' f',{call.type}' if call.type is not None else ''
+ f'{number_text}'
+ f'{type_text}'
)
self.send_response(response)
self.send_ok()
diff --git a/tests/hfp_test.py b/tests/hfp_test.py
index e2aed57..83b0d35 100644
--- a/tests/hfp_test.py
+++ b/tests/hfp_test.py
@@ -311,7 +311,7 @@ async def test_query_calls_without_calls(
):
hf, ag = hfp_connections
- await hf.query_current_calls() == []
+ assert await hf.query_current_calls() == []
# -----------------------------------------------------------------------------
@@ -331,7 +331,7 @@ async def test_query_calls_with_calls(
)
)
- await hf.query_current_calls() == ag.calls
+ assert await hf.query_current_calls() == ag.calls
# -----------------------------------------------------------------------------