Skip to content

Commit 2672010

Browse files
committed
Increase call status polling interval to fix DECLINED calls detection
On Huawei E1550 decreasing polling interval below 1 second causes "+CME ERROR: 100" following by TimeoutError so integration returns NOT_ANSWERED instead of DECLINED.
1 parent 203ee47 commit 2672010

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

custom_components/gsm_call/hardware/at_dialer.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ async def dial(self, modem: Modem, phone_number: str) -> EndedReason:
2323
lines = await modem.execute_at(
2424
f"{self.at_command}+{phone_number};",
2525
timeout=10,
26-
end_markers=["OK", "ERROR", "BUSY", "NO CARRIER"]
26+
end_markers=["OK", "ERROR", "BUSY", "NO CARRIER", "+CME ERROR"]
2727
)
28-
reply = "\n".join(lines)
28+
reply = " ".join(lines)
2929
_LOGGER.debug(f"Modem replied with {reply}")
3030

3131
if "BUSY" in reply:
@@ -40,7 +40,7 @@ async def dial(self, modem: Modem, phone_number: str) -> EndedReason:
4040
ended_reason = EndedReason.NOT_ANSWERED
4141

4242
_LOGGER.debug("Hanging up...")
43-
modem.writer.write(b"AT+CHUP\r\n")
43+
modem.send_command("AT+CHUP")
4444
_LOGGER.info(f"Call ended: {ended_reason}")
4545

4646
return ended_reason
@@ -60,9 +60,9 @@ async def _wait_for_answer(self, modem: Modem):
6060
lines = await modem.execute_at(
6161
"AT+CLCC",
6262
timeout=2,
63-
end_markers=["OK", "ERROR"]
63+
end_markers=["OK", "ERROR", "+CME ERROR"]
6464
)
65-
reply = "\n".join(lines)
65+
reply = " ".join(lines)
6666
_LOGGER.debug(f"Modem replied with {reply}")
6767

6868
if not is_ringing and "+CLCC: 1,0,3" in reply:
@@ -78,4 +78,5 @@ async def _wait_for_answer(self, modem: Modem):
7878
if "+CLCC: 1,0" not in reply:
7979
return EndedReason.DECLINED
8080

81-
await asyncio.sleep(.5)
81+
# Intervals lower than 1 sec are causing "+CME ERROR: 100" on some modems
82+
await asyncio.sleep(1)

0 commit comments

Comments
 (0)