Fix HFP query call status

This commit is contained in:
Josh Wu
2024-04-29 19:49:29 +08:00
committed by zxzxwu
parent 1b33c9eb74
commit c48568aabe
2 changed files with 14 additions and 10 deletions

View File

@@ -951,7 +951,7 @@ class HfProtocol(pyee.EventEmitter):
self.supported_ag_call_hold_operations = [ self.supported_ag_call_hold_operations = [
CallHoldOperation(operation.decode()) CallHoldOperation(operation.decode())
for operation in response.parameters for operation in response.parameters[0]
] ]
# 4.2.1.4 HF Indicators # 4.2.1.4 HF Indicators
@@ -1081,8 +1081,9 @@ class HfProtocol(pyee.EventEmitter):
mode=CallInfoMode(int(response.parameters[3])), mode=CallInfoMode(int(response.parameters[3])),
multi_party=CallInfoMultiParty(int(response.parameters[4])), multi_party=CallInfoMultiParty(int(response.parameters[4])),
) )
if len(response.parameters) >= 6:
call_info.number = response.parameters[5].decode()
if len(response.parameters) >= 7: if len(response.parameters) >= 7:
call_info.number = response.parameters[5]
call_info.type = int(response.parameters[6]) call_info.type = int(response.parameters[6])
calls.append(call_info) calls.append(call_info)
return calls return calls
@@ -1422,9 +1423,11 @@ class AgProtocol(pyee.EventEmitter):
return return
self.send_response( self.send_response(
'+CHLD:' '+CHLD: ({})'.format(
+ ','.join( ','.join(
operation.value for operation in self.supported_ag_call_hold_operations operation.value
for operation in self.supported_ag_call_hold_operations
)
) )
) )
self.send_ok() self.send_ok()
@@ -1557,15 +1560,16 @@ class AgProtocol(pyee.EventEmitter):
def _on_clcc(self) -> None: def _on_clcc(self) -> None:
for call in self.calls: 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 = ( response = (
f'+CLCC: {call.index}' f'+CLCC: {call.index}'
f',{call.direction.value}' f',{call.direction.value}'
f',{call.status.value}' f',{call.status.value}'
f',{call.mode.value}' f',{call.mode.value}'
f',{call.multi_party.value}' f',{call.multi_party.value}'
f',\"{call.number}\"' f'{number_text}'
if call.number is not None f'{type_text}'
else '' f',{call.type}' if call.type is not None else ''
) )
self.send_response(response) self.send_response(response)
self.send_ok() self.send_ok()

View File

@@ -311,7 +311,7 @@ async def test_query_calls_without_calls(
): ):
hf, ag = hfp_connections 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
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------