commit f6d25894dffd3cef92c02047bb76f7decb88a984 Author: cfif Date: Mon Jun 2 13:26:41 2025 +0300 Init diff --git a/AtGsmSimComA7600_SSL_LOAD_CA.c b/AtGsmSimComA7600_SSL_LOAD_CA.c new file mode 100644 index 0000000..0b3edca --- /dev/null +++ b/AtGsmSimComA7600_SSL_LOAD_CA.c @@ -0,0 +1,157 @@ +// +// Created by cfif on 23.05.2024. +// +#include "AtGsmSimComA7600_SSL_LOAD_CA.h" +#include "SystemDelayInterface.h" +#include "string.h" + +tIsFind AtGsmSimComA7600_SSL_CHECK_CA(tAtCmd *env, + const char *fileName1, uint16_t FileNameLen1, + const char *fileName2, uint16_t FileNameLen2, + const char *fileName3, uint16_t FileNameLen3, + uint32_t timeout) { + + tIsFind isFind; + + isFind.isFind1 = false; + isFind.isFind2 = false; + isFind.isFind3 = false; + + AtCmdPrepare(env); + AtCmdRxClear(env); + + AtCmdSendStatic(env, "AT+CCERTLIST\r\n"); + + uint32_t endMs = SystemGetMs() + timeout; + uint32_t leftMs = timeout; + + while ((AtCmdReceiveNextLine(env, leftMs) == AT_OK) && (SystemGetMs() < endMs)) { + leftMs = endMs - SystemGetMs(); + + if (AtCmdRxBeginWithStatic(env, "+CCERTLIST: ")) { + + if (!isFind.isFind1) { + if (memcmp(fileName1, env->rxBuffer.data + sizeof("+CCERTLIST: "), FileNameLen1) == 0) { + isFind.isFind1 = true; + } + } + + if (!isFind.isFind2) { + if (memcmp(fileName2, env->rxBuffer.data + sizeof("+CCERTLIST: "), FileNameLen2) == 0) { + isFind.isFind2 = true; + } + } + + if (!isFind.isFind3) { + if (memcmp(fileName3, env->rxBuffer.data + sizeof("+CCERTLIST: "), FileNameLen3) == 0) { + isFind.isFind3 = true; + } + } + + if ((isFind.isFind1) && (isFind.isFind2) && (isFind.isFind3)) + return isFind; + + } + + } + + return isFind; +} + +void AtGsmSimComA7600_SSL_DEL_ONE_CA(tAtCmd *env, + const char *fileName1, uint16_t FileNameLen1) { + AtCmdPrepare(env); + + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CCERTDELE="); + AtCmdTxAddChar(env, '"'); + AtCmdTxAdd(env, (char *) fileName1, FileNameLen1); + AtCmdTxAddChar(env, '"'); + AtCmdTxSendLn(env); + + AtCmdOkErrAnswer(env, env->stdRxTimeout); +} + +void AtGsmSimComA7600_SSL_DEL_CA(tAtCmd *env, + const char *fileName1, uint16_t FileNameLen1, + const char *fileName2, uint16_t FileNameLen2, + const char *fileName3, uint16_t FileNameLen3) { + AtCmdPrepare(env); + + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CCERTDELE="); + AtCmdTxAddChar(env, '"'); + AtCmdTxAdd(env, (char *) fileName1, FileNameLen1); + AtCmdTxAddChar(env, '"'); + AtCmdTxSendLn(env); + + AtCmdOkErrAnswer(env, env->stdRxTimeout); + + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CCERTDELE="); + AtCmdTxAddChar(env, '"'); + AtCmdTxAdd(env, (char *) fileName2, FileNameLen2); + AtCmdTxAddChar(env, '"'); + AtCmdTxSendLn(env); + + AtCmdOkErrAnswer(env, env->stdRxTimeout); + + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CCERTDELE="); + AtCmdTxAddChar(env, '"'); + AtCmdTxAdd(env, (char *) fileName3, FileNameLen3); + AtCmdTxAddChar(env, '"'); + AtCmdTxSendLn(env); + + AtCmdOkErrAnswer(env, env->stdRxTimeout); + +} + +AtCommandResult +AtGsmSimComA7600_SSL_LOAD_CA(tAtCmd *env, const char *fileName, uint16_t FileNameLen, unsigned char *data, + uint16_t dataLen, uint32_t timeout) { + AtCmdPrepare(env); + + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CCERTDOWN="); + AtCmdTxAddChar(env, '"'); + AtCmdTxAdd(env, (char *) fileName, FileNameLen); + AtCmdTxAddChar(env, '"'); + AtCmdTxAddChar(env, ','); + AtCmdTxAddDecimalIntWithLimit(env, dataLen, 5); + + AtCmdTxSendLn(env); + + uint32_t endMs = SystemGetMs() + timeout; + uint32_t leftMs = timeout; + + while ((AtCmdReceiveNextChar(env, leftMs) == AT_OK) && (SystemGetMs() < endMs)) { + leftMs = endMs - SystemGetMs(); + if (AtCmdRxIsCompleteLine(env)) { + if (AtCmdRxBeginWithStatic(env, ">")) { + AtCmdRxClear(env); + AtCmdSend(env, data, dataLen); + } else if (AtCmdRxBeginWithStatic(env, "ERROR")) { + AtCmdRxClear(env); + return AT_ERROR; + } else if (AtCmdRxBeginWithStatic(env, "OK")) { + AtCmdRxClear(env); + return AT_OK; + } else { + AtCmdProcessUnresolvedLine(env); + AtCmdRxClear(env); + continue; + } + } else { + if (AtCmdRxBeginWithStatic(env, ">")) { + AtCmdRxClear(env); + AtCmdSend(env, data, dataLen); + } + + + } + + } + + return AT_TIMEOUT; +} \ No newline at end of file diff --git a/AtGsmSimComA7600_SSL_LOAD_CA.h b/AtGsmSimComA7600_SSL_LOAD_CA.h new file mode 100644 index 0000000..86e3284 --- /dev/null +++ b/AtGsmSimComA7600_SSL_LOAD_CA.h @@ -0,0 +1,33 @@ +// +// Created by cfif on 23.05.2024. +// + +#ifndef SMART_COMPONENTS_ATGSMSIMCOMA7600_SSL_LOAD_CA_H +#define SMART_COMPONENTS_ATGSMSIMCOMA7600_SSL_LOAD_CA_H + +#include "AtCmdCommon.h" +#include "AtCmdCommonProtected.h" + +typedef struct { + bool isFind1; + bool isFind2; + bool isFind3; +} tIsFind; + +AtCommandResult AtGsmSimComA7600_SSL_LOAD_CA(tAtCmd *env, const char *fileName, uint16_t FileNameLen, unsigned char *data, uint16_t dataLen, uint32_t timeout); + +tIsFind AtGsmSimComA7600_SSL_CHECK_CA(tAtCmd *env, + const char *fileName1, uint16_t FileNameLen1, + const char *fileName2, uint16_t FileNameLen2, + const char *fileName3, uint16_t FileNameLen3, + uint32_t timeout); + +void AtGsmSimComA7600_SSL_DEL_CA(tAtCmd *env, + const char *fileName1, uint16_t FileNameLen1, + const char *fileName2, uint16_t FileNameLen2, + const char *fileName3, uint16_t FileNameLen3); + +void AtGsmSimComA7600_SSL_DEL_ONE_CA(tAtCmd *env, + const char *fileName1, uint16_t FileNameLen1); + +#endif //SMART_COMPONENTS_ATGSMSIMCOMA7600_SSL_LOAD_CA_H diff --git a/modular.json b/modular.json new file mode 100644 index 0000000..d608446 --- /dev/null +++ b/modular.json @@ -0,0 +1,17 @@ +{ + "dep": [ + { + "type": "git", + "provider": "Smart_Components_Aurus", + "repo": "AtGsmCommon" + } + ], + "cmake": { + "inc_dirs": [ + "./" + ], + "srcs": [ + "./**.c" + ] + } +} \ No newline at end of file