71 lines
1.9 KiB
C
Executable File
71 lines
1.9 KiB
C
Executable File
//
|
|
// Created by xemon on 10.05.23.
|
|
//
|
|
#include "AtGsmTelitLe910_StartSocketService.h"
|
|
#include "AtCmdCommonProtected.h"
|
|
#include "SystemDelayInterface.h"
|
|
|
|
|
|
AtCommandResult AtGsmSimComA7600_StartSocketService(tAtCmd *env) {
|
|
AtCmdPrepare(env);
|
|
|
|
AtCmdSendStatic(env, "AT+NETOPEN\r\n");
|
|
|
|
uint32_t timeout = env->stdRxTimeout*5;
|
|
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, "+NETOPEN: 0")) {
|
|
AtCmdRxClear(env);
|
|
return AT_OK;
|
|
} else if (AtCmdRxBeginWithStatic(env, "+NETOPEN: 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_HasIp(tAtCmd *env) {
|
|
AtCmdPrepare(env);
|
|
|
|
AtCmdSendStatic(env, "AT+IPADDR\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;
|
|
}
|