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BE=D0=B1=D1=80=D0=B0=D1=89=D1=8F=D1=8E?= =?UTF-8?q?=D1=89=D0=B8=D1=85=D1=81=D1=8F=20=D0=BA=20=D0=90=D0=A2=20=D0=B8?= =?UTF-8?q?=D0=BD=D1=82=D0=B5=D1=80=D1=84=D0=B5=D0=B9=D1=81=D1=83=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=B4=D0=B5=D0=BC=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/AtGsmTelitLe910_Gnss.c | 100 +++++++++++++------------------------ 1 file changed, 35 insertions(+), 65 deletions(-) diff --git a/Src/AtGsmTelitLe910_Gnss.c b/Src/AtGsmTelitLe910_Gnss.c index 3167a6a..f1431bc 100644 --- a/Src/AtGsmTelitLe910_Gnss.c +++ b/Src/AtGsmTelitLe910_Gnss.c @@ -278,81 +278,51 @@ AtCommandResult GsmWithGnss_StopRMCThread(tAtCmd *env) { } AtCommandResult GsmWithGnss_GetCGSN(tAtCmd *env, char *acpString, size_t *acpStringLen) { - AtCmdPrepare(env); + if (osMutexAcquire(env->access, 5000) == osOK) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT#CGSN\r\n"); - AtCmdTxClear(env); - AtCmdSendStatic(env, "AT#CGSN\r\n"); - - SystemDelayMs(2000); - while (AtCmdReceiveNextLine(env, 15000) == AT_OK) { - if (AtCmdRxBeginWithStatic(env, "#CGSN: ")) { - static const uint16_t prefixSize = sizeof("#CGSN: ") - 1; - *acpStringLen = env->rxBuffer.len - (prefixSize + 2); - memcpy(acpString, env->rxBuffer.data + prefixSize, *acpStringLen); - - return AT_OK; - } - if (AtCmdRxBeginWithStatic(env, "ERROR")) { - return AT_ERROR; + SystemDelayMs(2000); + while (AtCmdReceiveNextLine(env, 15000) == AT_OK) { + if (AtCmdRxBeginWithStatic(env, "#CGSN: ")) { + static const uint16_t prefixSize = sizeof("#CGSN: ") - 1; + *acpStringLen = env->rxBuffer.len - (prefixSize + 2); + memcpy(acpString, env->rxBuffer.data + prefixSize, *acpStringLen); + osMutexRelease(env->access); + return AT_OK; + } + if (AtCmdRxBeginWithStatic(env, "ERROR")) { + osMutexRelease(env->access); + return AT_ERROR; + } } + osMutexRelease(env->access); } - return AT_TIMEOUT; } AtCommandResult GsmWithGnss_GetCCID(tAtCmd *env, char *acpStr, size_t *acpStrLen) { -// AtCmdPrepare(env); -// AtCmdRxClear(env); -// AtCmdSendStatic(env, "AT#CCID\r\n"); -// -// uint32_t timeout = 4000; -// uint32_t endMs = SystemGetMs() + timeout; -// uint32_t leftMs = timeout; -// -// while ((AtCmdReceiveNextLine(env, leftMs) == AT_OK) && (SystemGetMs() < endMs)) { -// leftMs = endMs - SystemGetMs(); -// -// if (AtCmdRxBeginWithStatic(env, "OK")) { -// AtCmdRxClear(env); -// continue; -// -// } else if (AtCmdRxBeginWithStatic(env, "ERROR")) { -// AtCmdRxClear(env); -// return AT_ERROR; -// -// } else if (AtCmdRxBeginWithStatic(env, "#CCID: ")) { -// -// static const uint16_t prefixSize = sizeof("#CCID: ") - 1; -// *acpStrLen = env->rxBuffer.len - (prefixSize + 2); -// memcpy(acpStr, env->rxBuffer.data+ prefixSize,*acpStrLen); -// AtCmdRxClear(env); -// return AT_OK; -// -// } else { -// AtCmdProcessUnresolvedLine(env); -// AtCmdRxClear(env); -// continue; -// } -// } -// return AT_TIMEOUT; -// + if (osMutexAcquire(env->access, 5000) == osOK) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT#CCID\r\n"); - AtCmdPrepare(env); + while (AtCmdReceiveNextLine(env, 1500) == AT_OK) { + if (AtCmdRxBeginWithStatic(env, "#CCID: ")) { + static const uint16_t prefixSize = sizeof("#CCID: ") - 1; + *acpStrLen = env->rxBuffer.len - (prefixSize + 2); + memcpy(acpStr, env->rxBuffer.data+ prefixSize,*acpStrLen); + osMutexRelease(env->access); + return AT_OK; + } - AtCmdTxClear(env); - AtCmdSendStatic(env, "AT#CCID\r\n"); - - while (AtCmdReceiveNextLine(env, 1500) == AT_OK) { - if (AtCmdRxBeginWithStatic(env, "#CCID: ")) { - static const uint16_t prefixSize = sizeof("#CCID: ") - 1; - *acpStrLen = env->rxBuffer.len - (prefixSize + 2); - memcpy(acpStr, env->rxBuffer.data+ prefixSize,*acpStrLen); - return AT_OK; - } - - if (AtCmdRxBeginWithStatic(env, "ERROR")) { - return AT_ERROR; + if (AtCmdRxBeginWithStatic(env, "ERROR")) { + osMutexRelease(env->access); + return AT_ERROR; + } } + osMutexRelease(env->access); } return AT_TIMEOUT; }