175 lines
5.3 KiB
C
175 lines
5.3 KiB
C
//
|
|
// Created by xemon on 24.10.22.
|
|
//
|
|
|
|
#include <AsciiStringAssmeblingUtils.h>
|
|
#include <AtCmdCommonProtected.h>
|
|
#include <string.h>
|
|
#include <SystemDelayInterface.h>
|
|
#include "AtGsmSimcomSim7600_Ecall.h"
|
|
#include "cmsis_os2.h"
|
|
|
|
AtCommandResult AtGsmSimComSim7600_EcallSetUrc(tAtCmd *env, eGsmSimcomEcallUrcLevel mode) {
|
|
return 0;
|
|
}
|
|
|
|
AtCommandResult AtGsmSimComSim7600_HangUpCall(tAtCmd *env) {
|
|
if (osMutexAcquire(&env->access, 1000) == osOK) {
|
|
AtCmdPrepare(env);
|
|
AtCmdSendStatic(env, "AT+CHUP\r\n");
|
|
osMutexRelease(&env->access);
|
|
return AtCmdOkErrAnswer(env, 5 * env->stdRxTimeout);
|
|
}
|
|
return AT_TIMEOUT;
|
|
// AtCmdPrepare(env);
|
|
// AtCmdSendStatic(env, "AT+CHUP\r\n");
|
|
// return AtCmdOkErrAnswer(env, 5 * env->stdRxTimeout);
|
|
}
|
|
|
|
AtCommandResult AtGsmSimComSim7600_EcallWriteMsdToModem(
|
|
tAtCmd *env,
|
|
eEcallActivationType activationType,
|
|
eEcallTestMode testMode,
|
|
uint8_t *msd,
|
|
size_t msdLength
|
|
) {
|
|
|
|
uint16_t staticSizeData = 281;
|
|
char dataInModemFormat[staticSizeData];
|
|
size_t dataInModemFormatLen = 0;
|
|
memset(dataInModemFormat, '0', staticSizeData);
|
|
vAsciiStringAddBytesAsHex(dataInModemFormat, &dataInModemFormatLen, msd, msdLength);
|
|
dataInModemFormat[staticSizeData - 1] = 0x1A;
|
|
|
|
AtCmdTxClear(env);
|
|
AtCmdPrepare(env);
|
|
|
|
AtCmdTxAddStatic(env, "AT+CMSD=");
|
|
AtCmdTxAddStatic(env, "\"");
|
|
AtCmdTxAdd(env, dataInModemFormat, dataInModemFormatLen);
|
|
AtCmdTxAddStatic(env, "\"");
|
|
AtCmdTxAddStatic(env, ",");
|
|
if (activationType == MANUAL_ACTIVATION) {
|
|
AtCmdTxAddStatic(env, "0");
|
|
} else if (activationType == AUTOMATIC_ACTIVATION) {
|
|
AtCmdTxAddStatic(env, "1");
|
|
}
|
|
|
|
AtCmdTxAddStatic(env, ",");
|
|
if (testMode == TEST_CALL) {
|
|
AtCmdTxAddStatic(env, "0");
|
|
} else if (testMode == EMERGENCY_CALL) {
|
|
AtCmdTxAddStatic(env, "1");
|
|
}
|
|
|
|
AtCmdTxSendLn(env);
|
|
return AtCmdOkErrAnswer(env, env->stdRxTimeout);
|
|
}
|
|
|
|
AtCommandResult AtGsmSimComSim7600_EcallMake(
|
|
tAtCmd *env,
|
|
char *phoneNumber,
|
|
size_t phoneNumberLength
|
|
) {
|
|
|
|
AtCmdTxClear(env);
|
|
AtCmdPrepare(env);
|
|
|
|
AtCmdTxAddStatic(env, "AT+CECALLS=");
|
|
AtCmdTxAdd(env, phoneNumber, phoneNumberLength);
|
|
AtCmdTxAddStatic(env, ", 1");
|
|
AtCmdTxSendLn(env);
|
|
|
|
return AtCmdOkErrAnswer(env, 20 * env->stdRxTimeout);
|
|
|
|
}
|
|
|
|
|
|
AtCommandResult AtGsmSimComSim7600_SendEcall(
|
|
tAtCmd *env,
|
|
|
|
eEcallActivationType activationType,
|
|
eEcallTestMode testMode,
|
|
|
|
uint8_t *msd,
|
|
size_t msdLength,
|
|
|
|
char *phoneNumber,
|
|
size_t phoneNumberLength
|
|
) {
|
|
if (osMutexAcquire(env->access, 10000) == osOK) {
|
|
if (AtGsmSimComSim7600_EcallWriteMsdToModem(env,
|
|
activationType,
|
|
testMode,
|
|
msd,
|
|
msdLength) == AT_OK) {
|
|
if (AtGsmSimComSim7600_EcallMake(env, phoneNumber, phoneNumberLength) == AT_OK) {
|
|
osMutexRelease(env->access);
|
|
return AT_OK;
|
|
}
|
|
osMutexRelease(env->access);
|
|
return AT_ERROR;
|
|
} else {
|
|
osMutexRelease(env->access);
|
|
return AT_ERROR;
|
|
}
|
|
} else {
|
|
return AT_ERROR;
|
|
}
|
|
|
|
// AT_INOKR(AtGsmSimComSim7600_EcallWriteMsdToModem(env,
|
|
// activationType,
|
|
// testMode,
|
|
// msd,
|
|
// msdLength))
|
|
//
|
|
// SystemDelayMs(100);
|
|
// AT_INOKR(AtGsmSimComSim7600_EcallMake(env, phoneNumber, phoneNumberLength))
|
|
// SystemDelayMs(100);
|
|
//
|
|
// return AT_OK;
|
|
|
|
}
|
|
|
|
AtCommandResult AtGsmSimComSim7600_EcallPushMsd(tAtCmd *env) {
|
|
AtCmdPrepare(env);
|
|
return AtCmdOkErrAnswer(env, 2 * env->stdRxTimeout);
|
|
}
|
|
|
|
AtCommandResult AtGsmSimComSim7600_ResetiingMsd(
|
|
tAtCmd *env,
|
|
uint8_t *msd,
|
|
size_t msdLength,
|
|
eEcallActivationType activationType,
|
|
eEcallTestMode testMode
|
|
) {
|
|
if (osMutexAcquire(env->access, 1000) == osOK) {
|
|
if (AtGsmSimComSim7600_EcallWriteMsdToModem(env,
|
|
activationType,
|
|
testMode,
|
|
msd,
|
|
msdLength) == AT_OK) {
|
|
if (AtGsmSimComSim7600_EcallPushMsd(env) == AT_OK) {
|
|
osMutexRelease(env->access);
|
|
return AT_OK;
|
|
} else {
|
|
osMutexRelease(env->access);
|
|
return AT_ERROR;
|
|
}
|
|
} else {
|
|
osMutexRelease(env->access);
|
|
return AT_ERROR;
|
|
}
|
|
} else {
|
|
return AT_ERROR;
|
|
}
|
|
// AT_INOKR(AtGsmSimComSim7600_EcallWriteMsdToModem(env,
|
|
// activationType,
|
|
// testMode,
|
|
// msd,
|
|
// msdLength))
|
|
// SystemDelayMs(100);
|
|
// AT_INOKR(AtGsmSimComSim7600_EcallPushMsd(env))
|
|
//
|
|
// return AT_OK;
|
|
} |