Изменения на новый модем GSM

This commit is contained in:
cfif 2025-05-29 11:51:36 +03:00
commit 1801afeb4f
3 changed files with 146 additions and 0 deletions

33
Inc/AtGsmA76xx.h Normal file
View File

@ -0,0 +1,33 @@
//
// Created by cfif on 25.01.23.
//
#ifndef GONEC_GSM_ATGGMSIM800F_H
#define GONEC_GSM_ATGGMSIM800F_H
#include <SystemDelayInterface.h>
#include "AtCmdCommonProtected.h"
#include "AsciiStringParsingUtils.h"
#include "AtGsm_NetworkRegistrationStatus.h"
//
// Created by cfif on 25.01.23.
//
#include "AtGsmA76xx.h"
#include "stdlib.h"
// начало-------------------------- Служебные ----------------------------------------------------------------------
// начало-------------------------- Служебные ----------------------------------------------------------------------
// начало-------------------------- Служебные ----------------------------------------------------------------------
// IMEI
AtCommandResult AtGsm_Simcom_A76xx_GET_CGSN(tAtCmd *env, char *acpString, size_t *acpStringLen);
AtCommandResult AtGsm_Simcom_A76xx_CCID(tAtCmd *env, char *acpString, size_t *acpStringLen);
// конец-------------------------- Служебные ----------------------------------------------------------------------
// конец-------------------------- Служебные ----------------------------------------------------------------------
// конец-------------------------- Служебные ----------------------------------------------------------------------
#endif //GONEC_GSM_ATGGMSIM800F_H

91
Src/AtGsmA76xx.c Normal file
View File

@ -0,0 +1,91 @@
//
// 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;
}
// конец-------------------------- Служебные ----------------------------------------------------------------------
// конец-------------------------- Служебные ----------------------------------------------------------------------
// конец-------------------------- Служебные ----------------------------------------------------------------------

22
modular.json Normal file
View File

@ -0,0 +1,22 @@
{
"dep": [
{
"type": "git",
"provider": "GONEC_NEW",
"repo": "AsciiStringAssemblingUtils"
},
{
"type": "git",
"provider": "GONEC_NEW",
"repo": "AtGsmCommon"
}
],
"cmake": {
"inc_dirs": [
"Inc"
],
"srcs": [
"Src/**.c"
]
}
}