74 lines
2.1 KiB
C
74 lines
2.1 KiB
C
//
|
|
// Created by zemon on 29.11.22.
|
|
//
|
|
|
|
#include <memory.h>
|
|
#include "AudioRecorderTelitLe910.h"
|
|
#include "SystemDelayInterface.h"
|
|
|
|
|
|
static bool AudioRecordTelitLe910_Start(tAtCmd *telitAt, char *name, uint16_t nameLen) {
|
|
char fileName[nameLen + 4];
|
|
memcpy(fileName, name, nameLen);
|
|
stpncpy(fileName + nameLen, ".pcm", 4);
|
|
|
|
AtCommandResult result;
|
|
uint32_t end = SystemGetMs() + 5000;
|
|
while (end > SystemGetMs()){
|
|
result = AtGsmTelitLe910_RecorderAudioFileStart(telitAt, fileName, nameLen + 4);
|
|
if (result == AT_OK) {
|
|
return true;
|
|
}
|
|
SystemDelayMs(100);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
static bool AtGsmTelitLe910_RecordrerAudioFileDel(tAtCmd *telitAt, char *name, uint16_t nameLen) {
|
|
char fileName[nameLen + 4];
|
|
memcpy(fileName, name, nameLen);
|
|
stpncpy(fileName + nameLen, ".pcm", 4);
|
|
|
|
|
|
AtCommandResult result;
|
|
uint32_t end = SystemGetMs() + 5000;
|
|
while (end > SystemGetMs()){
|
|
result = AtGsmTelitLe910_DeleteAudioFile(telitAt, fileName, nameLen + 4);
|
|
if (result == AT_OK) {
|
|
return true;
|
|
}
|
|
SystemDelayMs(500);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
static bool AudioRecordTelitLe910_Stop(tAtCmd *telitAt) {
|
|
return AtGsmTelitLe910_RecorderAudioFileStop(telitAt) == AT_OK;
|
|
}
|
|
|
|
static bool AudioPlayerTelitLe910_WaitStop(tAtCmd *telitAt, uint32_t timeout) {
|
|
bool result= AtGsmTelitLe910_RecAudioWaitEnd(telitAt, timeout) == AT_OK;
|
|
if(result){
|
|
SystemDelayMs(timeout);
|
|
AudioRecordTelitLe910_Stop(telitAt);
|
|
SystemDelayMs(500);
|
|
return result;
|
|
} else {
|
|
AudioRecordTelitLe910_Stop(telitAt);
|
|
SystemDelayMs(500);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
tAudioRecorderInterface AudioRecordTelitLe910_GetInterface(tAtCmd *telitAt) {
|
|
tAudioRecorderInterface result = {
|
|
.env = telitAt,
|
|
.start = (audioRecordStart) AudioRecordTelitLe910_Start,
|
|
.stop = (audioRecordStop) AudioRecordTelitLe910_Stop,
|
|
.del = (audioRecordDel) AtGsmTelitLe910_RecordrerAudioFileDel,
|
|
.waitStop = (audioRecordWaitStop) AudioPlayerTelitLe910_WaitStop,
|
|
};
|
|
|
|
return result;
|
|
}
|