119 lines
2.7 KiB
C
119 lines
2.7 KiB
C
//
|
|
// Created by cfif on 10.05.23.
|
|
//
|
|
#include "AtGsmSimComA7600_DefinePdpContext.h"
|
|
#include "AtCmdCommonProtected.h"
|
|
#include "SystemDelayInterface.h"
|
|
|
|
|
|
AtCommandResult AtGsmSimComA7600_DefinePdpAuthContext(
|
|
tAtCmd *env, uint8_t cid, uint8_t auth_type, const char *user, uint8_t userLen, const char *pass, uint8_t passLen
|
|
) {
|
|
AtCmdPrepare(env);
|
|
AtCmdRxClear(env);
|
|
|
|
if (cid > 15) {
|
|
return AT_ERROR;
|
|
}
|
|
|
|
AtCmdTxClear(env);
|
|
AtCmdTxAddStatic(env, "AT+CGAUTH=");
|
|
AtCmdTxAddDecimalIntWithLimit(env, cid, 2);
|
|
AtCmdTxAddChar(env, ',');
|
|
AtCmdTxAddDecimalIntWithLimit(env, auth_type, 2);
|
|
AtCmdTxAddChar(env, ',');
|
|
|
|
AtCmdTxAddChar(env, '"');
|
|
AtCmdTxAdd(env, pass, passLen);
|
|
AtCmdTxAddChar(env, '"');
|
|
|
|
AtCmdTxAddChar(env, ',');
|
|
|
|
AtCmdTxAddChar(env, '"');
|
|
AtCmdTxAdd(env, user, userLen);
|
|
AtCmdTxAddChar(env, '"');
|
|
|
|
AtCmdTxSendLn(env);
|
|
|
|
return AtCmdOkErrAnswer(env, 10000);
|
|
}
|
|
|
|
|
|
AtCommandResult AtGsmSimComA7600_DefinePdpContext(
|
|
tAtCmd *env, uint8_t cid, eAtGsmSimComA7600_PdpType pdpType, const char *apn, uint8_t apnLen
|
|
) {
|
|
AtCmdPrepare(env);
|
|
AtCmdRxClear(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, 10000);
|
|
}
|
|
|
|
AtCommandResult AtGsmSimComA7600_PdpActivate(tAtCmd *env, uint8_t cid) {
|
|
AtCmdPrepare(env);
|
|
AtCmdRxClear(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);
|
|
}
|
|
|
|
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);
|
|
}
|