From 470d1db0978bdf469696154cc51b4c6edef743ff Mon Sep 17 00:00:00 2001 From: cfif Date: Wed, 4 Dec 2024 13:10:48 +0300 Subject: [PATCH] Init --- Inc/AudioRecorderTelitLe910.h | 15 +++++++ Src/AudioRecorderTelitLe910.c | 73 +++++++++++++++++++++++++++++++++++ modular.json | 12 ++++++ 3 files changed, 100 insertions(+) create mode 100644 Inc/AudioRecorderTelitLe910.h create mode 100644 Src/AudioRecorderTelitLe910.c create mode 100644 modular.json diff --git a/Inc/AudioRecorderTelitLe910.h b/Inc/AudioRecorderTelitLe910.h new file mode 100644 index 0000000..6a144b2 --- /dev/null +++ b/Inc/AudioRecorderTelitLe910.h @@ -0,0 +1,15 @@ +// +// Created by zemon on 29.11.22. +// + +#ifndef UVEOS_ON_NATION_AUDIORECORDERTELITLE910_H +#define UVEOS_ON_NATION_AUDIORECORDERTELITLE910_H + +#include "stdlib.h" +#include "stdbool.h" +#include "AudioRecorderInterface.h" +#include "AtGsmTelitLe910.h" + +tAudioRecorderInterface AudioRecordTelitLe910_GetInterface(tAtCmd *telitAt); + +#endif //UVEOS_ON_NATION_AUDIORECORDERTELITLE910_H diff --git a/Src/AudioRecorderTelitLe910.c b/Src/AudioRecorderTelitLe910.c new file mode 100644 index 0000000..73d4521 --- /dev/null +++ b/Src/AudioRecorderTelitLe910.c @@ -0,0 +1,73 @@ +// +// Created by zemon on 29.11.22. +// + +#include +#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; +} diff --git a/modular.json b/modular.json new file mode 100644 index 0000000..d4d574e --- /dev/null +++ b/modular.json @@ -0,0 +1,12 @@ +{ + "dep": [ + ], + "cmake": { + "inc_dirs": [ + "Inc" + ], + "srcs": [ + "Src/**.c" + ] + } +} \ No newline at end of file