This commit is contained in:
cfif 2024-12-04 13:10:48 +03:00
commit 9fcacfb273
14 changed files with 1025 additions and 0 deletions

View File

@ -0,0 +1,35 @@
//
// Created by xemon on 10.05.23.
//
#ifndef ATGSMSIMCOMA7600_DEFINEPDPCONTEXT_H
#define ATGSMSIMCOMA7600_DEFINEPDPCONTEXT_H
#include "AtCmdCommon.h"
typedef enum {
AtGsmTelitLe910_PdpType_IP,
AtGsmTelitLe910_PdpType_IPV6,
AtGsmTelitLe910_PdpType_IPV4V6
} eAtGsmTelitLe910_PdpType;
//AtCommandResult AtGsmSimComA7600_DefinePdpContext(
// tAtCmd *env, uint8_t cid, eAtGsmSimComA7600_PdpType pdpType, const char *apn, uint8_t apnLen
//);
AtCommandResult AtGsmTelitLe910_DefinePdpContext(
tAtCmd *env, uint8_t cid, eAtGsmTelitLe910_PdpType pdpType, const char *apn, uint8_t apnLen
);
AtCommandResult AtGsmTelitLe910_PdpActivate(tAtCmd *env, uint8_t cid);
AtCommandResult AtGsmTelitLe910_PdpDeactivate(tAtCmd *env, uint8_t cid);
#define AtGsmTelitLe910_DefinePdpIpContextStaticApn(ENV, CID, APN) AtGsmTelitLe910_DefinePdpContext(ENV,CID,AtGsmSimComA7600_PdpType_IPV4V6,APN,sizeof(APN)-1)
//AtCommandResult AtGsmSimComA7600_PdpActivate(tAtCmd *env, uint8_t cid);
//AtCommandResult AtGsmSimComA7600_PdpDeactivate(tAtCmd *env, uint8_t cid);
//#define AtGsmSimComA7600_DefinePdpIpContextStaticApn(ENV, CID, APN) AtGsmSimComA7600_DefinePdpContext(ENV,CID,AtGsmSimComA7600_PdpType_IP,APN,sizeof(APN)-1)
#endif //ATGSMSIMCOMA7600_DEFINEPDPCONTEXT_H

View File

@ -0,0 +1,47 @@
//
// Created by xemon on 10.05.23.
//
#ifndef ATGSMSIMCOMA7600_ESTEBLISHCONNECTION_H
#define ATGSMSIMCOMA7600_ESTEBLISHCONNECTION_H
#include "AtCmdCommon.h"
typedef enum {
eAtGsmSimComA7600_IpType_TCP,
eAtGsmSimComA7600_IpType_UDP,
} eAtGsmSimComA7600_IpType;
//AtCommandResult AtGsmSimComA7600_EstablishConnection(
// tAtCmd *env,
// uint8_t linkNum,
// eAtGsmSimComA7600_IpType type,
// char *srvIp,
// uint8_t srvIpLen,
// uint16_t srvPort,
// uint16_t localPort
//);
AtCommandResult AtGsmTelitLe910_EstablishConnection(
tAtCmd *env,
uint8_t linkNum,
eAtGsmSimComA7600_IpType type,
char *srvIp,
uint8_t srvIpLen,
uint16_t srvPort,
uint16_t localPort
);
//#define AtGsmSimComA7600_EstablishTcpConnStatic(ENV, LNK, SRV, PORT) AtGsmSimComA7600_EstablishConnection(ENV,LNK,eAtGsmSimComA7600_IpType_TCP,SRV,sizeof(SRV)-1,PORT,0)
#define AtGsmSimComA7600_EstablishTcpConnStatic(ENV, LNK, SRV, PORT) AtGsmTelitLe910_EstablishConnection(ENV,LNK,eAtGsmSimComA7600_IpType_TCP,SRV,sizeof(SRV)-1,PORT,0)
//AtCommandResult AtGsmSimComA7600_HasConnection(tAtCmd *env, uint8_t linkNum, bool *status);
AtCommandResult AtGsmTelitLe910_HasConnection(tAtCmd *env, uint8_t linkNum, bool *status);
AtCommandResult AtGsmTelitLe910_CloseConnection(tAtCmd *env, uint8_t linkNum);
//AtCommandResult AtGsmSimComA7600_CloseConnection(tAtCmd *env, uint8_t linkNum);
#endif //ATGSMSIMCOMA7600_ESTEBLISHCONNECTION_H

