From aef4a5ad652b142ddbd8de6c27973e8f62a1a70a Mon Sep 17 00:00:00 2001 From: korolev Date: Wed, 29 Jan 2025 15:30:39 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D0=B8=20=D1=81=D0=B8?= =?UTF-8?q?=D0=BC=20=D0=BF=D1=80=D0=BE=D1=84=D0=B8=D0=BB=D0=B5=D0=B9=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0=20=D1=83=D0=B4=D0=B0?= =?UTF-8?q?=D0=BB=D0=BE=D1=81=D1=8C=20=D0=B2=D0=BA=D0=BB=D1=8E=D1=87=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BF=D1=80=D0=BE=D1=84=D0=B8=D0=BB=D1=8C=20?= =?UTF-8?q?=D0=B8=D0=BB=D0=B8=20=D0=BD=D0=B5=D1=82,=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D0=BA=D0=B0=20=D0=BF=D1=80=D0=BE=D1=85=D0=BE?= =?UTF-8?q?=D0=B4=D0=B8=D1=82=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=BE=D0=BC?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=B0=20id=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D1=84=D0=B8=D0=BB=D1=8F,=20=D0=BF=D1=80=D0=B8?= =?UTF-8?q?=D1=87=D0=B8=D0=BD=D0=B0=20=D0=B2=D0=BD=D0=B5=D1=81=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B8=D0=B7=D0=B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=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/AtGsmTelitLe910_Ecall.c | 88 ++++++++++++++++++++++++++++++++++--- 1 file changed, 83 insertions(+), 5 deletions(-) diff --git a/Src/AtGsmTelitLe910_Ecall.c b/Src/AtGsmTelitLe910_Ecall.c index bf5dc01..8575b58 100644 --- a/Src/AtGsmTelitLe910_Ecall.c +++ b/Src/AtGsmTelitLe910_Ecall.c @@ -42,18 +42,96 @@ AtCommandResult AtGsmTelitLe910_EcallSetModeBattle(tAtCmd *env) { AtCommandResult AtGsmTelitLe910_SIMCardDetect(tAtCmd *env) { AtCmdPrepare(env); - + AtCmdRxClear(env); AtCmdSendStatic(env, "AT#SIMDET=1\r\n"); + uint32_t timeout = SystemGetMs() + 4000; - return AtCmdOkErrAnswer(env, env->stdRxTimeout); + while ( (AtCmdReceiveNextLine(env, 500) == AT_OK) && (timeout > SystemGetMs()) ) { + if(AtCmdRxBeginWithStatic(env, "OK") == AT_OK){ + AtCmdPrepare(env); + AtCmdRxClear(env); + SystemDelayMs(500); + AtCmdSendStatic(env, "AT#CIMI\r\n"); + timeout = SystemGetMs() + 4000; + while ( (AtCmdReceiveNextLine(env, 500) == AT_OK) || (timeout > SystemGetMs()) ) { + if(AtCmdRxBeginWithStatic(env, "OK") == AT_OK){ + SystemDelayMs(1000); + return AT_OK; + } else if(AtCmdRxBeginWithStatic(env, "+CME ERROR: SIM not inserted") == AT_OK){ + AtCmdPrepare(env); + AtCmdRxClear(env); + SystemDelayMs(500); + AtCmdSendStatic(env, "AT#SIMDET=1\r\n"); + AtCmdPrepare(env); + AtCmdRxClear(env); + SystemDelayMs(500); + AtCmdSendStatic(env, "AT#CIMI\r\n"); + continue; + } + if(timeout < SystemGetMs()){ + return AT_TIMEOUT; + } + } + if(timeout < SystemGetMs()){ + return AT_TIMEOUT; + } else { + return AT_ERROR; + } + } else { + continue; + } + } + return AT_ERROR; + +///=================================================== +// +// AtCmdPrepare(env); +// AtCmdRxClear(env); +// AtCmdSendStatic(env, "AT#SIMDET=1\r\n"); +// +// uint32_t timeout = SystemGetMs() + 4000; +// +// while ( (AtCmdReceiveNextLine(env, 500) == AT_OK) && (timeout > SystemGetMs()) ) { +// if (AtCmdRxBeginWithStatic(env, "")) { +// if (AtCmdRxBeginWithStatic(env, "OK")) { +// AtCmdPrepare(env); +// AtCmdRxClear(env); +// SystemDelayMs(500); +// AtCmdSendStatic(env, "AT#CIMI\r\n"); +// timeout = SystemGetMs() + 4000; +// +// while ((AtCmdReceiveNextLine(env, 500) == AT_OK) && (timeout > SystemGetMs())) { +// if (AtCmdRxBeginWithStatic(env, "#CIMI: ")) { +// SystemDelayMs(1000); +// return AT_OK; +// } else if (AtCmdRxBeginWithStatic(env, "+CME ERROR: SIM not inserted")) { +// AtCmdPrepare(env); +// AtCmdRxClear(env); +// SystemDelayMs(500); +// AtCmdSendStatic(env, "AT#CIMI\r\n"); +// continue; +// } +// } +// } else { +// AtCmdPrepare(env); +// AtCmdRxClear(env); +// SystemDelayMs(500); +// AtCmdSendStatic(env, "AT#SIMDET=1\r\n"); +// continue; +// } +// } +// } +// +// return AT_ERROR; } AtCommandResult AtGsmTelitLe910_SIMCardNoDetect(tAtCmd *env) { AtCmdPrepare(env); - + AtCmdRxClear(env); AtCmdSendStatic(env, "AT#SIMDET=0\r\n"); - - return AtCmdOkErrAnswer(env, env->stdRxTimeout); + AtCommandResult res = AtCmdOkErrAnswer(env, env->stdRxTimeout); + SystemDelayMs(500); + return res; } AtCommandResult AtGsmTelitLe910_EcallWriteMsdToModem(tAtCmd *env, uint8_t *msd, size_t msdLength) {