270 lines
7.9 KiB
C
270 lines
7.9 KiB
C
//
|
|
// Created by xemon on 14.11.22.
|
|
//
|
|
#include "AtGsmSim7600e_AudioFileAndStream.h"
|
|
#include <AtCmdCommonProtected.h>
|
|
#include <SystemDelayInterface.h>
|
|
|
|
|
|
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");
|
|
} |