14
Inc/AtGsmTelitLe910_Socket.h Executable file
View File

@ -0,0 +1,14 @@
//
// Created by xemon on 10.05.23.
//
#ifndef ATGSMSIMCOMA7600_H
#define ATGSMSIMCOMA7600_H
#include "AtGsmTelitLe910_DefinePdpContext.h"
#include "AtGsmTelitLe910_StartSocketService.h"
#include "AtGsmTelitLe910_StopSocketService.h"
#include "AtGsmTelitLe910_EstablishConnection.h"
#include "AtGsmTelitLe910_SocketSendData.h"
#endif //ATGSMSIMCOMA7600_H

View File

@ -0,0 +1,12 @@
//
// Created by cfif on 16.10.2023.
//
#ifndef MOTOTERMINAL_MAIN_ONAT435_ATGSMTELITLE910_SOCKETREADDATA_H
#define MOTOTERMINAL_MAIN_ONAT435_ATGSMTELITLE910_SOCKETREADDATA_H
#include "AtCmdCommon.h"
AtCommandResult xAtGsmTelit_ReadSocket(tAtCmd *env, int idSocket, uint8_t *dataSocketRead, uint32_t dataSocketReadMaxLen, uint32_t *dataSocketReadLen);
#endif //MOTOTERMINAL_MAIN_ONAT435_ATGSMTELITLE910_SOCKETREADDATA_H

View File

@ -0,0 +1,48 @@
//
// Created by xemon on 10.05.23.
//
#ifndef ATGSMSIMCOMA7600_SOCKETSENDDATA_H
#define ATGSMSIMCOMA7600_SOCKETSENDDATA_H
#include "AtCmdCommon.h"
AtCommandResult AtGsmTelitLe910_SocketSendData(
tAtCmd *env, uint8_t linkNum, uint8_t *data, uint16_t dataLen, uint32_t timeout
);
AtCommandResult AtGsmTelitLe910_SocketSendDataUdp(
tAtCmd *env,
uint8_t linkNum,
uint8_t *data,
uint16_t dataLen,
char *srvIp,
uint8_t srvIpLen,
uint16_t srvPort,
uint32_t timeout
);
#define AtGsmTelitLe910_SocketSendDataStatic(ENV, LNK, STR, TOUT) AtGsmSimComA7600_SocketSendData(ENV,LNK,(uint8_t*)STR,sizeof(STR)-1,TOUT)
/*
AtCommandResult AtGsmSimComA7600_SocketSendData(
tAtCmd *env, uint8_t linkNum, uint8_t *data, uint16_t dataLen, uint32_t timeout
);
AtCommandResult AtGsmSimComA7600_SocketSendDataUdp(
tAtCmd *env,
uint8_t linkNum,
uint8_t *data,
uint16_t dataLen,
char *srvIp,
uint8_t srvIpLen,
uint16_t srvPort,
uint32_t timeout
);
#define AtGsmSimComA7600_SocketSendDataStatic(ENV, LNK, STR, TOUT) AtGsmSimComA7600_SocketSendData(ENV,LNK,(uint8_t*)STR,sizeof(STR)-1,TOUT)
*/
#endif //ATGSMSIMCOMA7600_DEFINEPDPCONTEXT_H

View File

@ -0,0 +1,12 @@
//
// Created by xemon on 10.05.23.
//
#ifndef ATGSMSIMCOMA7600_STARTSOCKETSERVICE_H
#define ATGSMSIMCOMA7600_STARTSOCKETSERVICE_H
#include "AtCmdCommon.h"
AtCommandResult AtGsmSimComA7600_StartSocketService(tAtCmd *env);
AtCommandResult AtGsmSimComA7600_HasIp(tAtCmd *env);
#endif //ATGSMSIMCOMA7600_STARTSOCKETSERVICE_H

View File

