// // Created by cfif on 24.05.2024. // #include "AtCmdCommonProtected.h" #include "SystemDelayInterface.h" #include "AtGsmSimComA7600_SSL_DefinePdpContext.h" AtCommandResult AtGsmSimComA7600_SSL_SetContext(tAtCmd *env, uint8_t linkNum, uint8_t ctx) { AtCmdPrepare(env); AtCmdTxClear(env); AtCmdTxAddStatic(env, "AT+CCHSSLCFG="); AtCmdTxAddDecimalIntWithLimit(env, linkNum, 1); AtCmdTxAddChar(env, ','); AtCmdTxAddDecimalIntWithLimit(env, ctx, 1); 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, "OK")) { AtCmdRxClear(env); return AT_OK; } else if (AtCmdRxBeginWithStatic(env, "ERROR")) { AtCmdRxClear(env); return AT_ERROR; } else { AtCmdProcessUnresolvedLine(env); AtCmdRxClear(env); continue; } } return AT_TIMEOUT; } AtCommandResult AtGsmSimComA7600_SSL_CfgContext(tAtCmd *env, eAtGsmSimComA7600_SSL_Cfg_Type type, char *param, uint8_t paramLen, uint8_t ctx, char *value, uint8_t valueLen) { AtCmdPrepare(env); AtCmdRxClear(env); AtCmdTxClear(env); AtCmdTxAddStatic(env, "AT+CSSLCFG="); AtCmdTxAddChar(env, '"'); AtCmdTxAdd(env, param, paramLen); AtCmdTxAddChar(env, '"'); AtCmdTxAddChar(env, ','); AtCmdTxAddDecimalIntWithLimit(env, ctx, 1); AtCmdTxAddChar(env, ','); if (type == eAtGsmSimComA7600_SslCfgType_STR) AtCmdTxAddChar(env, '"'); AtCmdTxAdd(env, value, valueLen); if (type == eAtGsmSimComA7600_SslCfgType_STR) AtCmdTxAddChar(env, '"'); 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, "OK")) { AtCmdRxClear(env); return AT_OK; } else if (AtCmdRxBeginWithStatic(env, "ERROR")) { AtCmdRxClear(env); return AT_ERROR; } else { AtCmdProcessUnresolvedLine(env); AtCmdRxClear(env); continue; } } return AT_TIMEOUT; }