commit 0e268ca044204ffea8a6d9aa8545d97bf50f9a2e Author: cfif Date: Tue Mar 11 12:05:57 2025 +0300 Переход в новую организацию diff --git a/AtCommandsInc/AtGsmErrorLogLevel.h b/AtCommandsInc/AtGsmErrorLogLevel.h new file mode 100755 index 0000000..8410bad --- /dev/null +++ b/AtCommandsInc/AtGsmErrorLogLevel.h @@ -0,0 +1,18 @@ +// +// Created by xemon on 09.09.22. +// + +#ifndef GSMAT_GSMATERRORLOGLEVEL_H +#define GSMAT_GSMATERRORLOGLEVEL_H + +#include "AtCmdBase.h" + +typedef enum { + GSM_NO_LOG_ERROR = 0, + GSM_LOG_ERROR_CODES = 1, + GSM_LOG_ERROR_VERBOSE = 2, +} tGsmErrorLogLevel; + +AtCommandResult AtGsmSetErrorLogLevel(tAtCmd *env, tGsmErrorLogLevel value); + +#endif //GSMAT_GSMATERRORLOGLEVEL_H diff --git a/AtCommandsInc/AtGsmListCurrentCalls.h b/AtCommandsInc/AtGsmListCurrentCalls.h new file mode 100755 index 0000000..72050d7 --- /dev/null +++ b/AtCommandsInc/AtGsmListCurrentCalls.h @@ -0,0 +1,43 @@ +// +// Created by xemon on 09.09.22. +// + +#ifndef GSMAT_GSMCOMMONLISTCURRENTCALLS_H +#define GSMAT_GSMCOMMONLISTCURRENTCALLS_H + +#include "stddef.h" +#include "stdint.h" +#include "stdbool.h" +#include "AtCmdBase.h" + +typedef enum { + GSM_CURRENT_CALL_DIRECTION_MOBILE_ORIGINATED = 0x00, + GSM_CURRENT_CALL_DIRECTION_MOBILE_TERMINATED = 0x01, +} eGsmCurrentCallDirection; + +typedef enum { + GSM_CURRENT_CALL_STATE_ACTIVE = 0x00, + GSM_CURRENT_CALL_STATE_HELD = 0x01, + GSM_CURRENT_CALL_STATE_DIALING = 0x02, + GSM_CURRENT_CALL_STATE_ALERTING = 0x03, + GSM_CURRENT_CALL_STATE_INCOMING = 0x04, + GSM_CURRENT_CALL_STATE_WAITING = 0x05, +} eGsmCurrentCallState; + +typedef struct { + uint8_t idx; + eGsmCurrentCallDirection direction; + eGsmCurrentCallState state; + uint8_t mode; + bool multiparty; +} tGsmCurrentCall; + +#define GSM_CURRENT_CALLS_TABLE_LIMIT 16 +typedef struct { + tGsmCurrentCall calls[GSM_CURRENT_CALLS_TABLE_LIMIT]; + uint8_t count; +} tGsmCurrentCallsTable; + +AtCommandResult AtGsmListOfCurrentCalls(tAtCmd *env, tGsmCurrentCallsTable *currentCallsTable); + +#endif //GSMAT_GSMCOMMONLISTCURRENTCALLS_H diff --git a/AtCommandsInc/AtGsmOpenAudioLoop.h b/AtCommandsInc/AtGsmOpenAudioLoop.h new file mode 100755 index 0000000..8bc9c6b --- /dev/null +++ b/AtCommandsInc/AtGsmOpenAudioLoop.h @@ -0,0 +1,13 @@ +// +// Created by cfif on 17.12.22. +// + +#ifndef UVEOS_ON_NATION_ATGSMOPENAUDIOLOOP_H +#define UVEOS_ON_NATION_ATGSMOPENAUDIOLOOP_H + +#include "AtCmdBase.h" +#include "stdbool.h" + +AtCommandResult AtGsmSetOpenAudioLoop(tAtCmd *env, bool value); + +#endif //UVEOS_ON_NATION_ATGSMOPENAUDIOLOOP_H diff --git a/AtCommandsInc/AtGsmOperatorSelection.h b/AtCommandsInc/AtGsmOperatorSelection.h new file mode 100755 index 0000000..e1dbe8e --- /dev/null +++ b/AtCommandsInc/AtGsmOperatorSelection.h @@ -0,0 +1,22 @@ +// +// Created by xemon on 14.12.22. +// + +#ifndef UVEOS_ON_NATION_ATGSMOPERATORSELECTION_H +#define UVEOS_ON_NATION_ATGSMOPERATORSELECTION_H + + +#include "AtCmdBase.h" + +typedef enum { + GSM_OPERATOR_SELECTION_MODE_AUTOMATIC = 0, + GSM_OPERATOR_SELECTION_MODE_MANUAL = 1, + GSM_OPERATOR_SELECTION_MODE_DEREGISTER = 2, +} tGsmOperatorSelectionMode; + +AtCommandResult AtGsm_OperatorSelectionAutomatic(tAtCmd *env); + +AtCommandResult AtGsm_OperatorSelectionDeregister(tAtCmd *env); + + +#endif //UVEOS_ON_NATION_ATGSMOPERATORSELECTION_H diff --git a/AtCommandsInc/AtGsmVoiceCall.h b/AtCommandsInc/AtGsmVoiceCall.h new file mode 100755 index 0000000..67db281 --- /dev/null +++ b/AtCommandsInc/AtGsmVoiceCall.h @@ -0,0 +1,22 @@ +// +// Created by xemon on 25.10.22. +// + +#ifndef UVEOS_ON_NATION_ATGSMVOICECALL_H +#define UVEOS_ON_NATION_ATGSMVOICECALL_H + +#include "AtCmdCommon.h" + +AtCommandResult AtGsmVoiceCall(tAtCmd *env, char *phoneNumber, uint8_t phoneNumberLen); + +AtCommandResult AtGsmHangUpCall(tAtCmd *env); + +AtCommandResult AtGsmAnswer(tAtCmd *env); + +uint16_t xGsmReadLastTextSms( + tAtCmd *env, + uint32_t *data, + uint16_t *dataLen +); + +#endif //UVEOS_ON_NATION_ATGSMVOICECALL_H diff --git a/AtCommandsInc/AtGsm_GetTime.h b/AtCommandsInc/AtGsm_GetTime.h new file mode 100755 index 0000000..b170d8d --- /dev/null +++ b/AtCommandsInc/AtGsm_GetTime.h @@ -0,0 +1,10 @@ +// +// Created by ilya on 14.02.23. +// + +#ifndef UVEOS_ON_NATION_ATGSM_GETTIME_H +#define UVEOS_ON_NATION_ATGSM_GETTIME_H +#include "AtCmdBase.h" +#include "time.h" +AtCommandResult AtGsm_GetTime (tAtCmd *env,struct tm *time); +#endif //UVEOS_ON_NATION_ATGSM_GETTIME_H diff --git a/AtCommandsInc/AtGsm_NetworkRegistrationStatus.h b/AtCommandsInc/AtGsm_NetworkRegistrationStatus.h new file mode 100755 index 0000000..49e31d9 --- /dev/null +++ b/AtCommandsInc/AtGsm_NetworkRegistrationStatus.h @@ -0,0 +1,29 @@ +// +// Created by xemon on 15.12.22. +// + +#ifndef UVEOS_ON_NATION_ATGSM_NETWORKREGISTRATIONSTATUS_H +#define UVEOS_ON_NATION_ATGSM_NETWORKREGISTRATIONSTATUS_H + +typedef enum { + AT_NETWORK_REGISTRATION_REPORT_DISABLE = '0', + AT_NETWORK_REGISTRATION_REPORT_ENABLE = '1', + AT_NETWORK_REGISTRATION_REPORT_ENABLE_WITH_CELL_ID = '2', +} tAtGsm_NetworkRegistrationReportMode; + +typedef enum { + AT_NETWORK_REGISTRATION_STATE_NOT_REGISTERED = '0', + AT_NETWORK_REGISTRATION_STATE_REGISTERED_HOME = '1', + AT_NETWORK_REGISTRATION_STATE_NOT_REGISTERED_BUT_SEARCH = '2', + AT_NETWORK_REGISTRATION_STATE_REGISTRATION_DENIED = '3', + AT_NETWORK_REGISTRATION_STATE_UNKNOWN = '4', + AT_NETWORK_REGISTRATION_STATE_REGISTERED_ROAMING = '5', +} tAtGsm_NetworkRegistrationState; + +AtCommandResult AtGsm_NetworkRegistrationStatus( + tAtCmd *env, + tAtGsm_NetworkRegistrationReportMode *mode, + tAtGsm_NetworkRegistrationState *state +); + +#endif //UVEOS_ON_NATION_ATGSM_NETWORKREGISTRATIONSTATUS_H diff --git a/AtCommandsSrc/AtGsmErrorLogLevel.c b/AtCommandsSrc/AtGsmErrorLogLevel.c new file mode 100755 index 0000000..caca9aa --- /dev/null +++ b/AtCommandsSrc/AtGsmErrorLogLevel.c @@ -0,0 +1,19 @@ +// +// Created by xemon on 09.09.22. +// + +#include "AtGsmErrorLogLevel.h" +#include "AtCmdCommonProtected.h" + +AtCommandResult AtGsmSetErrorLogLevel(tAtCmd *env, tGsmErrorLogLevel value) { + AtCmdPrepare(env); + + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT+CMEE="); + AtCmdTxAddDecimalInt(env, value, 1); + + AtCmdTxSendLn(env); + + return AtCmdOkErrAnswer(env, env->stdRxTimeout); +} + diff --git a/AtCommandsSrc/AtGsmListCurrentCalls.c b/AtCommandsSrc/AtGsmListCurrentCalls.c new file mode 100755 index 0000000..cb2241e --- /dev/null +++ b/AtCommandsSrc/AtGsmListCurrentCalls.c @@ -0,0 +1,76 @@ +// +// Created by xemon on 09.09.22. +// +#include +#include "AtGsmListCurrentCalls.h" +#include "AtCmdCommonProtected.h" +#include "AsciiStringParsingUtils.h" + +AtCommandResult AtGsmListOfCurrentCalls(tAtCmd *env, tGsmCurrentCallsTable *currentCallsTable) { + + currentCallsTable->count = 0; + + AtCmdPrepare(env); + AtCmdSendStatic(env, "AT+CLCC\r\n"); + + + uint32_t timeout = 5000; + uint32_t endMs = SystemGetMs() + timeout; + uint32_t leftMs = timeout; + + while (AtCmdReceiveNextLine(env, leftMs) == AT_OK) { + leftMs = endMs - SystemGetMs(); + + if (AtCmdRxBeginWithStatic(env, "AT+CLCC")) { + AtCmdRxClear(env); + continue; + + } else if (AtCmdRxBeginWithStatic(env, "OK")) { + + return AT_OK; + + } else if (AtCmdRxBeginWithStatic(env, "ERROR")) { + + return AT_ERROR; + + } else if (AtCmdRxBeginWithStatic(env, "+CLCC:")) { + + tGsmCurrentCall *next_call = ¤tCallsTable->calls[currentCallsTable->count]; + + char *front; + char *div = env->rxBuffer.data + sizeof("+CLCC:"); + char *end = div + env->rxBuffer.len; + + if (iAsciiStringMoveToNextParsingBlock(&front, &div, end, ',')) { + next_call->idx = iAsciiStringParseUnsignedLongDecimalNumber(front, div); + } + + if (iAsciiStringMoveToNextParsingBlock(&front, &div, end, ',')) { + next_call->direction = iAsciiStringParseUnsignedLongDecimalNumber(front, div); + } + + if (iAsciiStringMoveToNextParsingBlock(&front, &div, end, ',')) { + next_call->state = iAsciiStringParseUnsignedLongDecimalNumber(front, div); + } + + if (iAsciiStringMoveToNextParsingBlock(&front, &div, end, ',')) { + next_call->mode = iAsciiStringParseUnsignedLongDecimalNumber(front, div); + } + + if (iAsciiStringMoveToNextParsingBlock(&front, &div, end, ',')) { + next_call->multiparty = iAsciiStringParseUnsignedLongDecimalNumber(front, div); + } + + + ++currentCallsTable->count; + + AtCmdRxClear(env); + } else { + AtCmdProcessUnresolvedLine(env); + AtCmdRxClear(env); + continue; + } + } + + return AT_ERROR; +} diff --git a/AtCommandsSrc/AtGsmOpenAudioLoop.c b/AtCommandsSrc/AtGsmOpenAudioLoop.c new file mode 100755 index 0000000..11a0b68 --- /dev/null +++ b/AtCommandsSrc/AtGsmOpenAudioLoop.c @@ -0,0 +1,23 @@ +// +// Created by cfif on 17.12.22. +// + +#include "AtGsmErrorLogLevel.h" +#include "AtCmdCommonProtected.h" + +AtCommandResult AtGsmSetOpenAudioLoop(tAtCmd *env, bool value) { + AtCmdPrepare(env); + + AtCmdTxClear(env); + AtCmdTxAddStatic(env, "AT#OAP="); + + if (value) { + AtCmdTxAddDecimalInt(env, 1, 1); + } else { + AtCmdTxAddDecimalInt(env, 0, 1); + } + + AtCmdTxSendLn(env); + + return AtCmdOkErrAnswer(env, env->stdRxTimeout); +} \ No newline at end of file diff --git a/AtCommandsSrc/AtGsmOperatorSelection.c b/AtCommandsSrc/AtGsmOperatorSelection.c new file mode 100755 index 0000000..7dd6f6f --- /dev/null +++ b/AtCommandsSrc/AtGsmOperatorSelection.c @@ -0,0 +1,18 @@ +// +// Created by xemon on 14.12.22. +// +#include "AtGsmOperatorSelection.h" +#include "AtCmdCommonProtected.h" + + +AtCommandResult AtGsm_OperatorSelectionAutomatic(tAtCmd *env) { + AtCmdPrepare(env); + AtCmdSendStatic(env, "AT+COPS=0\r\n"); + return AtCmdOkErrAnswer(env, 10 * env->stdRxTimeout); +} + +AtCommandResult AtGsm_OperatorSelectionDeregister(tAtCmd *env) { + AtCmdPrepare(env); + AtCmdSendStatic(env, "AT+COPS=2\r\n"); + return AtCmdOkErrAnswer(env, 1 * env->stdRxTimeout); +} \ No newline at end of file diff --git a/AtCommandsSrc/AtGsmVoiceCall.c b/AtCommandsSrc/AtGsmVoiceCall.c new file mode 100755 index 0000000..2ea5df9 --- /dev/null +++ b/AtCommandsSrc/AtGsmVoiceCall.c @@ -0,0 +1,33 @@ +// +// Created by xemon on 25.10.22. +// +#include "AtGsmVoiceCall.h" +#include "AtCmdCommonProtected.h" +#include "SystemDelayInterface.h" + + + +AtCommandResult AtGsmVoiceCall(tAtCmd *env, char *phoneNumber, uint8_t phoneNumberLen) { + AtCmdPrepare(env); + AtCmdTxClear(env); + + AtCmdTxAddStatic(env, "ATD"); + AtCmdTxAdd(env, phoneNumber, phoneNumberLen); + AtCmdTxAddChar(env, ';'); + + AtCmdTxSendLn(env); + + return AtCmdOkErrAnswer(env, env->stdRxTimeout); +} + +AtCommandResult AtGsmHangUpCall(tAtCmd *env) { + AtCmdPrepare(env); + AtCmdSendStatic(env, "ATH\r\n"); + return AtCmdOkErrAnswer(env, 5 * env->stdRxTimeout); +} + +AtCommandResult AtGsmAnswer(tAtCmd *env) { + AtCmdPrepare(env); + AtCmdSendStatic(env, "ATA\r\n"); + return AtCmdOkErrAnswer(env, 5 * env->stdRxTimeout); +} diff --git a/AtCommandsSrc/AtGsm_GetTime.c b/AtCommandsSrc/AtGsm_GetTime.c new file mode 100755 index 0000000..d7959c2 --- /dev/null +++ b/AtCommandsSrc/AtGsm_GetTime.c @@ -0,0 +1,84 @@ +// +// Created by ilya on 14.02.23. +// + +#include "AtGsm_GetTime.h" +#include +#include +#include "AtGsmListCurrentCalls.h" +#include "AtCmdCommonProtected.h" +static void parser (char *buf,struct tm *time) +{char *dasd; + uint32_t year; + uint32_t month; + uint32_t day; + uint32_t hour; + uint32_t min; + uint32_t sec; + char buf_year[2]; + buf_year[0]=buf[1]; + buf_year[1]=buf[2]; + char buf_month[2]; + buf_month[0]=buf[4]; + buf_month[1]=buf[5]; + char buf_day[2];buf_day[0]=buf[7];buf_day[1]=buf[8]; + char buf_hour[2];buf_hour[0]=buf[10];buf_hour[1]=buf[11]; + char buf_min[2];buf_min[0]=buf[13];buf_min[1]=buf[14]; + char buf_sec[2];buf_sec[0]=buf[16];buf_sec[1]=buf[17]; + year=strtol(buf_year,&dasd,10); + month=strtol(buf_month,&dasd,10); + day=strtol(buf_day,&dasd,10); + hour=strtol(buf_hour,&dasd,10); + min=strtol(buf_min,&dasd,10); + sec=strtol(buf_sec,&dasd,10); + time->tm_year=year; + time->tm_mon=month; + time->tm_mday=day; + time->tm_hour=hour; + time->tm_min=min; + time->tm_sec=sec;} +AtCommandResult AtGsm_GetTime (tAtCmd *env,struct tm *time) +{ + char buf[20]; + uint32_t timeout = 5000; + uint32_t endMs = SystemGetMs() + timeout; + uint32_t leftMs = timeout; + + AtCmdPrepare(env); + + AtCmdSendStatic(env, "AT+CCLK?\r\n"); + + + + while (AtCmdReceiveNextLine(env, leftMs) == AT_OK) { + leftMs = endMs - SystemGetMs(); + + if (AtCmdRxBeginWithStatic(env, "AT+CCLK")) { + AtCmdRxClear(env); + continue; + + } else if (AtCmdRxBeginWithStatic(env, "OK")) { + AtCmdRxClear(env); + return AT_OK; + + } else if (AtCmdRxBeginWithStatic(env, "ERROR")) { + AtCmdRxClear(env); + return AT_ERROR; + + } else if (AtCmdRxBeginWithStatic(env, "+CCLK: ")) { + + char *div = env->rxBuffer.data + sizeof("+CCLK:"); + for (int i=0;i<18;i++) + {char*tmpadd=div+i; + buf[i]=*tmpadd;} + parser(buf,time); + AtCmdRxClear(env); + } else { + AtCmdProcessUnresolvedLine(env); + AtCmdRxClear(env); + continue; + } + } + + return AT_ERROR; +} \ No newline at end of file diff --git a/AtCommandsSrc/AtGsm_NetworkRegistrationStatus.c b/AtCommandsSrc/AtGsm_NetworkRegistrationStatus.c new file mode 100755 index 0000000..f61db18 --- /dev/null +++ b/AtCommandsSrc/AtGsm_NetworkRegistrationStatus.c @@ -0,0 +1,62 @@ +// +// Created by xemon on 15.12.22. +// +#include +#include "AtCmdCommonProtected.h" +#include "AsciiStringParsingUtils.h" +#include "AtGsm_NetworkRegistrationStatus.h" + +AtCommandResult AtGsm_NetworkRegistrationStatus( + tAtCmd *env, + tAtGsm_NetworkRegistrationReportMode *mode, + tAtGsm_NetworkRegistrationState *state +) { + + + AtCmdPrepare(env); + AtCmdSendStatic(env, "AT+CREG?\r\n"); + + + uint32_t timeout = 5000; + uint32_t endMs = SystemGetMs() + timeout; + uint32_t leftMs = timeout; + + while (AtCmdReceiveNextLine(env, leftMs) == AT_OK) { + leftMs = endMs - SystemGetMs(); + + if (AtCmdRxBeginWithStatic(env, "AT+CREG")) { + AtCmdRxClear(env); + continue; + + } else if (AtCmdRxBeginWithStatic(env, "OK")) { + AtCmdRxClear(env); + return AT_OK; + + } else if (AtCmdRxBeginWithStatic(env, "ERROR")) { + AtCmdRxClear(env); + return AT_ERROR; + + } else if (AtCmdRxBeginWithStatic(env, "+CREG: ")) { + + char *front; + char *div = env->rxBuffer.data + sizeof("+CREG:"); + char *end = div + env->rxBuffer.len; + + if (iAsciiStringMoveToNextParsingBlock(&front, &div, end, ',')) { + *(char *) mode = *front; + } + + if (iAsciiStringMoveToNextParsingBlock(&front, &div, end, ',')) { + *(char *) state = *front; + } + + AtCmdRxClear(env); + } else { + AtCmdProcessUnresolvedLine(env); + AtCmdRxClear(env); + continue; + } + } + + return AT_ERROR; +} diff --git a/Inc/AtGsmCommon.h b/Inc/AtGsmCommon.h new file mode 100755 index 0000000..639096a --- /dev/null +++ b/Inc/AtGsmCommon.h @@ -0,0 +1,18 @@ +// +// Created by xemon on 25.10.22. +// + +#ifndef UVEOS_ON_NATION_ATGSMCOMMON_H +#define UVEOS_ON_NATION_ATGSMCOMMON_H + +#include "AtCmdCommon.h" + +#include "AtGsmVoiceCall.h" +#include "AtGsmListCurrentCalls.h" +#include "AtGsmErrorLogLevel.h" +#include "AtGsmOperatorSelection.h" +#include "AtGsm_NetworkRegistrationStatus.h" +#include "AtGsm_GetTime.h" + + +#endif //UVEOS_ON_NATION_ATGSMCOMMON_H diff --git a/modular.json b/modular.json new file mode 100755 index 0000000..c235572 --- /dev/null +++ b/modular.json @@ -0,0 +1,18 @@ +{ + "dep": [ + { + "type": "git", + "provider": "GONEC_BOOT_MODEM", + "repo": "AtCmdCommon" + } + ], + "cmake": { + "inc_dirs": [ + "Inc", + "AtCommandsInc" + ], + "srcs": [ + "AtCommandsSrc/**.c" + ] + } +} \ No newline at end of file