From 21efdf6b0eac8d4bbf3aac946af9add6c424dd53 Mon Sep 17 00:00:00 2001 From: cfif Date: Mon, 2 Jun 2025 13:26:41 +0300 Subject: [PATCH] Init --- Inc/AtGsmSim7600e_AudioFileAndStream.h | 38 ++ Inc/AtGsmSim7600e_DigitalVoicebandInterface.h | 41 ++ Inc/AtGsmSimcomSim7600.h | 15 + Inc/AtGsmSimcomSim7600_Ecall.h | 48 ++ Inc/AtGsmSimcomSim7600_Gnss.h | 52 +++ Inc/GsmSimComAudioCodec.h | 9 + Src/AtGsmSim7600e_AudioFileAndStream.c | 270 ++++++++++++ Src/AtGsmSim7600e_DigitalVoicebandInterface.c | 73 ++++ Src/AtGsmSimcomSim7600_Ecall.c | 175 ++++++++ Src/AtGsmSimcomSim7600_Gnss.c | 411 ++++++++++++++++++ Src/GsmSimComAudioCodec.c | 76 ++++ modular.json | 22 + 12 files changed, 1230 insertions(+) create mode 100644 Inc/AtGsmSim7600e_AudioFileAndStream.h create mode 100644 Inc/AtGsmSim7600e_DigitalVoicebandInterface.h create mode 100644 Inc/AtGsmSimcomSim7600.h create mode 100644 Inc/AtGsmSimcomSim7600_Ecall.h create mode 100644 Inc/AtGsmSimcomSim7600_Gnss.h create mode 100644 Inc/GsmSimComAudioCodec.h create mode 100644 Src/AtGsmSim7600e_AudioFileAndStream.c create mode 100644 Src/AtGsmSim7600e_DigitalVoicebandInterface.c create mode 100644 Src/AtGsmSimcomSim7600_Ecall.c create mode 100644 Src/AtGsmSimcomSim7600_Gnss.c create mode 100644 Src/GsmSimComAudioCodec.c create mode 100644 modular.json diff --git a/Inc/AtGsmSim7600e_AudioFileAndStream.h b/Inc/AtGsmSim7600e_AudioFileAndStream.h new file mode 100644 index 0000000..2604512 --- /dev/null +++ b/Inc/AtGsmSim7600e_AudioFileAndStream.h @@ -0,0 +1,38 @@ +// +// Created by xemon on 14.11.22. +// + +#ifndef UVEOS_ON_NATION_ATGSMSIM7600E_AUDIOFILEANDSTREAM_H +#define UVEOS_ON_NATION_ATGSMSIM7600E_AUDIOFILEANDSTREAM_H + + +#include "AtCmdCommon.h" + +typedef enum { + SIM7600E_AUDIO_FILE_PLAY_TO_SPEAKER = '2', + SIM7600E_AUDIO_FILE_PLAY_TO_UPLINK = '1' +} eSim7600ePlayAudioFileDir; + +AtCommandResult AtGsmSimComSim7600E_PlayAudioWaitBegin(tAtCmd *env, uint32_t timeout); +AtCommandResult AtGsmSimComSim7600E_PlayAudioWaitEndMp3(tAtCmd *env, uint32_t timeout); +AtCommandResult AtGsmSimComSim7600E_PlayAudioWaitEndWav(tAtCmd *env, uint32_t timeout); +AtCommandResult AtGsmSimComSim7600E_RecordAudioWaitToEnd(tAtCmd *env, uint32_t timeout); +AtCommandResult AtGsmSimComSim7600E_PlayWavAudioFileTo(tAtCmd *env, eSim7600ePlayAudioFileDir dir, char *name, size_t nameLen); +AtCommandResult AtGsmSimComSim7600E_PlayMp3AudioFileTo(tAtCmd *env, eSim7600ePlayAudioFileDir dir, char *name, size_t nameLen); + +AtCommandResult AtGsmSimComSim7600E_PlayToneUds(tAtCmd *env); + + +AtCommandResult AtGsmSimComSim7600E_PlayTone(tAtCmd *env); +AtCommandResult AtGsmSimComSim7600E_PlayAudioStopWav(tAtCmd *env, uint16_t timeout); +AtCommandResult AtGsmSimComSim7600E_PlayAudioStopMp3(tAtCmd *env, uint16_t timeout); +AtCommandResult AtGsmSimComSim7600E_RecorderAudioFileStart(tAtCmd *env, char *name, size_t nameLen); +AtCommandResult AtGsmSimComSim7600E_RecAudioFileTo(tAtCmd *env, char *name, size_t nameLen); +AtCommandResult AtGsmSimComSim7600E_DeleteAudioFile(tAtCmd *env, char *name, size_t nameLen); +AtCommandResult AtGsmSimComSim7600E_RecorderAudioFileStop(tAtCmd *env); +AtCommandResult AtGsmSimComSim7600E_RecorderAudioFileWaitStop(tAtCmd *env, uint64_t timeout); +AtCommandResult AtGsmSimComSim7600E_RecorderAudioIsBusy(tAtCmd *env); +AtCommandResult AtGsmSimComSim7600E_RecAudioWaitEnd(tAtCmd *env, uint32_t timeout); +AtCommandResult AtGsmSimComSim7600E_RecorderAudioFileWaitToStop(tAtCmd *env); +AtCommandResult AtGsmSimComSim7600E_RecorderAudioFileStopNotSubmit(tAtCmd *env); +#endif //UVEOS_ON_NATION_ATGSMSIM7600E_AUDIOFILEANDSTREAM_H diff --git a/Inc/AtGsmSim7600e_DigitalVoicebandInterface.h b/Inc/AtGsmSim7600e_DigitalVoicebandInterface.h new file mode 100644 index 0000000..374d0fa --- /dev/null +++ b/Inc/AtGsmSim7600e_DigitalVoicebandInterface.h @@ -0,0 +1,41 @@ +// +// Created by xemon on 20.10.22. +// + +#ifndef UVEOS_ON_NATION_ATGSMSIM7600E_AUDIOINTERFACE_H +#define UVEOS_ON_NATION_ATGSMSIM7600E_AUDIOINTERFACE_H + +#include "AtCmdCommon.h" +/* +typedef enum { + AT_GSM_TELIT_910_DVI_CLOCK_0_KHz = 0, + AT_GSM_TELIT_910_DVI_CLOCK_128_KHz = 7, + AT_GSM_TELIT_910_DVI_CLOCK_256_KHz = 8, + AT_GSM_TELIT_910_DVI_CLOCK_512_KHz = 9, + AT_GSM_TELIT_910_DVI_CLOCK_1024_KHz = 10, + AT_GSM_TELIT_910_DVI_CLOCK_2048_KHz = 11, + AT_GSM_TELIT_910_DVI_CLOCK_4096_KHz = 12, +} eAtGsmTelitLe910DviClock; + +typedef enum { + AT_GSM_TELIT_910_DVI_SAMPLE_RATE_8KHz = '0', + AT_GSM_TELIT_910_DVI_SAMPLE_RATE_16KHz = '1', +} eAtGsmTelitLe910DviSampleRate; + +AtCommandResult AtGsmTelitLe910_SetSpeakerVolumeLevel(tAtCmd *env, uint16_t level); + +AtCommandResult AtGsmTelitLe910_DviEnableMaster(tAtCmd *env); + +AtCommandResult AtGsmTelitLe910_DviToPcmMode(tAtCmd *env); + +AtCommandResult AtGsmTelitLe910_DviPcmClk( + tAtCmd *env, + eAtGsmTelitLe910DviClock clock, + eAtGsmTelitLe910DviSampleRate sampleRate +); + +AtCommandResult AtGsmTelitLe910_DviToI2s16Khz(tAtCmd *env); + +AtCommandResult AtGsmTelitLe910_DviToI2s8Khz(tAtCmd *env); +*/ +#endif //UVEOS_ON_NATION_ATGSMSIM7600E_AUDIOINTERFACE_H diff --git a/Inc/AtGsmSimcomSim7600.h b/Inc/AtGsmSimcomSim7600.h new file mode 100644 index 0000000..f56bd82 --- /dev/null +++ b/Inc/AtGsmSimcomSim7600.h @@ -0,0 +1,15 @@ +// +// Created by zemon on 31.03.23. +// + +#ifndef UVEOS_ON_NATION_ATGSMSIMCOMSIM7600_H +#define UVEOS_ON_NATION_ATGSMSIMCOMSIM7600_H + +#include + +#include "AtGsmCommon.h" +#include "AtGsmSimcomSim7600_Gnss.h" +#include "AtGsmSimcomSim7600_Ecall.h" +#include "AtGsmSim7600e_AudioFileAndStream.h" + +#endif //UVEOS_ON_NATION_ATGSMSIMCOMSIM7600_H diff --git a/Inc/AtGsmSimcomSim7600_Ecall.h b/Inc/AtGsmSimcomSim7600_Ecall.h new file mode 100644 index 0000000..4c2112c --- /dev/null +++ b/Inc/AtGsmSimcomSim7600_Ecall.h @@ -0,0 +1,48 @@ +// +// Created by xemon on 24.10.22. +// + +#ifndef UVEOS_ON_NATION_ATGSMTELITLE910_ECALL_H +#define UVEOS_ON_NATION_ATGSMTELITLE910_ECALL_H + +#include "AtCmdCommon.h" +#include "EcallTypes.h" + +typedef enum { + GSM_ECALLTYPE_TEST = 0, + GSM_ECALLTYPE_RECONFIGURATION = 1, + GSM_ECALLTYPE_MANUAL = 2, + GSM_ECALLTYPE_AUTOMATIC = 3, +} eGsmEcallType; + +typedef enum { + GSM_SIMCOM_ECALL_URC_MODE_0 = '0', + GSM_SIMCOM_ECALL_URC_MODE_1 = '1', + GSM_SIMCOM_ECALL_URC_MODE_2 = '2' +} eGsmSimcomEcallUrcLevel; + +AtCommandResult AtGsmSimComSim7600_EcallSetUrc(tAtCmd *env, eGsmSimcomEcallUrcLevel mode); +AtCommandResult AtGsmSimComSim7600_HangUpCall(tAtCmd *env); + +AtCommandResult AtGsmSimComSim7600_SendEcall( + tAtCmd *env, + + eEcallActivationType activationType, + eEcallTestMode testMode, + + uint8_t *msd, + size_t msdLength, + + char *phoneNumber, + size_t phoneNumberLength +); + +AtCommandResult AtGsmSimComSim7600_ResetiingMsd( + tAtCmd *env, + uint8_t *msd, + size_t msdLength, + eEcallActivationType activationType, + eEcallTestMode testMode +); + +#endif //UVEOS_ON_NATION_ATGSMTELITLE910_ECALL_H diff --git a/Inc/AtGsmSimcomSim7600_Gnss.h b/Inc/AtGsmSimcomSim7600_Gnss.h new file mode 100644 index 0000000..17bea5c --- /dev/null +++ b/Inc/AtGsmSimcomSim7600_Gnss.h @@ -0,0 +1,52 @@ +// +// Created by zemon on 05.04.23. +// +/// factoryTest +#ifndef UVEOS_ON_NATION_ATGSMSIMCOMSIM7600_GNSS_H +#define UVEOS_ON_NATION_ATGSMSIMCOMSIM7600_GNSS_H + +#include "AtGsmCommon.h" +#include "BaseTypes/Strings.h" + +typedef enum { + SIMCOM_SIM7600_EXTERNAL_LNA_NOT_SUPPORT = '0', + SIMCOM_SIM7600_EXTERNAL_LNA_SUPPORT = '1' +} eSimcomSim7600_ExternalLnaSupportMode; + +typedef enum { + SIMCOM_FUNC_MINIMAL = '0', + SIMCOM_FUNC_MAXIMAL = '1', + SIMCOM_DISABLED_FHONE = '2', + SIMCOM_FACTORY_TEST = '3', + SIMCOM_RESET = '4', + SIMCOM_OFFLINE = '5' +} eSimcomSim7600_FuncMode; + +typedef enum { + SIMCOM_SIM7600_ERA_GLONASS_PROFILE = '0', + SIMCOM_SIM7600_BOOTSTRAP_PROFILE = '1', + SIMCOM_SIM7600_TEST_PROFILE = '2' +} eSimcomSim7600_SimProfileType; + +AtCommandResult AtGsm_Gsnss_Simcom7600_GnssStopThread(tAtCmd *env); +AtCommandResult AtGsm_Gsnss_Simcom7600_SetWorkingState(tAtCmd *env, eSimcomSim7600_FuncMode funcMode); +AtCommandResult AtGsm_Gsnss_Simcom7600_SimProfileSelect(tAtCmd *env, tStringLink profileData); +AtCommandResult AtGsm_Gsnss_Simcom7600_EcallOnlyMode(tAtCmd *env, bool mode); +AtCommandResult AtGsm_Gsnss_Simcom7600_EchoMode(tAtCmd *env, bool mode); +AtCommandResult AtGsm_Gsnss_Simcom7600_ManualPowerMode(tAtCmd *env, const bool *mode); +AtCommandResult AtGsm_Gsnss_Simcom7600_SetModemLTEPowerMode(tAtCmd *env, const uint16_t *value); +AtCommandResult AtGsm_Gsnss_Simcom7600_SetModemWCDMAPowerMode(tAtCmd *env, const uint16_t *value); +AtCommandResult AtGsm_Gsnss_Simcom7600_SetModemGSMPowerMode(tAtCmd *env, const uint16_t *value); +AtCommandResult AtGsm_Gsnss_Simcom7600_DeleteGpsInfo(tAtCmd *env); +AtCommandResult AtGsm_Gsnss_Simcom7600_SetConfigureStaticRMCThread(tAtCmd *env); +AtCommandResult AtGsm_Gsnss_Simcom7600_SetConfigureAudioProfile(tAtCmd *env, tString32 *profileData); +AtCommandResult AtGsm_Gsnss_Simcom7600_StartReceiver(tAtCmd *env, bool value); +AtCommandResult AtGsm_Gsnss_Simcom7600_HotStartReceiver(tAtCmd *env); +AtCommandResult AtGsm_Gsnss_Simcom7600_SetExternalLnaSupport(tAtCmd *env, eSimcomSim7600_ExternalLnaSupportMode value); +AtCommandResult AtGsm_Gsnss_Simcom7600_GetCGSN(tAtCmd *env, char *acpString, size_t *acpStringLen); +AtCommandResult AtGsm_Gsnss_Simcom7600_GetAudioFilesValidation(tAtCmd *env); +AtCommandResult AtGsm_Gsnss_Simcom7600_GetCCID(tAtCmd *env, char *acpString, size_t *acpStringLen); +AtCommandResult AtGsm_Gsnss_Simcom7600_GetSoftRevInModem(tAtCmd *env, char *cgmrStr, size_t *cgmrStrLen); +AtCommandResult AtGsm_Gsnss_Simcom7600_OpenADB(tAtCmd *env); + +#endif //UVEOS_ON_NATION_ATGSMSIMCOMSIM7600_GNSS_H diff --git a/Inc/GsmSimComAudioCodec.h b/Inc/GsmSimComAudioCodec.h new file mode 100644 index 0000000..2af463e --- /dev/null +++ b/Inc/GsmSimComAudioCodec.h @@ -0,0 +1,9 @@ +// +// Created by ilya on 27.03.24. +// + +#ifndef SMART_COMPONENTS_GSMSIMCOMAUDIOCODEC_H +#define SMART_COMPONENTS_GSMSIMCOMAUDIOCODEC_H +#include "AtCmdCommonProtected.h" +AtCommandResult AtGsmSimCom_NAU_Codec_Full10w(tAtCmd *env); +#endif //SMART_COMPONENTS_GSMSIMCOMAUDIOCODEC_H diff --git a/Src/AtGsmSim7600e_AudioFileAndStream.c b/Src/AtGsmSim7600e_AudioFileAndStream.c new file mode 100644 index 0000000..e79806d --- /dev/null +++ b/Src/AtGsmSim7600e_AudioFileAndStream.c @@ -0,0 +1,270 @@ +// +// Created by xemon on 14.11.22. +// +#include "AtGsmSim7600e_AudioFileAndStream.h" +#include +#include + + +AtCommandResult AtGsmSimComSim7600E_PlayWavAudioFileTo(tAtCmd *env, eSim7600ePlayAudioFileDir dir, char *name, size_t nameLen) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CCMXPLAYWAV="); + AtCmdTxAddStatic(env, "\"E:/"); + AtCmdTxAdd(env, name, nameLen); + AtCmdTxAddStatic(env, "\""); + AtCmdTxAddStatic(env, ", "); + AtCmdTxAddChar(env, dir); + AtCmdTxSendLn(env); + return AtCmdOkErrAnswer(env, env->stdRxTimeout); +} + + +AtCommandResult AtGsmSimComSim7600E_PlayToneUds(tAtCmd *env) { + AtCmdRxClear(env); + AtCmdPrepare(env); + AtCmdSendStatic(env, "AT+CPTONE=1,1000,1000"); + return AtCmdWaitOk(env, 10, 500); +} + +AtCommandResult AtGsmSimComSim7600E_PlayTone(tAtCmd *env) { + AtCmdRxClear(env); + AtCmdPrepare(env); + AtCmdSendStatic(env, "AT+CPTONE=1,200,1000"); + return AtCmdWaitOk(env, 10, 500); +// +// AtCmdPrepare(env); +// AtCmdTxClear(env); +// AtCmdTxAddStatic(env, "AT+CCMXPLAY="); +// AtCmdTxAddStatic(env, "\"E:/"); +// AtCmdTxAdd(env, name, nameLen); +// AtCmdTxAddStatic(env, "\""); +// AtCmdTxAddStatic(env, ", "); +// if(dir == SIM7600E_AUDIO_FILE_PLAY_TO_SPEAKER){ +// AtCmdTxAddStatic(env, "0, 0"); +// } else { +// AtCmdTxAddStatic(env, "1, 0"); +// } +// AtCmdTxSendLn(env); +// +// AtCommandResult res = AT_ERROR; +// uint32_t endMs = SystemGetMs() + 1000; +// uint32_t leftMs; +// +// while (endMs > SystemGetMs()) { +// leftMs = endMs - SystemGetMs(); +// if (AtCmdReceiveNextLine(env, leftMs) == AT_OK) { +// if (AtCmdRxBeginWithStatic(env, "+CCMXPLAY:")){ +// return AT_OK; +// } +// AtCmdProcessUnresolvedLine(env); +// } +// } +// return AT_ERROR; + +} +AtCommandResult AtGsmSimComSim7600E_PlayMp3AudioFileTo(tAtCmd *env, eSim7600ePlayAudioFileDir dir, char *name, size_t nameLen) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CCMXPLAY="); + AtCmdTxAddStatic(env, "\"E:/"); + AtCmdTxAdd(env, name, nameLen); + AtCmdTxAddStatic(env, "\""); + AtCmdTxAddStatic(env, ", "); + if(dir == SIM7600E_AUDIO_FILE_PLAY_TO_SPEAKER){ + AtCmdTxAddStatic(env, "0, 0"); + } else { + AtCmdTxAddStatic(env, "1, 0"); + } + AtCmdTxSendLn(env); + + AtCommandResult res = AT_ERROR; + uint32_t endMs = SystemGetMs() + 1000; + uint32_t leftMs; + + while (endMs > SystemGetMs()) { + leftMs = endMs - SystemGetMs(); + if (AtCmdReceiveNextLine(env, leftMs) == AT_OK) { + if (AtCmdRxBeginWithStatic(env, "+CCMXPLAY:")){ + return AT_OK; + } + AtCmdProcessUnresolvedLine(env); + } + } + return AT_ERROR; + +} + +AtCommandResult AtGsmSimComSim7600E_PlayAudioStopWav(tAtCmd *env, uint16_t timeout){ + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT+CCMXSTOPWAV\r\n"); + return AtCmdOkErrAnswer(env, env->stdRxTimeout); +} + +AtCommandResult AtGsmSimComSim7600E_PlayAudioStopMp3(tAtCmd *env, uint16_t timeout) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT+CCMXSTOP\r\n"); + + uint32_t endMs = SystemGetMs() + timeout; + uint32_t leftMs; + + while (endMs > SystemGetMs()) { + leftMs = endMs - SystemGetMs(); + if (AtCmdReceiveNextLine(env, leftMs) == AT_OK) { + if (AtCmdRxBeginWithStatic(env, "+CCMXSTOP:")){ + return AT_OK; + } + AtCmdProcessUnresolvedLine(env); + } + } + return AT_ERROR; +} + +AtCommandResult AtGsmSimComSim7600E_PlayAudioWaitBegin(tAtCmd *env, uint32_t timeout) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCommandResult res = AtCmdWaitPrefixStatic(env, timeout, "+WAVSTATE: wav play");; + return res; +} + +AtCommandResult AtGsmSimComSim7600E_PlayAudioWaitEndWav(tAtCmd *env, uint32_t timeout) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCommandResult res = AtCmdWaitPrefixStatic(env, timeout, "+WAVSTATE: wav play stop"); + return res; +} + +AtCommandResult AtGsmSimComSim7600E_RecordAudioWaitToEnd(tAtCmd *env, uint32_t timeout) { + uint32_t endMs = SystemGetMs() + timeout; + uint32_t leftMs; + + while (endMs > SystemGetMs()) { + leftMs = endMs - SystemGetMs(); + if (AtCmdReceiveNextLine(env, leftMs) == AT_OK) { + if (AtCmdRxBeginWithStatic(env, "+CREC: 0")){ + return AT_OK; + } + AtCmdProcessUnresolvedLine(env); + } + } + return AT_ERROR; +} + +AtCommandResult AtGsmSimComSim7600E_PlayAudioWaitEndMp3(tAtCmd *env, uint32_t timeout) { + uint32_t endMs = SystemGetMs() + timeout; + uint32_t leftMs; + + while (endMs > SystemGetMs()) { + leftMs = endMs - SystemGetMs(); + if (AtCmdReceiveNextLine(env, endMs) == AT_OK) { + if (AtCmdRxBeginWithStatic(env, "+AUDIOSTATE: audio play stop")){ + return AT_OK; + } + AtCmdProcessUnresolvedLine(env); + } + } + return AT_ERROR; +} + +AtCommandResult AtGsmSimComSim7600E_RecAudioFileTo(tAtCmd *env, char *name, size_t nameLen) { + AtCmdPrepare(env); + AtCmdTxClear(env); + + AtCmdTxAddStatic(env, "AT+CREC=1,"); + AtCmdTxAddStatic(env, "\"E:/"); + AtCmdTxAdd(env, name, nameLen); + AtCmdTxAddStatic(env, "\""); + AtCmdTxSendLn(env); + + uint32_t endMs = SystemGetMs() + 2000; + uint32_t leftMs; + + while (endMs > SystemGetMs()) { + leftMs = endMs - SystemGetMs(); + if (AtCmdReceiveNextLine(env, leftMs) == AT_OK) { + if (AtCmdRxBeginWithStatic(env, "+CREC: 1")){ + return AT_OK; + } + AtCmdProcessUnresolvedLine(env); + } + } + return AT_ERROR; + +} + +AtCommandResult AtGsmSimComSim7600E_RecorderAudioFileStart(tAtCmd *env, char *name, size_t nameLen) { + AtCmdPrepare(env); + AtCmdTxClear(env); + + AtCmdTxAddStatic(env, "AT+CREC=1,"); + AtCmdTxAddStatic(env, "\"E:/"); + AtCmdTxAdd(env, name, nameLen); + AtCmdTxAddStatic(env, "\""); + AtCmdTxSendLn(env); + return AtCmdOkErrAnswer(env, env->stdRxTimeout); +} + +AtCommandResult AtGsmSimComSim7600E_DeleteAudioFile(tAtCmd *env, char *name, size_t nameLen) { +// AtCmdPrepare(env); +// AtCmdTxClear(env); +// AtCmdTxAddStatic(env, "AT#ADELF="); +// AtCmdTxAddStatic(env, "\""); +// AtCmdTxAdd(env, name, nameLen); +// AtCmdTxAddStatic(env, "\""); +// AtCmdTxSendLn(env); +// return AtCmdOkErrAnswer(env, env->stdRxTimeout); + return AT_OK; +} + + +AtCommandResult AtGsmSimComSim7600E_RecorderAudioFileWaitToStop(tAtCmd *env) { + uint32_t endMs = SystemGetMs() + 2000; + uint32_t leftMs; + while (endMs > SystemGetMs()) { + leftMs = endMs - SystemGetMs(); + if (AtCmdReceiveNextLine(env, leftMs) == AT_OK) { + if (AtCmdRxBeginWithStatic(env, "+CREC: 0")){ + return AT_OK; + } + AtCmdProcessUnresolvedLine(env); + } + } + return AT_TIMEOUT; +} + +AtCommandResult AtGsmSimComSim7600E_RecorderAudioFileStopNotSubmit(tAtCmd *env) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT+CREC=0\r\n"); + AtCmdTxSendLn(env); + return AT_OK; +} + +AtCommandResult AtGsmSimComSim7600E_RecorderAudioFileStop(tAtCmd *env) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT+CREC=0\r\n"); + return AtCmdOkErrAnswer(env, env->stdRxTimeout); +} + +AtCommandResult AtGsmSimComSim7600E_RecorderAudioFileWaitStop(tAtCmd *env, uint64_t timeout) { + uint32_t endMs = SystemGetMs() + timeout; + uint32_t leftMs; + + while (endMs > SystemGetMs()) { + leftMs = endMs - SystemGetMs(); + if (AtCmdReceiveNextLine(env, leftMs) == AT_OK) { + if (AtCmdRxBeginWithStatic(env, "+CREC: 0")){ + return AT_OK; + } + AtCmdProcessUnresolvedLine(env); + } + } + return AT_ERROR; +} + +AtCommandResult AtGsmSimComSim7600E_RecAudioWaitEnd(tAtCmd *env, uint32_t timeout) { + return AtCmdWaitPrefixStatic(env, timeout, "#ARECDEV: 0"); +} \ No newline at end of file diff --git a/Src/AtGsmSim7600e_DigitalVoicebandInterface.c b/Src/AtGsmSim7600e_DigitalVoicebandInterface.c new file mode 100644 index 0000000..76dd673 --- /dev/null +++ b/Src/AtGsmSim7600e_DigitalVoicebandInterface.c @@ -0,0 +1,73 @@ +// +// Created by xemon on 20.10.22. +// +#include "AtGsmSim7600e_DigitalVoicebandInterface.h" +#include + +// level: 0-5 +AtCommandResult AtGsmSim7600e_LoudspeakerVolumeLevel(tAtCmd *env, uint8_t level) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CLVL="); + AtCmdTxAddDecimalIntWithLimit(env, level, 5); + AtCmdTxSendLn(env); + return AtCmdOkErrAnswer(env, env->stdRxTimeout); +} + +// value: 0-16 +// time: Duration, the default value is 50ms. Support 1-1000. +// gain: The default value is 4000. Support 1-9999. +AtCommandResult AtGsmSim7600e_Play_Tone(tAtCmd *env, uint8_t value, uint16_t time, uint16_t gain) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CPTONE=16,50,4000"); +// AtCmdTxAddDecimalInt(env, value, 16); +// AtCmdTxAddDecimalInt(env, time, 1000); +// AtCmdTxAddDecimalInt(env, gain, 9999); + AtCmdTxSendLn(env); + return AtCmdOkErrAnswer(env, env->stdRxTimeout); +} + +// mode: +// 0 – Module control codec when play sound. +// 1 – Host device control codec. Host device can open codec by +// AT+CSDVC=1 or AT+CSDVC=3, close codec by AT+CSDVC=0. +AtCommandResult AtGsmSim7600e_ControlCodecByHostDeviceOrModule(tAtCmd *env, uint8_t mode) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CODECCTL="); + AtCmdTxAddDecimalIntWithLimit(env, mode, 1); + AtCmdTxSendLn(env); + return AtCmdOkErrAnswer(env, env->stdRxTimeout); +} + +// mode: +// 0 – Close voice channel device. Only used after AT+CODECCTL=1 +// 1 – Handset. +// 3 – Speaker phone. +AtCommandResult AtGsmSim7600e_Switch_Voice_Channel_Device(tAtCmd *env, uint8_t mode) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CSDVC="); + AtCmdTxAddDecimalIntWithLimit(env, mode, 1); + AtCmdTxSendLn(env); + return AtCmdOkErrAnswer(env, env->stdRxTimeout); +} + +// volte_sample: +// 0 – Sampling rate is 16K. +// 1 – Sampling rate is 8K. +// novolte_sample: +// 0 – Sampling rate is 16K. +// 1 – Sampling rate is 8K. +AtCommandResult AtGsmSim7600e_Modify_The_Sampling_Rate_Of_The_PCM(tAtCmd *env, uint8_t volte_sample, uint8_t novolte_sample) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CPCMBANDWIDTH="); + AtCmdTxAddDecimalIntWithLimit(env, volte_sample, 1); + AtCmdTxAddStatic(env, ","); + AtCmdTxAddDecimalIntWithLimit(env, novolte_sample, 1); + AtCmdTxSendLn(env); + return AtCmdOkErrAnswer(env, env->stdRxTimeout); +} + diff --git a/Src/AtGsmSimcomSim7600_Ecall.c b/Src/AtGsmSimcomSim7600_Ecall.c new file mode 100644 index 0000000..70d3ff9 --- /dev/null +++ b/Src/AtGsmSimcomSim7600_Ecall.c @@ -0,0 +1,175 @@ +// +// Created by xemon on 24.10.22. +// + +#include +#include +#include +#include +#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; +} \ No newline at end of file diff --git a/Src/AtGsmSimcomSim7600_Gnss.c b/Src/AtGsmSimcomSim7600_Gnss.c new file mode 100644 index 0000000..23a3ccc --- /dev/null +++ b/Src/AtGsmSimcomSim7600_Gnss.c @@ -0,0 +1,411 @@ +// +// Created by zemon on 31.03.23. +// + +#include "AtGsmSimcomSim7600_Gnss.h" +#include "AtCmdCommonProtected.h" +#include "SystemDelayInterface.h" +#include "BaseTypes/Strings.h" +#include +#include + + +AtCommandResult AtGsm_Gsnss_Simcom7600_EcallOnlyMode(tAtCmd *env, bool mode) { + AtCmdPrepare(env); + AtCmdTxClear(env); + if(mode){ + AtCmdSendStatic(env, "AT+CECALLSTAT=1\r\n"); + } else{ + AtCmdSendStatic(env, "AT+CECALLSTAT=0\r\n"); + } + return AtCmdOkErrAnswer(env, 2000 * env->stdRxTimeout); +} + +AtCommandResult AtGsm_Gsnss_Simcom7600_SimProfileSelect(tAtCmd *env, tStringLink profileData) { + char simProfile[*profileData.length]; + memcpy(&simProfile, profileData.data, *profileData.length); + + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CSIM="); + AtCmdTxAddDecimalIntWithLimit(env, *profileData.length, 2); + AtCmdTxAddStatic(env, ", "); + AtCmdTxAddStatic(env, "\""); + AtCmdTxAdd(env, simProfile, *profileData.length); + AtCmdTxAddStatic(env, "\""); + AtCmdTxAddStatic(env, "\r\n"); + AtCmdTxSendLn(env); + + return AtCmdOkErrAnswer(env, 2000 * env->stdRxTimeout); +} + +AtCommandResult AtGsm_Gsnss_Simcom7600_SetModemGSMPowerMode(tAtCmd *env, const uint16_t *value) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT^BODYSARGSM="); + AtCmdTxAddDecimalIntWithLimit(env, *value, 2); + AtCmdTxSendLn(env); + return AtCmdOkErrAnswer(env, env->stdRxTimeout); +} + +AtCommandResult AtGsm_Gsnss_Simcom7600_SetModemWCDMAPowerMode(tAtCmd *env, const uint16_t *value) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT^BODYSARWCDMA="); + AtCmdTxAddDecimalIntWithLimit(env, *value, 2); + AtCmdTxSendLn(env); + return AtCmdOkErrAnswer(env, env->stdRxTimeout); +} + +AtCommandResult AtGsm_Gsnss_Simcom7600_SetModemLTEPowerMode(tAtCmd *env, const uint16_t *value) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT^BODYSARLTE="); + AtCmdTxAddDecimalIntWithLimit(env, *value, 2); + AtCmdTxSendLn(env); + return AtCmdOkErrAnswer(env, env->stdRxTimeout); +} + +AtCommandResult AtGsm_Gsnss_Simcom7600_ManualPowerMode(tAtCmd *env, const bool *mode) { + AtCmdTxClear(env); + if(*mode){ + AtCmdSendStatic(env, "AT^BODYSARON=1\r\n"); + return AtCmdOkErrAnswer(env, 2000 * env->stdRxTimeout); + } else { + return AT_OK; +// AtCmdSendStatic(env, "AT^BODYSARON=0\r\n"); +// return AtCmdOkErrAnswer(env, 2000 * env->stdRxTimeout); + } +} + + +AtCommandResult AtGsm_Gsnss_Simcom7600_EchoMode(tAtCmd *env, bool mode) { + AtCmdPrepare(env); + AtCmdTxClear(env); + if(mode){ + AtCmdSendStatic(env, "ATE1\r\n"); + } else{ + AtCmdSendStatic(env, "ATE0\r\n"); + } + + return AtCmdOkErrAnswer(env, 2000 * env->stdRxTimeout); +} + +AtCommandResult AtGsm_Gsnss_Simcom7600_DeleteGpsInfo(tAtCmd *env) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT+CGPSDEL\r\n"); + return AtCmdOkErrAnswer(env, 2000 * env->stdRxTimeout); +} + +AtCommandResult AtGsm_Gsnss_Simcom7600_SetConfigureAudioProfile(tAtCmd *env, tString32 *profileData) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CACDBFN="); + AtCmdTxAdd(env, profileData->data, profileData->length); + AtCmdTxAddStatic(env, "\r\n"); + AtCmdTxSendLn(env); + + return AtCmdOkErrAnswer(env, env->stdRxTimeout); +} + +AtCommandResult AtGsm_Gsnss_Simcom7600_SetConfigureStaticRMCThread(tAtCmd *env) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT+CGPSINFOCFG=1,3\r\n"); + return AtCmdOkErrAnswer(env, 2000 * env->stdRxTimeout); +} + +AtCommandResult AtGsm_Gsnss_Simcom7600_OpenADB(tAtCmd *env) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT+CUSBADB=1\r\n"); + return AtCmdOkErrAnswer(env, 2000 * env->stdRxTimeout); +} + +/* +AtCommandResult AtGsm_Gsnss_Simcom7600_StartReceiver(tAtCmd *env, bool value) { + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CGPS="); + AtCmdTxAddChar(env, value ? '1' : '0'); + AtCmdTxSendLn(env); + + return AtCmdOkErrAnswer(env, 5 * env->stdRxTimeout); +} +*/ + +AtCommandResult AtGsm_Gsnss_Simcom7600_StartReceiver(tAtCmd *env, bool value) { + AtCmdPrepare(env); + AtCmdRxClear(env); + AtCmdTxAddStatic(env, "AT+CGPS="); + AtCmdTxAddChar(env, value ? '1' : '0'); + AtCmdTxSendLn(env); + + uint32_t timeout = 5000; + 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); + + if (value) { + return AT_OK; + } + + continue; + + } else if (AtCmdRxBeginWithStatic(env, "ERROR")) { + AtCmdRxClear(env); + return AT_ERROR; + + } else if (AtCmdRxBeginWithStatic(env, "+CGPS: ")) { + AtCmdRxClear(env); + return AT_OK; + } else { + AtCmdProcessUnresolvedLine(env); + AtCmdRxClear(env); + continue; + } + } + + return AT_TIMEOUT; +} + + +AtCommandResult AtGsm_Gsnss_Simcom7600_HotStartReceiver(tAtCmd *env) { + AtCmdPrepare(env); + AtCmdRxClear(env); + AtCmdSendStatic(env, "AT+CGPSHOT\r\n"); + + return AtCmdOkErrAnswer(env, 5 * env->stdRxTimeout); +} + +AtCommandResult AtGsm_Gsnss_Simcom7600_SetExternalLnaSupport(tAtCmd *env, eSimcomSim7600_ExternalLnaSupportMode value) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT$GPSELNA="); + AtCmdTxAddChar(env, value); + AtCmdTxSendLn(env); + + return AtCmdOkErrAnswer(env, 2 * env->stdRxTimeout); +} + +AtCommandResult AtGsm_Gsnss_Simcom7600_GetCGSN(tAtCmd *env, char *acpString, size_t *acpStringLen) { + AtCmdPrepare(env); + AtCmdRxClear(env); + AtCmdSendStatic(env, "AT+CGSN\r\n"); + + AtCommandResult res = AtCmdReceiveNextLine(env, 15000); + + if(res == AT_OK){ + if (!AtCmdRxBeginWithStatic(env, "$GPRMC")) { + while (AtCmdReceiveNextLine(env, 4000) == AT_OK) { + if(env->rxBuffer.len == 17) { + *acpStringLen = env->rxBuffer.len; + memcpy(acpString, env->rxBuffer.data, *acpStringLen); + return AT_OK; + } + } + } + if (AtCmdRxBeginWithStatic(env, "ERROR")) { + return AT_ERROR; + } + } + + return AT_TIMEOUT; +} + +static uint8_t findDelimiter(tAtBuffer *address, char ch) { + + for (size_t i = 0; i < address->len; ++i) { + if (address->data[i] == ch) + return i; + } + + return 0; +} + +AtCommandResult AtGsm_Gsnss_Simcom7600_GetAudioFilesValidation(tAtCmd *env) { + AtCmdPrepare(env); + AtCmdRxClear(env); + AtCmdSendStatic(env, "AT+FSCD=E:/\r\n"); + + uint8_t fileCount = 0; + bool fl_findetFile = false; + while ( (AtCmdReceiveNextLine(env, 500) == AT_OK) ) { + if(AtCmdRxBeginWithStatic(env, "+FSCD: E:/") == AT_OK){ + AtCmdPrepare(env); + AtCmdRxClear(env); + AtCmdSendStatic(env, "AT+FSLS\r\n"); + while ((AtCmdReceiveNextLine(env, 200) == AT_OK)) { + if(env->rxBuffer.len < 6){ + continue; + } + uint8_t index = findDelimiter(&env->rxBuffer, '.'); + if( + (env->rxBuffer.data[index + 0] == '.' ) && + (env->rxBuffer.data[index + 1] == 'm' ) && + (env->rxBuffer.data[index + 2] == 'p' ) && + (env->rxBuffer.data[index + 3] == '3' ) + ){ + fileCount ++; + } + #if (AURUS_CAR_UI == 1) + if(fileCount == 61){ + return AT_OK; + } else { + continue; + } + #endif + #if (AURUS_CAR_UI == 0) + if(fileCount == 49){ + return AT_OK; + } else { + continue; + } + #endif + + } + return AT_ERROR; + } else { + continue; + } + } + return AT_TIMEOUT; +} + +AtCommandResult AtGsm_Gsnss_Simcom7600_GetSoftRevInModem(tAtCmd *env, char *cgmrStr, size_t *cgmrStrLen) { + AtCmdPrepare(env); + AtCmdRxClear(env); + AtCmdSendStatic(env, "AT+CGMR\r\n"); + + uint32_t leftMs; + uint32_t endMs = SystemGetMs() + 5000; + + while (endMs > SystemGetMs()) { + leftMs = endMs - SystemGetMs(); + if ((AtCmdReceiveNextLine(env, leftMs) == AT_OK) && (SystemGetMs() < endMs)) { + if (AtCmdRxBeginWithStatic(env, "+CGMR: ")) { + static const uint16_t prefixSize = sizeof("+CGMR: ") - 1; + *cgmrStrLen = env->rxBuffer.len - (prefixSize + 2); + memcpy(cgmrStr, env->rxBuffer.data+ prefixSize, *cgmrStrLen); + return AT_OK; + } + } + if (AtCmdRxBeginWithStatic(env, "ERROR")){ + return AT_ERROR; + } + AtCmdProcessUnresolvedLine(env); + } + + return AT_TIMEOUT; +} +AtCommandResult AtGsm_Gsnss_Simcom7600_SetWorkingState(tAtCmd *env, eSimcomSim7600_FuncMode funcMode) { + AtCmdPrepare(env); + AtCmdTxClear(env); + + if(funcMode == SIMCOM_FUNC_MAXIMAL) { + AtCmdSendStatic(env, "AT+CFUN=1\r\n"); + SystemDelayMs(1000); + uint32_t endMs = SystemGetMs() + 10000; + while (endMs > SystemGetMs()) { + if (AtCmdReceiveNextLine(env, 1000) == AT_OK) { + if (AtCmdRxBeginWithStatic(env, "PB DONE")) { + SystemDelayMs(100); + return AT_OK; + } + if (AtCmdRxBeginWithStatic(env, "OK")) { + SystemDelayMs(100); + return AT_OK; + } + + if (AtCmdRxBeginWithStatic(env, "ERROR")) { + return AT_ERROR; + } + if (AtCmdRxBeginWithStatic(env, "+CME ERROR: SIM busy")) { + AtCmdRxClear(env); + return AT_ERROR; + } + + AtCmdProcessUnresolvedLine(env); + } + } + return AT_ERROR; + } + + if(funcMode == SIMCOM_FUNC_MINIMAL) { + AtCmdSendStatic(env, "AT+CFUN=0\r\n"); + uint32_t endMs = SystemGetMs() + 8000; + + while (endMs > SystemGetMs()) { + if (AtCmdRxBeginWithStatic(env, "ERROR")) { + return AT_ERROR; + } + if (AtCmdReceiveNextLine(env, 4000) == AT_OK) { + if (AtCmdRxBeginWithStatic(env, "+SIMCARD: NOT AVAILABLE")) { + while (endMs > SystemGetMs()) { + if (AtCmdReceiveNextLine(env, 4000) == AT_OK) { + if (AtCmdRxBeginWithStatic(env, "OK")) { + SystemDelayMs(500); + AtCmdRxClear(env); + return AT_OK; + } + } + } + } + if (AtCmdRxBeginWithStatic(env, "OK")) { + SystemDelayMs(500); + AtCmdRxClear(env); + return AT_OK; + } + + SystemDelayMs(10); + } + } + + return AT_ERROR; + } + return AT_ERROR; +} + +AtCommandResult AtGsm_Gsnss_Simcom7600_GnssStopThread(tAtCmd *env) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT+CGPSINFOCFG=0,0\r\n"); + return AtCmdOkErrAnswer(env, 2 * env->stdRxTimeout); +} + +AtCommandResult AtGsm_Gsnss_Simcom7600_GetCCID(tAtCmd *env, char *ssidStr, size_t *ssidStrLen) { + AtCmdPrepare(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT+CICCID\r\n"); + + uint32_t endMs = SystemGetMs() + 5000; + while (endMs > SystemGetMs()) { + if (AtCmdReceiveNextLine(env, 1000) == AT_OK) { + if (AtCmdRxBeginWithStatic(env, "+ICCID: ")) { + static const uint16_t prefixSize = sizeof("+ICCID: ") - 1; + *ssidStrLen = env->rxBuffer.len - (prefixSize + 2); + memcpy(ssidStr, env->rxBuffer.data + prefixSize, *ssidStrLen); + return AT_OK; + } + + if (AtCmdRxBeginWithStatic(env, "ERROR")) { + return AT_ERROR; + } + if (AtCmdRxBeginWithStatic(env, "+CME ERROR: SIM busy")) { + AtCmdPrepare(env); + AtCmdRxClear(env); + continue; + } + + AtCmdProcessUnresolvedLine(env); + } + } + + return AT_TIMEOUT; +} + diff --git a/Src/GsmSimComAudioCodec.c b/Src/GsmSimComAudioCodec.c new file mode 100644 index 0000000..21ab9a5 --- /dev/null +++ b/Src/GsmSimComAudioCodec.c @@ -0,0 +1,76 @@ +// +// Created by ilya on 27.03.24. +// +#include "GsmSimComAudioCodec.h" +#include "SystemDelayInterface.h" + +AtCommandResult AtGsmSimCom_NAU_Codec_Full10w(tAtCmd *env) { + do { + SystemDelayMs(500); + AtCmdRxClear(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT+CWIIC=0x34, 0x0, 0x1, 1\r\n"); + } while (AtCmdOkErrAnswer(env, 1000) != AT_OK); + do { + SystemDelayMs(500); + AtCmdRxClear(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT+CWIIC=0x34, 0x02, 0x19, 1\r\n"); + } while (AtCmdOkErrAnswer(env, 1000) != AT_OK); + do { + SystemDelayMs(500); + AtCmdRxClear(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT+CWIIC=0x34, 0x04, 0x15, 1\r\n"); + } while (AtCmdOkErrAnswer(env, 1000) != AT_OK); + do { + SystemDelayMs(500); + AtCmdRxClear(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT+CWIIC=0x34, 0x06, 0x65, 1\r\n"); + } while (AtCmdOkErrAnswer(env, 1000) != AT_OK); + do { + SystemDelayMs(500); + AtCmdRxClear(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT+CWIIC=0x34, 0x09, 0x18, 1\r\n"); + } while (AtCmdOkErrAnswer(env, 1000) != AT_OK); + do { + SystemDelayMs(500); + AtCmdRxClear(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT+CWIIC=0x34, 0x0A, 0x00, 1\r\n"); + } while (AtCmdOkErrAnswer(env, 1000) != AT_OK); + do { + SystemDelayMs(500); + AtCmdRxClear(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT+CWIIC=0x34, 0x0C, 0x00, 1\r\n"); + } while (AtCmdOkErrAnswer(env, 1000) != AT_OK); + do { + SystemDelayMs(500); + AtCmdRxClear(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT+CWIIC=0x34, 0x0E, 0x0A, 1\r\n"); + } while (AtCmdOkErrAnswer(env, 1000) != AT_OK); + do { + SystemDelayMs(500); + AtCmdRxClear(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT+CWIIC=0x34, 0x5A, 0x0A, 1\r\n"); + } while (AtCmdOkErrAnswer(env, 1000) != AT_OK); + do { + SystemDelayMs(500); + AtCmdRxClear(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT+CWIIC=0x34, 0x5E, 0x00, 1\r\n"); + } while (AtCmdOkErrAnswer(env, 1000) != AT_OK); + do { + SystemDelayMs(500); + AtCmdRxClear(env); + AtCmdTxClear(env); + AtCmdSendStatic(env, "AT+CWIIC=0x34, 0x6C, 0x36, 1\r\n"); + } while (AtCmdOkErrAnswer(env, 1000) != AT_OK); + + return AT_OK; +} \ No newline at end of file diff --git a/modular.json b/modular.json new file mode 100644 index 0000000..087033d --- /dev/null +++ b/modular.json @@ -0,0 +1,22 @@ +{ + "dep": [ + { + "type": "git", + "provider": "Smart_Components_Aurus", + "repo": "AsciiStringAssemblingUtils" + }, + { + "type": "git", + "provider": "Smart_Components_Aurus", + "repo": "AtGsmCommon" + } + ], + "cmake": { + "inc_dirs": [ + "Inc" + ], + "srcs": [ + "Src/**.c" + ] + } +} \ No newline at end of file