@ -0,0 +1,12 @@
//
// Created by xemon on 10.05.23.
//
#ifndef ATGSMSIMCOMA7600_STOPSOCKETSERVICE_H
#define ATGSMSIMCOMA7600_STOPSOCKETSERVICE_H
#include "AtCmdCommon.h"
AtCommandResult AtGsmSimComA7600_StopSocketService(tAtCmd *env);
#endif //ATGSMSIMCOMA7600_STOPSOCKETSERVICE_H

View File

@ -0,0 +1,159 @@
//
// Created by xemon on 10.05.23.
//
#include "AtGsmTelitLe910_DefinePdpContext.h"
#include "AtCmdCommonProtected.h"
#include "SystemDelayInterface.h"
AtCommandResult AtGsmTelitLe910_DefinePdpContext(
tAtCmd *env, uint8_t cid, eAtGsmTelitLe910_PdpType pdpType, const char *apn, uint8_t apnLen
) {
AtCmdPrepare(env);
if (cid > 15) {
return AT_ERROR;
}
AtCmdTxClear(env);
AtCmdTxAddStatic(env, "AT+CGDCONT=");
AtCmdTxAddDecimalIntWithLimit(env, cid, 2);
AtCmdTxAddChar(env, ',');
AtCmdTxAddChar(env, '"');
switch (pdpType) {
case AtGsmTelitLe910_PdpType_IP:
AtCmdTxAddStatic(env, "IP");
break;
case AtGsmTelitLe910_PdpType_IPV6:
AtCmdTxAddStatic(env, "IPV6");
break;
case AtGsmTelitLe910_PdpType_IPV4V6:
AtCmdTxAddStatic(env, "IPV4V6");
break;
default:
return AT_ERROR;
}
AtCmdTxAddChar(env, '"');
AtCmdTxAddChar(env, ',');
AtCmdTxAddChar(env, '"');
AtCmdTxAdd(env, apn, apnLen);
AtCmdTxAddChar(env, '"');
AtCmdTxSendLn(env);
return AtCmdOkErrAnswer(env, env->stdRxTimeout);
}
AtCommandResult AtGsmTelitLe910_PdpActivate(tAtCmd *env, uint8_t cid) {
AtCmdPrepare(env);
if (cid > 15) {
return AT_ERROR;
}
AtCmdTxClear(env);
AtCmdTxAddStatic(env, "AT#SGACT=1,");
AtCmdTxAddDecimalIntWithLimit(env, cid, 2);
AtCmdTxSendLn(env);
return AtCmdOkErrAnswer(env, env->stdRxTimeout*10);
}
AtCommandResult AtGsmTelitLe910_PdpDeactivate(tAtCmd *env, uint8_t cid) {
AtCmdPrepare(env);
if (cid > 15) {
return AT_ERROR;
}
AtCmdTxClear(env);
AtCmdTxAddStatic(env, "AT#SGACT=0,");
AtCmdTxAddDecimalIntWithLimit(env, cid, 2);
AtCmdTxSendLn(env);
return AtCmdOkErrAnswer(env, env->stdRxTimeout*10);
}
/*
AtCommandResult AtGsmSimComA7600_DefinePdpContext(
tAtCmd *env, uint8_t cid, eAtGsmSimComA7600_PdpType pdpType, const char *apn, uint8_t apnLen
) {
AtCmdPrepare(env);
if (cid > 15) {
return AT_ERROR;
}
AtCmdTxClear(env);
AtCmdTxAddStatic(env, "AT+CGDCONT=");
AtCmdTxAddDecimalIntWithLimit(env, cid, 2);
AtCmdTxAddChar(env, ',');
AtCmdTxAddChar(env, '"');
switch (pdpType) {
case AtGsmSimComA7600_PdpType_IP:
AtCmdTxAddStatic(env, "IP");
break;
case AtGsmSimComA7600_PdpType_IPV6:
AtCmdTxAddStatic(env, "IPV6");
break;
case AtGsmSimComA7600_PdpType_IPV4V6:
AtCmdTxAddStatic(env, "IPV4V6");
break;
default:
return AT_ERROR;
}
AtCmdTxAddChar(env, '"');
AtCmdTxAddChar(env, ',');
AtCmdTxAddChar(env, '"');
AtCmdTxAdd(env, apn, apnLen);
AtCmdTxAddChar(env, '"');
AtCmdTxSendLn(env);
return AtCmdOkErrAnswer(env, env->stdRxTimeout);
}
AtCommandResult AtGsmSimComA7600_PdpActivate(tAtCmd *env, uint8_t cid) {
AtCmdPrepare(env);
if (cid > 15) {
return AT_ERROR;
}
AtCmdTxClear(env);
AtCmdTxAddStatic(env, "AT+CGACT=1,");
AtCmdTxAddDecimalIntWithLimit(env, cid, 2);
AtCmdTxSendLn(env);
return AtCmdOkErrAnswer(env, env->stdRxTimeout*10);
}
AtCommandResult AtGsmSimComA7600_PdpDeactivate(tAtCmd *env, uint8_t cid) {
AtCmdPrepare(env);
if (cid > 15) {
return AT_ERROR;
}
AtCmdTxClear(env);
AtCmdTxAddStatic(env, "AT+CGACT=0,");
AtCmdTxAddDecimalIntWithLimit(env, cid, 2);
AtCmdTxSendLn(env);
return AtCmdOkErrAnswer(env, env->stdRxTimeout*10);
}
*/

