71 lines
1.9 KiB
C
71 lines
1.9 KiB
C
//
|
|
// Created by cfif on 24.05.2024.
|
|
//
|
|
|
|
#include "AtCmdCommonProtected.h"
|
|
#include "SystemDelayInterface.h"
|
|
|
|
|
|
AtCommandResult AtGsmSimComA7600_SSL_StartSocketService(tAtCmd *env) {
|
|
AtCmdPrepare(env);
|
|
AtCmdRxClear(env);
|
|
|
|
AtCmdSendStatic(env, "AT+CCHSTART\r\n");
|
|
|
|
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);
|
|
} else if (AtCmdRxBeginWithStatic(env, "+CCHSTART: 0")) {
|
|
AtCmdRxClear(env);
|
|
return AT_OK;
|
|
} else if (AtCmdRxBeginWithStatic(env, "+CCHSTART: 1")) {
|
|
AtCmdRxClear(env);
|
|
return AT_ERROR;
|
|
} else if (AtCmdRxBeginWithStatic(env, "ERROR")) {
|
|
AtCmdRxClear(env);
|
|
return AT_ERROR;
|
|
} else {
|
|
AtCmdProcessUnresolvedLine(env);
|
|
AtCmdRxClear(env);
|
|
continue;
|
|
}
|
|
}
|
|
|
|
return AT_TIMEOUT;
|
|
}
|
|
|
|
AtCommandResult AtGsmSimComA7600_SSL_HasIp(tAtCmd *env) {
|
|
AtCmdPrepare(env);
|
|
|
|
AtCmdSendStatic(env, "AT+CCHADDR\r\n");
|
|
|
|
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, "+IP ERROR:")) {
|
|
AtCmdRxClear(env);
|
|
} else if (AtCmdRxBeginWithStatic(env, "ERROR")) {
|
|
AtCmdRxClear(env);
|
|
return AT_ERROR;
|
|
} else {
|
|
AtCmdProcessUnresolvedLine(env);
|
|
AtCmdRxClear(env);
|
|
continue;
|
|
}
|
|
}
|
|
|
|
return AT_TIMEOUT;
|
|
} |