This commit is contained in:
cfif 2024-12-04 13:10:50 +03:00
commit af614e89ab
18 changed files with 355 additions and 0 deletions

17
Inc/AtGsmSms.h Normal file
View File

@ -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

12
Inc/AtGsmSms_DeleteAll.h Normal file
View File

@ -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 <AtCmdBase.h>
AtCommandResult AtGsmSms_DeleteAll(tAtCmd *env);
#endif //UVEOS_ON_NATION_ATGSMSMS_DELETEALL_H

12
Inc/AtGsmSms_DeleteById.h Normal file
View File

@ -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 <AtCmdBase.h>
AtCommandResult AtGsmSms_DeleteById(tAtCmd *env, uint8_t id);
#endif //UVEOS_ON_NATION_ATGSMSMS_DELETE_BY_ID_H

View File

@ -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 <AtCmdBase.h>
AtCommandResult AtGsmSms_ReedOneNewPdu(
tAtCmd *env,
char *pduHex,
uint8_t *pduHexSize,
uint8_t pduHexLimit
);
#endif //UVEOS_ON_NATION_ATGSMSMS_REEDONENEWPDU_H

12
Inc/AtGsmSms_SendById.h Normal file
View File

@ -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 <AtCmdBase.h>
AtCommandResult AtGsmSms_SendById(tAtCmd *env, uint8_t id);
#endif //UVEOS_ON_NATION_ATGSMSMS_SENDBYID_H

12
Inc/AtGsmSms_SendText.h Normal file
View File

@ -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 <AtCmdBase.h>
AtCommandResult AtGsmSms_SendText(tAtCmd *env, char *number, uint8_t numberLen, char *text, uint8_t textLen);
#endif //UVEOS_ON_NATION_ATGSMSMS_SENDTEXT_H

17
Inc/AtGsmSms_SetMode.h Normal file
View File

@ -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 <AtCmdBase.h>
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

View File

@ -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 <AtCmdBase.h>
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

View File

@ -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 <AtCmdBase.h>
AtCommandResult AtGsmSms_WriteNewPduSms(tAtCmd *env, char *pduBody, uint8_t fullLen, uint8_t pduDataLen);
#endif //UVEOS_ON_NATION_ATGSMSMS_WRITENEWPDUSMS_H

12
Src/AtGsmSms_DeleteAll.c Normal file
View File

@ -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);
}

20
Src/AtGsmSms_DeleteById.c Normal file
View File

@ -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);
}

View File

@ -0,0 +1,67 @@
//
// Created by zemon on 27.12.22.
//
#include <AtGsmSms_DeleteAll.h>
#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;
}

18
Src/AtGsmSms_SendById.c Normal file
View File

@ -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);
}

28
Src/AtGsmSms_SendText.c Normal file
View File

@ -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);
}

17
Src/AtGsmSms_SetMode.c Normal file
View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

22
modular.json Normal file
View File

@ -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"
]
}
}