View File

@ -0,0 +1,340 @@
//
// Created by xemon on 10.05.23.
//
#include <memory.h>
#include "AtGsmTelitLe910_EstablishConnection.h"
#include "AtCmdCommonProtected.h"
#include "SystemDelayInterface.h"
#include "string.h"
#include "stdlib.h"
AtCommandResult AtGsmTelitLe910_EstablishConnection(
tAtCmd *env,
uint8_t linkNum,
eAtGsmSimComA7600_IpType type,
char *srvIp,
uint8_t srvIpLen,
uint16_t srvPort,
uint16_t localPort
) {
AtCmdPrepare(env);
if (linkNum > 9) {
return AT_ERROR;
}
AtCmdTxClear(env);
AtCmdTxAddStatic(env, "AT#SD=");
AtCmdTxAddDecimalIntWithLimit(env, linkNum, 1);
AtCmdTxAddChar(env, ',');
switch (type) {
case eAtGsmSimComA7600_IpType_TCP:
AtCmdTxAddStatic(env, "0");
break;
case eAtGsmSimComA7600_IpType_UDP:
AtCmdTxAddStatic(env, "1");
break;
default:
return AT_ERROR;
}
AtCmdTxAddChar(env, ',');
if (srvPort) {
AtCmdTxAddDecimalIntWithLimit(env, srvPort, 5);
}
AtCmdTxAddChar(env, ',');
if (srvIpLen) {
AtCmdTxAddChar(env, '"');
AtCmdTxAdd(env, srvIp, srvIpLen);
AtCmdTxAddChar(env, '"');
}
AtCmdTxAddChar(env, ',');
AtCmdTxAddStatic(env, "0");
AtCmdTxAddChar(env, ',');
// if (localPort) {
AtCmdTxAddDecimalIntWithLimit(env, localPort, 5);
// }
AtCmdTxAddChar(env, ',');
AtCmdTxAddStatic(env, "1");
AtCmdTxSendLn(env);
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);
return AT_OK;
} else if (AtCmdRxBeginWithStatic(env, "CONNECT")) {
AtCmdRxClear(env);
} else if (AtCmdRxBeginWithStatic(env, "ERROR")) {
AtCmdRxClear(env);
return AT_ERROR;
} else if (AtCmdRxBeginWithStatic(env, "+CME ERROR:")) {
AtCmdRxClear(env);
return AT_ERROR;
} else {
AtCmdProcessUnresolvedLine(env);
AtCmdRxClear(env);
continue;
}
}
return AT_TIMEOUT;
}
/*
AtCommandResult AtGsmSimComA7600_EstablishConnection(
tAtCmd *env,
uint8_t linkNum,
eAtGsmSimComA7600_IpType type,
char *srvIp,
uint8_t srvIpLen,
uint16_t srvPort,
uint16_t localPort
) {
AtCmdPrepare(env);
if (linkNum > 9) {
return AT_ERROR;
}
AtCmdTxClear(env);
AtCmdTxAddStatic(env, "AT+CIPOPEN=");
AtCmdTxAddDecimalIntWithLimit(env, linkNum, 1);
AtCmdTxAddChar(env, ',');
AtCmdTxAddChar(env, '"');
switch (type) {
case eAtGsmSimComA7600_IpType_TCP:
AtCmdTxAddStatic(env, "TCP");
break;
case eAtGsmSimComA7600_IpType_UDP:
AtCmdTxAddStatic(env, "UDP");
break;
default:
return AT_ERROR;
}
AtCmdTxAddChar(env, '"');
AtCmdTxAddChar(env, ',');
if (srvIpLen) {
AtCmdTxAddChar(env, '"');
AtCmdTxAdd(env, srvIp, srvIpLen);
AtCmdTxAddChar(env, '"');
}
AtCmdTxAddChar(env, ',');
if (srvPort) {
AtCmdTxAddDecimalIntWithLimit(env, srvPort, 5);
}
AtCmdTxAddChar(env, ',');
if (localPort) {
AtCmdTxAddDecimalIntWithLimit(env, localPort, 5);
}
AtCmdTxSendLn(env);
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, "+CIPOPEN: ")) {
AtCommandResult res=(env->rxBuffer.data[sizeof ("+CIPOPEN: X,")-1]=='0')?AT_OK:AT_ERROR;
AtCmdRxClear(env);
return res;
} else if (AtCmdRxBeginWithStatic(env, "ERROR")) {
AtCmdRxClear(env);
return AT_ERROR;
} else {
AtCmdProcessUnresolvedLine(env);
AtCmdRxClear(env);
continue;
}
}
return AT_TIMEOUT;
}
*/
AtCommandResult AtGsmTelitLe910_HasConnection(tAtCmd *env, uint8_t linkNum, bool *status) {
char pattern[9];
memset(pattern, 0, sizeof(pattern));
strcat(pattern, "#SS: ");
utoa(linkNum, &pattern[strlen(pattern)], 10);
strcat(pattern, ",");
*status = false;
AtCmdPrepare(env);
AtCmdSendStatic(env, "AT#SS\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);
return AT_OK;
} else if (AtCmdRxBeginWith(env, pattern, strlen(pattern))) {
if ((env->rxBuffer.data[strlen(pattern)] == '0') || (env->rxBuffer.data[strlen(pattern)] == '3')) {
*status = false;
} else {
*status = true;
}
AtCmdRxClear(env);
} else if (AtCmdRxBeginWithStatic(env, "ERROR")) {
AtCmdRxClear(env);
return AT_ERROR;
} else {
AtCmdProcessUnresolvedLine(env);
AtCmdRxClear(env);
continue;
}
}
return AT_TIMEOUT;
}
/*
AtCommandResult AtGsmSimComA7600_HasConnection(tAtCmd *env, uint8_t linkNum, bool *status) {
char pattern[11];
memcpy(pattern, "+CIPOPEN: X", 11);
pattern[sizeof(pattern) - 1] = vAsciiStringDecimalIntToChar(linkNum);
uint8_t pattern_len = sizeof(pattern);
*status = false;
AtCmdPrepare(env);
AtCmdSendStatic(env, "AT+CIPOPEN?\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);
return AT_OK;
} else if (AtCmdRxBeginWithStatic(env, "+CIPOPEN")) {
if (AtCmdRxBeginWith(env, pattern, pattern_len)) {
if (env->rxBuffer.data[pattern_len] == '\r')
*status = false;
else if (env->rxBuffer.data[pattern_len] == ',') {
*status = true;
}
}
AtCmdRxClear(env);
} else if (AtCmdRxBeginWithStatic(env, "ERROR")) {
AtCmdRxClear(env);
return AT_ERROR;
} else {
AtCmdProcessUnresolvedLine(env);
AtCmdRxClear(env);
continue;
}
}
return AT_TIMEOUT;
}
*/
AtCommandResult AtGsmTelitLe910_CloseConnection(
tAtCmd *env,
uint8_t linkNum
) {
// AtCmdPrepare(env);
if (linkNum > 9) {
return AT_ERROR;
}
// AtCmdPrepare(env);
AtCmdTxClear(env);
AtCmdTxAddStatic(env, "AT#SH=");
AtCmdTxAddDecimalIntWithLimit(env, linkNum, 2);
AtCmdTxSendLn(env);
//debug_printf(env->io, "AT#SH=%u\r\n", idSocket);
return AtCmdOkErrAnswer(env, 5 * env->stdRxTimeout);
}
/*
AtCommandResult AtGsmSimComA7600_CloseConnection(
tAtCmd *env,
uint8_t linkNum
) {
AtCmdPrepare(env);
if (linkNum > 9) {
return AT_ERROR;
}
AtCmdTxClear(env);
AtCmdTxAddStatic(env, "AT+CIPClOSE=");
AtCmdTxAddDecimalIntWithLimit(env, linkNum, 1);
AtCmdTxSendLn(env);
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, "CLOSED")) {
AtCmdRxClear(env);
return AT_OK;
} else if (AtCmdRxBeginWithStatic(env, "ERROR")) {
AtCmdRxClear(env);
return AT_ERROR;
} else {
AtCmdProcessUnresolvedLine(env);
AtCmdRxClear(env);
continue;
}
}
return AT_TIMEOUT;
}
*/

