151 lines
3.6 KiB
C
151 lines
3.6 KiB
C
//
|
|
// Created by xemon on 24.10.22.
|
|
//
|
|
|
|
#include <AsciiStringAssmeblingUtils.h>
|
|
#include <AtCmdCommonProtected.h>
|
|
#include <string.h>
|
|
#include <SystemDelayInterface.h>
|
|
#include "AtGsmTelitLe910_Ecall.h"
|
|
|
|
|
|
|
|
AtCommandResult AtGsmTelitLe910_EcallSetUrc(tAtCmd *env, eGsmTelitEcallUrcLevel mode) {
|
|
AtCmdPrepare(env);
|
|
|
|
AtCmdTxClear(env);
|
|
AtCmdTxAddStatic(env, "AT#ECALLURC=");
|
|
AtCmdTxAddChar(env, mode);
|
|
AtCmdTxSendLn(env);
|
|
|
|
return AtCmdOkErrAnswer(env, env->stdRxTimeout);
|
|
}
|
|
|
|
AtCommandResult AtGsmTelitLe910_EcallSetTestNumber(tAtCmd *env, char *phoneNumber, size_t phoneNumberLength) {
|
|
AtCmdPrepare(env);
|
|
|
|
AtCmdTxClear(env);
|
|
AtCmdTxAddStatic(env, "AT#TESTNUM=0,");
|
|
AtCmdTxAdd(env, phoneNumber, phoneNumberLength);
|
|
AtCmdTxSendLn(env);
|
|
|
|
return AtCmdOkErrAnswer(env, env->stdRxTimeout);
|
|
}
|
|
|
|
AtCommandResult AtGsmTelitLe910_EcallSetModeBattle(tAtCmd *env) {
|
|
AtCmdPrepare(env);
|
|
|
|
AtCmdSendStatic(env, "AT#ECALL=1\r\n");
|
|
|
|
return AtCmdOkErrAnswer(env, env->stdRxTimeout);
|
|
}
|
|
|
|
AtCommandResult AtGsmTelitLe910_SIMCardDetect(tAtCmd *env) {
|
|
AtCmdPrepare(env);
|
|
|
|
AtCmdSendStatic(env, "AT#SIMDET=1\r\n");
|
|
|
|
return AtCmdOkErrAnswer(env, env->stdRxTimeout);
|
|
}
|
|
|
|
AtCommandResult AtGsmTelitLe910_SIMCardNoDetect(tAtCmd *env) {
|
|
AtCmdPrepare(env);
|
|
|
|
AtCmdSendStatic(env, "AT#SIMDET=0\r\n");
|
|
|
|
return AtCmdOkErrAnswer(env, env->stdRxTimeout);
|
|
}
|
|
|
|
AtCommandResult AtGsmTelitLe910_EcallWriteMsdToModem(tAtCmd *env, uint8_t *msd, size_t msdLength) {
|
|
|
|
//prepare msd data packet
|
|
char dataInModemFormat[281];
|
|
size_t dataInModemFormatLen = 0;
|
|
memset(dataInModemFormat, '0', 281);
|
|
vAsciiStringAddBytesAsHex(dataInModemFormat, &dataInModemFormatLen, msd, msdLength);
|
|
dataInModemFormat[280] = 0x1A;
|
|
|
|
//execute at
|
|
AtCmdPrepare(env);
|
|
|
|
AtCmdSendStatic(env, "AT#MSDSEND\r\n");
|
|
AtCmdWaitChar(env, 10000, '>');
|
|
|
|
AtCmdSend(env, (uint8_t *) dataInModemFormat, 281);
|
|
|
|
|
|
return AtCmdOkErrAnswer(env, env->stdRxTimeout);
|
|
}
|
|
|
|
AtCommandResult AtGsmTelitLe910_EcallPushMsd(tAtCmd *env) {
|
|
AtCmdPrepare(env);
|
|
|
|
AtCmdSendStatic(env, "AT#MSDPUSH\r\n");
|
|
|
|
return AtCmdOkErrAnswer(env, 2 * env->stdRxTimeout);
|
|
}
|
|
|
|
|
|
AtCommandResult AtGsmTelitLe910_EcallMake(tAtCmd *env, eGsmEcallType value) {
|
|
|
|
AtCmdPrepare(env);
|
|
|
|
AtCmdTxClear(env);
|
|
AtCmdTxAddStatic(env, "AT+CECALL=");
|
|
AtCmdTxAddDecimalInt(env, value, 1);
|
|
AtCmdTxSendLn(env);
|
|
|
|
return AtCmdOkErrAnswer(env, 25 * env->stdRxTimeout);
|
|
|
|
}
|
|
|
|
|
|
//GsmCommandResult AtGsmTelitLe910_EcallMsdRead(tGsmAt *env) {
|
|
// vGsmClearRx(env);
|
|
// vSendAtStatic(env, "AT#MSDREAD\r");
|
|
// xGsmWaitAnswerLine(env, "#MSDREAD:", 20000);
|
|
// return xGsmOkErrAnswer(env, 1000);
|
|
//}
|
|
|
|
|
|
|
|
AtCommandResult AtGsmTelitLe910_SendEcall(
|
|
tAtCmd *env,
|
|
|
|
uint8_t *msd,
|
|
size_t msdLength,
|
|
|
|
char *phoneNumber,
|
|
size_t phoneNumberLength,
|
|
|
|
eGsmEcallType ecallType
|
|
) {
|
|
|
|
if (ecallType == GSM_ECALLTYPE_TEST) {
|
|
AT_INOKR(AtGsmTelitLe910_EcallSetTestNumber(env, phoneNumber, phoneNumberLength))
|
|
SystemDelayMs(100);
|
|
}
|
|
|
|
AT_INOKR(AtGsmTelitLe910_EcallSetModeBattle(env))
|
|
SystemDelayMs(100);
|
|
AT_INOKR(AtGsmTelitLe910_EcallWriteMsdToModem(env, msd, msdLength))
|
|
SystemDelayMs(100);
|
|
AT_INOKR(AtGsmTelitLe910_EcallPushMsd(env))
|
|
SystemDelayMs(100);
|
|
AT_INOKR(AtGsmTelitLe910_EcallMake(env, ecallType))
|
|
|
|
return AT_OK;
|
|
}
|
|
|
|
AtCommandResult AtGsmTelitLe910_ResetiingMsd(
|
|
tAtCmd *env,
|
|
uint8_t *msd,
|
|
size_t msdLength
|
|
) {
|
|
|
|
AT_INOKR(AtGsmTelitLe910_EcallWriteMsdToModem(env, msd, msdLength))
|
|
SystemDelayMs(100);
|
|
AT_INOKR(AtGsmTelitLe910_EcallPushMsd(env))
|
|
|
|
return AT_OK;
|
|
} |