92 lines
3.1 KiB
C
92 lines
3.1 KiB
C
//
|
|
// Created by cfif on 25.01.23.
|
|
//
|
|
#include "AtGsmA76xx.h"
|
|
#include "stdlib.h"
|
|
#include "memory.h"
|
|
|
|
// начало-------------------------- Служебные ----------------------------------------------------------------------
|
|
// начало-------------------------- Служебные ----------------------------------------------------------------------
|
|
// начало-------------------------- Служебные ----------------------------------------------------------------------
|
|
|
|
// IMEI
|
|
AtCommandResult AtGsm_Simcom_A76xx_GET_CGSN(tAtCmd *env, char *acpString, size_t *acpStringLen) {
|
|
AtCmdPrepare(env);
|
|
|
|
AtCmdTxClear(env);
|
|
AtCmdTxAddStatic(env, "AT+CGSN");
|
|
AtCmdTxSendLn(env);
|
|
|
|
|
|
uint32_t timeout = env->stdRxTimeout;
|
|
uint32_t endMs = SystemGetMs() + timeout;
|
|
uint32_t leftMs = timeout;
|
|
|
|
while ((AtCmdReceiveNextLine(env, leftMs) == AT_OK) && (SystemGetMs() < endMs)) {
|
|
leftMs = endMs - SystemGetMs();
|
|
|
|
if (AtCmdRxBeginWithStatic(env, "ERROR")) {
|
|
AtCmdRxClear(env);
|
|
return AT_ERROR;
|
|
|
|
} else if (AtCmdRxBeginWithStatic(env, "AT+CGSN")) {
|
|
while (AtCmdReceiveNextLine(env, 1000) == AT_OK) {
|
|
*acpStringLen = env->rxBuffer.len - 2;
|
|
memcpy(acpString, env->rxBuffer.data, *acpStringLen);
|
|
AtCmdRxClear(env);
|
|
return AtCmdOkErrAnswer(env, env->stdRxTimeout);
|
|
}
|
|
} else {
|
|
AtCmdProcessUnresolvedLine(env);
|
|
AtCmdRxClear(env);
|
|
continue;
|
|
}
|
|
}
|
|
|
|
return AT_TIMEOUT;
|
|
}
|
|
|
|
AtCommandResult AtGsm_Simcom_A76xx_CCID(tAtCmd *env, char *acpString, size_t *acpStringLen) {
|
|
AtCmdPrepare(env);
|
|
|
|
AtCmdTxClear(env);
|
|
AtCmdTxAddStatic(env, "AT+CICCID");
|
|
AtCmdTxSendLn(env);
|
|
|
|
|
|
uint32_t timeout = env->stdRxTimeout;
|
|
uint32_t endMs = SystemGetMs() + timeout;
|
|
uint32_t leftMs = timeout;
|
|
|
|
while ((AtCmdReceiveNextLine(env, leftMs) == AT_OK) && (SystemGetMs() < endMs)) {
|
|
leftMs = endMs - SystemGetMs();
|
|
|
|
if (AtCmdRxBeginWithStatic(env, "ERROR")) {
|
|
AtCmdRxClear(env);
|
|
return AT_ERROR;
|
|
|
|
} else if (AtCmdRxBeginWithStatic(env, "+CCID: ")) {
|
|
while (AtCmdReceiveNextLine(env, 1000) == AT_OK) {
|
|
char *start = env->rxBuffer.data + sizeof("+CCID:");
|
|
*acpStringLen = env->rxBuffer.len - sizeof("+CCID:") - 2;
|
|
memcpy(acpString, start, *acpStringLen);
|
|
AtCmdRxClear(env);
|
|
return AtCmdOkErrAnswer(env, env->stdRxTimeout);
|
|
}
|
|
|
|
} else {
|
|
AtCmdProcessUnresolvedLine(env);
|
|
AtCmdRxClear(env);
|
|
continue;
|
|
}
|
|
}
|
|
|
|
return AT_TIMEOUT;
|
|
}
|
|
|
|
|
|
// конец-------------------------- Служебные ----------------------------------------------------------------------
|
|
// конец-------------------------- Служебные ----------------------------------------------------------------------
|
|
// конец-------------------------- Служебные ----------------------------------------------------------------------
|
|
|