From af614e89ab1f11fe348afe74af603d8485c9f3ba Mon Sep 17 00:00:00 2001 From: cfif Date: Wed, 4 Dec 2024 13:10:50 +0300 Subject: [PATCH] Init --- Inc/AtGsmSms.h | 17 +++++++++ Inc/AtGsmSms_DeleteAll.h | 12 ++++++ Inc/AtGsmSms_DeleteById.h | 12 ++++++ Inc/AtGsmSms_ReedOneNewPdu.h | 17 +++++++++ Inc/AtGsmSms_SendById.h | 12 ++++++ Inc/AtGsmSms_SendText.h | 12 ++++++ Inc/AtGsmSms_SetMode.h | 17 +++++++++ Inc/AtGsmSms_SetServiceCenter.h | 14 +++++++ Inc/AtGsmSms_WriteNewPduSms.h | 12 ++++++ Src/AtGsmSms_DeleteAll.c | 12 ++++++ Src/AtGsmSms_DeleteById.c | 20 ++++++++++ Src/AtGsmSms_ReedOneNewPdu.c | 67 +++++++++++++++++++++++++++++++++ Src/AtGsmSms_SendById.c | 18 +++++++++ Src/AtGsmSms_SendText.c | 28 ++++++++++++++ Src/AtGsmSms_SetMode.c | 17 +++++++++ Src/AtGsmSms_SetServiceCenter.c | 18 +++++++++ Src/AtGsmSms_WriteNewPduSms.c | 28 ++++++++++++++ modular.json | 22 +++++++++++ 18 files changed, 355 insertions(+) create mode 100644 Inc/AtGsmSms.h create mode 100644 Inc/AtGsmSms_DeleteAll.h create mode 100644 Inc/AtGsmSms_DeleteById.h create mode 100644 Inc/AtGsmSms_ReedOneNewPdu.h create mode 100644 Inc/AtGsmSms_SendById.h create mode 100644 Inc/AtGsmSms_SendText.h create mode 100644 Inc/AtGsmSms_SetMode.h create mode 100644 Inc/AtGsmSms_SetServiceCenter.h create mode 100644 Inc/AtGsmSms_WriteNewPduSms.h create mode 100644 Src/AtGsmSms_DeleteAll.c create mode 100644 Src/AtGsmSms_DeleteById.c create mode 100644 Src/AtGsmSms_ReedOneNewPdu.c create mode 100644 Src/AtGsmSms_SendById.c create mode 100644 Src/AtGsmSms_SendText.c create mode 100644 Src/AtGsmSms_SetMode.c create mode 100644 Src/AtGsmSms_SetServiceCenter.c create mode 100644 Src/AtGsmSms_WriteNewPduSms.c create mode 100644 modular.json diff --git a/Inc/AtGsmSms.h b/Inc/AtGsmSms.h new file mode 100644 index 0000000..c642228 --- /dev/null +++ b/Inc/AtGsmSms.h @@ -0,0 +1,17 @@ +// +// Created by xemon on 28.11.22. +// + +#ifndef UVEOS_ON_NATION_ATGSMSMS_H +#define UVEOS_ON_NATION_ATGSMSMS_H + +#include "AtGsmSms_DeleteAll.h" +#include "AtGsmSms_DeleteById.h" +#include "AtGsmSms_SendById.h" +#include "AtGsmSms_SendText.h" +#include "AtGsmSms_SetMode.h" +#include "AtGsmSms_SetServiceCenter.h" +#include "AtGsmSms_WriteNewPduSms.h" +#include "AtGsmSms_ReedOneNewPdu.h" + +#endif //UVEOS_ON_NATION_ATGSMSMS_H diff --git a/Inc/AtGsmSms_DeleteAll.h b/Inc/AtGsmSms_DeleteAll.h new file mode 100644 index 0000000..833a2ed --- /dev/null +++ b/Inc/AtGsmSms_DeleteAll.h @@ -0,0 +1,12 @@ +// +// Created by xemon on 28.11.22. +// + +#ifndef UVEOS_ON_NATION_ATGSMSMS_DELETEALL_H +#define UVEOS_ON_NATION_ATGSMSMS_DELETEALL_H + +#include + +AtCommandResult AtGsmSms_DeleteAll(tAtCmd *env); + +#endif //UVEOS_ON_NATION_ATGSMSMS_DELETEALL_H diff --git a/Inc/AtGsmSms_DeleteById.h b/Inc/AtGsmSms_DeleteById.h new file mode 100644 index 0000000..c8952a5 --- /dev/null +++ b/Inc/AtGsmSms_DeleteById.h @@ -0,0 +1,12 @@ +// +// Created by xemon on 25.11.22. +// + +#ifndef UVEOS_ON_NATION_ATGSMSMS_DELETE_BY_ID_H +#define UVEOS_ON_NATION_ATGSMSMS_DELETE_BY_ID_H + +#include + +AtCommandResult AtGsmSms_DeleteById(tAtCmd *env, uint8_t id); + +#endif //UVEOS_ON_NATION_ATGSMSMS_DELETE_BY_ID_H diff --git a/Inc/AtGsmSms_ReedOneNewPdu.h b/Inc/AtGsmSms_ReedOneNewPdu.h new file mode 100644 index 0000000..07e939b --- /dev/null +++ b/Inc/AtGsmSms_ReedOneNewPdu.h @@ -0,0 +1,17 @@ +// +// Created by zemon on 27.12.22. +// + +#ifndef UVEOS_ON_NATION_ATGSMSMS_REEDONENEWPDU_H +#define UVEOS_ON_NATION_ATGSMSMS_REEDONENEWPDU_H + +#include + +AtCommandResult AtGsmSms_ReedOneNewPdu( + tAtCmd *env, + char *pduHex, + uint8_t *pduHexSize, + uint8_t pduHexLimit +); + +#endif //UVEOS_ON_NATION_ATGSMSMS_REEDONENEWPDU_H diff --git a/Inc/AtGsmSms_SendById.h b/Inc/AtGsmSms_SendById.h new file mode 100644 index 0000000..6ab342d --- /dev/null +++ b/Inc/AtGsmSms_SendById.h @@ -0,0 +1,12 @@ +// +// Created by xemon on 28.11.22. +// + +#ifndef UVEOS_ON_NATION_ATGSMSMS_SENDBYID_H +#define UVEOS_ON_NATION_ATGSMSMS_SENDBYID_H + +#include + +AtCommandResult AtGsmSms_SendById(tAtCmd *env, uint8_t id); + +#endif //UVEOS_ON_NATION_ATGSMSMS_SENDBYID_H diff --git a/Inc/AtGsmSms_SendText.h b/Inc/AtGsmSms_SendText.h new file mode 100644 index 0000000..9cf2344 --- /dev/null +++ b/Inc/AtGsmSms_SendText.h @@ -0,0 +1,12 @@ +// +// Created by xemon on 28.11.22. +// + +#ifndef UVEOS_ON_NATION_ATGSMSMS_SENDTEXT_H +#define UVEOS_ON_NATION_ATGSMSMS_SENDTEXT_H + +#include + +AtCommandResult AtGsmSms_SendText(tAtCmd *env, char *number, uint8_t numberLen, char *text, uint8_t textLen); + +#endif //UVEOS_ON_NATION_ATGSMSMS_SENDTEXT_H diff --git a/Inc/AtGsmSms_SetMode.h b/Inc/AtGsmSms_SetMode.h new file mode 100644 index 0000000..0872ccc --- /dev/null +++ b/Inc/AtGsmSms_SetMode.h @@ -0,0 +1,17 @@ +// +// Created by xemon on 25.11.22. +// + +#ifndef UVEOS_ON_NATION_ATGSMSMS_SETMODE_H +#define UVEOS_ON_NATION_ATGSMSMS_SETMODE_H + +#include + +typedef enum { + AT_GSM_SMS_MODE_TEXT = 1, + AT_GSM_SMS_MODE_PDU = 0, +} tAtGsmSmsMode; + +AtCommandResult AtGsmSms_SetMode(tAtCmd *env, tAtGsmSmsMode mode); + +#endif //UVEOS_ON_NATION_ATGSMSMS_SETMODE_H diff --git a/Inc/AtGsmSms_SetServiceCenter.h b/Inc/AtGsmSms_SetServiceCenter.h new file mode 100644 index 0000000..5d833aa --- /dev/null +++ b/Inc/AtGsmSms_SetServiceCenter.h @@ -0,0 +1,14 @@ +// +// Created by xemon on 25.11.22. +// + +#ifndef UVEOS_ON_NATION_ATGSMSMS_SETSERVICECENTER_H +#define UVEOS_ON_NATION_ATGSMSMS_SETSERVICECENTER_H + +#include + +AtCommandResult AtGsmSms_SetServiceCenter(tAtCmd *env, char *smsCenterNumber, uint8_t smsCenterNumberLen); + +#define AtGsmSms_SetServiceCenterStatic(ENV, NUMBER) AtGsmSms_SetServiceCenter(ENV,NUMBER,sizeof(NUMBER)-1) + +#endif //UVEOS_ON_NATION_ATGSMSMS_SETSERVICECENTER_H diff --git a/Inc/AtGsmSms_WriteNewPduSms.h b/Inc/AtGsmSms_WriteNewPduSms.h new file mode 100644 index 0000000..2a2ff78 --- /dev/null +++ b/Inc/AtGsmSms_WriteNewPduSms.h @@ -0,0 +1,12 @@ +// +// Created by xemon on 28.11.22. +// + +#ifndef UVEOS_ON_NATION_ATGSMSMS_WRITENEWPDUSMS_H +#define UVEOS_ON_NATION_ATGSMSMS_WRITENEWPDUSMS_H + +#include + +AtCommandResult AtGsmSms_WriteNewPduSms(tAtCmd *env, char *pduBody, uint8_t fullLen, uint8_t pduDataLen); + +#endif //UVEOS_ON_NATION_ATGSMSMS_WRITENEWPDUSMS_H diff --git a/Src/AtGsmSms_DeleteAll.c b/Src/AtGsmSms_DeleteAll.c new file mode 100644 index 0000000..b97f3b2 --- /dev/null +++ b/Src/AtGsmSms_DeleteAll.c @@ -0,0 +1,12 @@ +// +// Created by xemon on 28.11.22. +// + +#include "AtGsmSms_DeleteAll.h" +#include "AtCmdCommonProtected.h" +// удалить все смс +AtCommandResult AtGsmSms_DeleteAll(tAtCmd *env) { + AtCmdPrepare(env); + AtCmdSendStatic(env, "AT+CMGD=1,4\r\n"); + return AtCmdOkErrAnswer(env, 10 * env->stdRxTimeout); +} diff --git a/Src/AtGsmSms_DeleteById.c b/Src/AtGsmSms_DeleteById.c new file mode 100644 index 0000000..f5bf684 --- /dev/null +++ b/Src/AtGsmSms_DeleteById.c @@ -0,0 +1,20 @@ +// +// Created by xemon on 25.11.22. +// + +#include "AtGsmSms_DeleteById.h" +#include "AtCmdCommonProtected.h" + +AtCommandResult AtGsmSms_DeleteById(tAtCmd *env, uint8_t id) { + AtCmdPrepare(env); + + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CMGD="); + AtCmdTxAddDecimalIntWithLimit(env, id, 3); + + AtCmdTxSendLn(env); + + return AtCmdOkErrAnswer(env, env->stdRxTimeout); +} + + diff --git a/Src/AtGsmSms_ReedOneNewPdu.c b/Src/AtGsmSms_ReedOneNewPdu.c new file mode 100644 index 0000000..57e09c2 --- /dev/null +++ b/Src/AtGsmSms_ReedOneNewPdu.c @@ -0,0 +1,67 @@ +// +// Created by zemon on 27.12.22. +// +#include +#include "AtCmdCommonProtected.h" +#include "SystemDelayInterface.h" +#include "LoggerInterface.h" + + +AtCommandResult AtGsmSms_ReedOneNewPdu( + tAtCmd *env, + char *pduHex, + uint8_t *pduHexSize, + uint8_t pduHexLimit +) { +// /// запрос на переотправку МНД +// char hexData[] = "04814523F1040A8180515634120004329052815002402B0100000B001E000600014A1700060040040433140050060000000000000000000000130100000000028155"; +// char hexData[] = "04814523F1040A8180515634120004326090419405402B0100000B001E00010001A91700010040040433140050010000000000000000000000130100000000027290"; +// char hexData[] = "0100010B003300010001EA2800010094E07404110A0A282500010222140601430145554B3C25C00000810037F08B8835FC1179A7A7B0FE0F1C1FE000001AA3D2"; +// char hexData[] = "04804523F1040A8080515634120004324041318175402A0100000B001D000A00017516000A00400404331300500A0000000000000000000002230235353535852C"; +// char hexData[] = "07919714180010F3040B919714111190F7000432302231033221350100000B0028000A00013D1D000A00010A0000000404331A00500A000000A9010000000100420D0237393431383130303032357D82"; +// char hexData[] = "07919714180010F3040B919714111190F70004323022310332213501A001C00012F13001C00400404331000501C0000000000000000000000120100A87010101010"; +// char hexData[] = "0100000B001E00040001C6170004004004043314005004000000000000000000000013010000000002B6B0"; +/// установка номера +// char hexData[] = "04804523F1040A8080515634120004324041318175402A0100000B001D000A00017516000A00400404331300500A0000000000000000000002230235353535852C"; +// uint16_t pos = 0; +// while ((pos < pduHexLimit) && (hexData[pos] != 0)) { +// pduHex[pos] = hexData[pos]; +// ++pos; +// } +// *pduHexSize = pos; +// return AT_OK; + + + +///============================================================================================================== + + + uint32_t endMs = SystemGetMs() + 2000; + AtCmdPrepare(env); + AtCmdSendStatic(env, "AT+CMGL\r\n"); + + *pduHexSize = 0; + while (endMs > SystemGetMs()) { + if (AtCmdReceiveNextLine(env, 500) == AT_OK) { + uint16_t pos = 0; + + if (AtCmdRxBeginWithStatic(env, "+CMGL:")) { + if (AtCmdReceiveNextLine(env, 1000) == AT_OK) { + while ((pos < pduHexLimit) && (env->rxBuffer.data[pos] != '\r')) { + pduHex[pos] = env->rxBuffer.data[pos]; + ++pos; + } + } + *pduHexSize = pos; + return AT_OK; + } + + if (AtCmdRxBeginWithStatic(env, "+CMS ERROR: ")) { + return AT_ERROR; + } + + AtCmdProcessUnresolvedLine(env); + } + } + return AT_TIMEOUT; +} diff --git a/Src/AtGsmSms_SendById.c b/Src/AtGsmSms_SendById.c new file mode 100644 index 0000000..edf99ac --- /dev/null +++ b/Src/AtGsmSms_SendById.c @@ -0,0 +1,18 @@ +// +// Created by xemon on 28.11.22. +// + +#include "AtGsmSms_SendById.h" +#include "AtCmdCommonProtected.h" + +AtCommandResult AtGsmSms_SendById(tAtCmd *env, uint8_t id) { + AtCmdPrepare(env); + + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CMSS="); + AtCmdTxAddDecimalIntWithLimit(env, id, 3); + + AtCmdTxSendLn(env); + + return AtCmdOkErrAnswer(env, env->stdRxTimeout * 6); +} diff --git a/Src/AtGsmSms_SendText.c b/Src/AtGsmSms_SendText.c new file mode 100644 index 0000000..3ecedfb --- /dev/null +++ b/Src/AtGsmSms_SendText.c @@ -0,0 +1,28 @@ +// +// Created by xemon on 28.11.22. +// + +#include "AtGsmSms_SendText.h" +#include "AtCmdCommonProtected.h" + +AtCommandResult AtGsmSms_SendText(tAtCmd *env, char *number, uint8_t numberLen, char *text, uint8_t textLen) { + AtCmdPrepare(env); + + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CMGS=\""); + AtCmdTxAdd(env, number, numberLen); + AtCmdTxAddStatic(env, "\""); + AtCmdTxSendLn(env); + + AtCommandResult ready = AtCmdWaitPrefix(env, 10000, ">", 1); + + if (ready != AT_OK) { + AtCmdSendStatic(env, AT_ESC_STR); + return ready; + } + + AtCmdSend(env, (uint8_t *) text, textLen); + AtCmdSendStatic(env, AT_ESC_STR); + + return AtCmdOkErrAnswer(env, env->stdRxTimeout * 5); +} diff --git a/Src/AtGsmSms_SetMode.c b/Src/AtGsmSms_SetMode.c new file mode 100644 index 0000000..0ec4aa5 --- /dev/null +++ b/Src/AtGsmSms_SetMode.c @@ -0,0 +1,17 @@ +// +// Created by xemon on 25.11.22. +// +#include "AtGsmSms_SetMode.h" +#include "AtCmdCommonProtected.h" + +AtCommandResult AtGsmSms_SetMode(tAtCmd *env, tAtGsmSmsMode mode) { + AtCmdPrepare(env); + + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CMGF="); + AtCmdTxAddDecimalInt(env, mode, 1); + + AtCmdTxSendLn(env); + + return AtCmdOkErrAnswer(env, env->stdRxTimeout); +} \ No newline at end of file diff --git a/Src/AtGsmSms_SetServiceCenter.c b/Src/AtGsmSms_SetServiceCenter.c new file mode 100644 index 0000000..0627124 --- /dev/null +++ b/Src/AtGsmSms_SetServiceCenter.c @@ -0,0 +1,18 @@ +// +// Created by xemon on 25.11.22. +// + +#include "AtGsmSms_SetServiceCenter.h" +#include "AtCmdCommonProtected.h" + +AtCommandResult AtGsmSms_SetServiceCenter(tAtCmd *env, char *smsCenterNumber, uint8_t smsCenterNumberLen) { + AtCmdPrepare(env); + AtCmdTxClear(env); + + AtCmdTxAddStatic(env, "AT+CSCA="); + AtCmdTxAdd(env, smsCenterNumber, smsCenterNumberLen); + + AtCmdTxSendLn(env); + + return AtCmdOkErrAnswer(env, env->stdRxTimeout); +} \ No newline at end of file diff --git a/Src/AtGsmSms_WriteNewPduSms.c b/Src/AtGsmSms_WriteNewPduSms.c new file mode 100644 index 0000000..887b751 --- /dev/null +++ b/Src/AtGsmSms_WriteNewPduSms.c @@ -0,0 +1,28 @@ +// +// Created by xemon on 28.11.22. +// + +#include "AtGsmSms_WriteNewPduSms.h" +#include "AtCmdCommonProtected.h" + +AtCommandResult AtGsmSms_WriteNewPduSms(tAtCmd *env, char *pduBody, uint8_t fullLen, uint8_t pduDataLen) { + + AtCmdPrepare(env); + + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CMGW="); + AtCmdTxAddDecimalIntWithLimit(env, pduDataLen, 3); + AtCmdTxSendLn(env); + + AtCommandResult ready = AtCmdWaitChar(env, 10000, '>'); + + if (ready != AT_OK) { + AtCmdSendStatic(env, AT_ESC_STR); + return ready; + } + + AtCmdSend(env, (uint8_t *) pduBody, fullLen); + AtCmdSendStatic(env, AT_ESC_STR); + + return AtCmdOkErrAnswer(env, env->stdRxTimeout * 5); +} \ No newline at end of file diff --git a/modular.json b/modular.json new file mode 100644 index 0000000..aceb6a3 --- /dev/null +++ b/modular.json @@ -0,0 +1,22 @@ +{ + "dep": [ + { + "type": "git", + "provider": "NAVIGATOR_UVEOS_NATION_TELIT", + "repo": "AtGsmCommon" + }, + { + "type": "git", + "provider": "NAVIGATOR_UVEOS_NATION_TELIT", + "repo": "SmsEncoderDecoder" + } + ], + "cmake": { + "inc_dirs": [ + "Inc" + ], + "srcs": [ + "Src/**.c" + ] + } +} \ No newline at end of file