From 02bc55643943141d6792989db494bb3ff5b2cf57 Mon Sep 17 00:00:00 2001 From: Joao Mario Lago Date: Mon, 16 Dec 2024 10:44:44 -0300 Subject: [PATCH] backend: modem: at: Change fetch IMEI impl * Change to use by default AT+CGSN instead of AT+CGSN=1 as provided in manual since some modems does not implement it, and only use AT+CGSN=1 to fallback --- backend/modem/at.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/modem/at.py b/backend/modem/at.py index 14575b5..a7ee5e3 100644 --- a/backend/modem/at.py +++ b/backend/modem/at.py @@ -215,7 +215,10 @@ async def get_serial_number(self) -> ATResponse: return await self.command(ATCommand.IMEI_SN, ATDivider.EQ, '0') async def get_imei(self) -> ATResponse: - return await self.command(ATCommand.IMEI_SN, ATDivider.EQ, '1') + try: + return await self.command(ATCommand.IMEI_SN, cmd_id_response=False) + except SerialSafeReadFailed: + return await self.command(ATCommand.IMEI_SN, ATDivider.EQ, '1') async def get_international_mobile_subscriber_id(self) -> ATResponse: return await self.command(ATCommand.IMSI, cmd_id_response=False)