View File

@ -0,0 +1,67 @@
//
// Created by cfif on 16.10.2023.
//
#include "AtGsmTelitLe910_SocketReadData.h"
#include "AtCmdCommonProtected.h"
#include "SystemDelayInterface.h"
#include "string.h"
#include "stdlib.h"
#include "AsciiStringParsingUtils.h"
AtCommandResult xAtGsmTelit_ReadSocket(tAtCmd *env, int idSocket, uint8_t *dataSocketRead, uint32_t dataSocketReadMaxLen, uint32_t *dataSocketReadLen) {
// AtCmdPrepare(env);
AtCmdTxClear(env);
AtCmdTxAddStatic(env, "AT#SRECV=");
AtCmdTxAddDecimalIntWithLimit(env, idSocket, 1);
AtCmdTxAddStatic(env, ",");
AtCmdTxAddDecimalIntWithLimit(env, dataSocketReadMaxLen, 4);
AtCmdTxSendLn(env);
//debug_printf(env->io, "AT#SRECV=%u,%u\r\n", idSocket, dataSocketReadMaxLen);
*dataSocketReadLen = 0;
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, "#SRECV: ")) {
char *front;
char *div = env->rxBuffer.data + sizeof("#SRECV:") - 1;
char *end = div + env->rxBuffer.len;
if (iAsciiStringMoveToNextParsingBlock(&front, &div, end, ',')) {
uint32_t id = atoi(front);
}
if (iAsciiStringMoveToNextParsingBlock(&front, &div, end, ',')) {
*dataSocketReadLen = atoi(front);
}
// *dataSocketReadLen = atoi(&env->rxBuffer.data[strlen("#SRECV: ")]);
AtCmdRxClear(env);
break;
} else if (AtCmdRxBeginWithStatic(env, "ERROR")) {
AtCmdRxClear(env);
return AT_ERROR;
} else if (AtCmdRxBeginWithStatic(env, "Operation")) {
AtCmdRxClear(env);
return AT_ERROR;
} else {
// AtCmdProcessUnresolvedLine(env);
AtCmdRxClear(env);
continue;
}
}
AtCmdRxReadRAW(env, dataSocketRead, *dataSocketReadLen, env->stdRxTimeout);
return AT_OK;
// return AtCmdOkErrAnswer(env, env->stdRxTimeout);
}

