45 lines
1.3 KiB
C
45 lines
1.3 KiB
C
//
|
|
// Created by xemon on 17.11.22.
|
|
//
|
|
|
|
#include <memory.h>
|
|
#include "AudioPlayerTelitLe910.h"
|
|
#include "SystemDelayInterface.h"
|
|
|
|
static bool AudioPlayerTelitLe910_Start(tAtCmd *telitAt, char *name, uint16_t nameLen, uint32_t timeout) {
|
|
char fileName[nameLen + 4];
|
|
|
|
memcpy(fileName, name, nameLen);
|
|
stpncpy(fileName + nameLen, ".pcm", 4);
|
|
|
|
if(AtGsmTelitLe910_PlayAudioFileTo(telitAt, TELIT_AUDIO_FILE_PLAY_TO_SPEAKER, fileName, nameLen + 4) == AT_OK){
|
|
return AtCmdWaitOk(telitAt, 10, 10);
|
|
}
|
|
}
|
|
|
|
static bool AudioPlayerTelitLe910_Stop(tAtCmd *telitAt, uint32_t timeout) {
|
|
return AtGsmTelitLe910_PlayAudioStop(telitAt) == AT_OK;
|
|
}
|
|
|
|
static bool AudioPlayerTelitLe910_Wait(tAtCmd *atCmd, uint32_t timeout) {
|
|
AtCommandResult result= AtGsmTelitLe910_PlayAudioWaitEnd(atCmd, timeout);
|
|
if(result == AT_OK){
|
|
return result;
|
|
} else {
|
|
AudioPlayerTelitLe910_Stop(atCmd, timeout);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
tAudioPlayerInterface AudioPlayerTelitLe910_GetInterface(tAtCmd *telitAt) {
|
|
tAudioPlayerInterface result = {
|
|
.env = telitAt,
|
|
.start = (audioPlayerCallStart) AudioPlayerTelitLe910_Start,
|
|
.stop = (audioPlayerCall) AudioPlayerTelitLe910_Stop,
|
|
.wait = (audioPlayerCall) AudioPlayerTelitLe910_Wait,
|
|
};
|
|
|
|
return result;
|
|
}
|
|
|