View File

@ -0,0 +1,177 @@
//
// Created by xemon on 10.05.23.
//
#include "AtGsmTelitLe910_SocketSendData.h"
#include "AtCmdCommonProtected.h"
#include "SystemDelayInterface.h"
AtCommandResult AtGsmTelitLe910_SocketSendData(
tAtCmd *env, uint8_t linkNum, uint8_t *data, uint16_t dataLen, uint32_t timeout
) {
return AtGsmTelitLe910_SocketSendDataUdp(env, linkNum, data, dataLen, 0, 0, 0, timeout);
}
AtCommandResult AtGsmTelitLe910_SocketSendDataUdp(
tAtCmd *env,
uint8_t linkNum,
uint8_t *data,
uint16_t dataLen,
char *srvIp,
uint8_t srvIpLen,
uint16_t srvPort,
uint32_t timeout
) {
AtCmdPrepare(env);
AtCmdRxClear(env);
if (linkNum > 9) {
return AT_ERROR;
}
AtCmdPrepare(env);
AtCmdTxClear(env);
AtCmdTxAddStatic(env, "AT#SSENDEXT=");
AtCmdTxAddDecimalIntWithLimit(env, linkNum, 1);
AtCmdTxAddStatic(env, ",");
AtCmdTxAddDecimalIntWithLimit(env, dataLen, 4);
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_OK;
}
}
}
return AT_TIMEOUT;
/*
//debug_printf(env->io, "AT#SSENDEXT=%u,%u\r\n", idSocket, dataSocketWriteLen);
AtCommandResult ready = AtCmdWaitChar(env, env->stdRxTimeout, '>');
if (ready != AT_OK) {
AtCmdSendStatic(env, AT_ESC_STR);
return ready;
}
AtCmdSend(env, data, dataLen);
AtCmdSendStatic(env, AT_ESC_STR);
return AtCmdOkErrAnswer(env, env->stdRxTimeout);
*/
}
/*
AtCommandResult AtGsmSimComA7600_SocketSendData(
tAtCmd *env, uint8_t linkNum, uint8_t *data, uint16_t dataLen, uint32_t timeout
) {
return AtGsmSimComA7600_SocketSendDataUdp(env, linkNum, data, dataLen, 0, 0, 0, timeout);
}
AtCommandResult AtGsmSimComA7600_SocketSendDataUdp(
tAtCmd *env,
uint8_t linkNum,
uint8_t *data,
uint16_t dataLen,
char *srvIp,
uint8_t srvIpLen,
uint16_t srvPort,
uint32_t timeout
) {
AtCmdPrepare(env);
if (linkNum > 9) {
return AT_ERROR;
}
AtCmdTxClear(env);
AtCmdTxAddStatic(env, "AT+CIPSEND=");
AtCmdTxAddDecimalIntWithLimit(env, linkNum, 1);
AtCmdTxAddChar(env, ',');
AtCmdTxAddDecimalIntWithLimit(env, dataLen, 5);
if (srvPort || srvIpLen) {
AtCmdTxAddChar(env, ',');
if (srvIpLen) {
AtCmdTxAddChar(env, '"');
AtCmdTxAdd(env, srvIp, srvIpLen);
AtCmdTxAddChar(env, '"');
}
if (srvPort) {
AtCmdTxAddChar(env, ',');
AtCmdTxAddDecimalIntWithLimit(env, srvPort, 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, "+CIPERROR:")) {
AtCmdRxClear(env);
return AT_ERROR;
} else if (AtCmdRxBeginWithStatic(env, "+CIPSEND: ")) {
//todo check
AtCmdRxClear(env);
return AT_OK;
} else {
AtCmdProcessUnresolvedLine(env);
AtCmdRxClear(env);
continue;
}
} else {
if (AtCmdRxBeginWithStatic(env, ">")) {
AtCmdRxClear(env);
AtCmdSend(env, data, dataLen);
}
}
}
return AT_TIMEOUT;
}
*/

View File

@ -0,0 +1,70 @@
//
// 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;
}

View File

@ -0,0 +1,15 @@
//
// Created by xemon on 10.05.23.
//
#include "AtGsmTelitLe910_StopSocketService.h"
#include "AtCmdCommonProtected.h"
#include "SystemDelayInterface.h"
AtCommandResult AtGsmSimComA7600_StopSocketService(tAtCmd *env) {
AtCmdPrepare(env);
AtCmdSendStatic(env, "AT+NETCLOSE\r\n");
return AtCmdOkErrAnswer(env, env->stdRxTimeout);
}

17
modular.json Executable file
View File

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