Init
This commit is contained in:
commit
fcddcc3624
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
//
|
||||||
|
// 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 AtGsmHangUpEcoll(tAtCmd *env);
|
||||||
|
|
||||||
|
AtCommandResult AtGsmHangUpCall(tAtCmd *env);
|
||||||
|
|
||||||
|
AtCommandResult AtGsmPrepareHangCall(tAtCmd *env);
|
||||||
|
|
||||||
|
AtCommandResult AtGsmAnswer(tAtCmd *env);
|
||||||
|
|
||||||
|
uint16_t xGsmReadLastTextSms(
|
||||||
|
tAtCmd *env,
|
||||||
|
uint32_t *data,
|
||||||
|
uint16_t *dataLen
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif //UVEOS_ON_NATION_ATGSMVOICECALL_H
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
//
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
AtCommandResult AtGsm_GetTimestamp(tAtCmd *env, time_t *timestamp);
|
||||||
|
|
||||||
|
#endif //UVEOS_ON_NATION_ATGSM_GETTIME_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
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
//
|
||||||
|
// Created by xemon on 09.09.22.
|
||||||
|
//
|
||||||
|
#include <SystemDelayInterface.h>
|
||||||
|
#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) && (SystemGetMs() < endMs)) {
|
||||||
|
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 {
|
||||||
|
AtCmdRxClear(env);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return AT_ERROR;
|
||||||
|
}
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
//
|
||||||
|
// 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 AtGsmPrepareHangCall(tAtCmd *env) {
|
||||||
|
AtCmdPrepare(env);
|
||||||
|
AtCmdTxClear(env);
|
||||||
|
|
||||||
|
AtCmdTxAddStatic(env, "AT+CVHU=0");
|
||||||
|
|
||||||
|
AtCmdTxSendLn(env);
|
||||||
|
return AtCmdOkErrAnswer(env, 10 * env->stdRxTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AtCommandResult AtGsmHangUpEcoll(tAtCmd *env) {
|
||||||
|
AtCmdPrepare(env);
|
||||||
|
AtCmdTxClear(env);
|
||||||
|
|
||||||
|
AtCmdTxAddStatic(env, "AT+CECALLE=1");
|
||||||
|
AtCmdTxSendLn(env);
|
||||||
|
return AtCmdOkErrAnswer(env, 10 * env->stdRxTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
AtCommandResult AtGsmHangUpCall(tAtCmd *env) {
|
||||||
|
AtCmdPrepare(env);
|
||||||
|
AtCmdTxClear(env);
|
||||||
|
|
||||||
|
AtCmdTxAddStatic(env, "ATH");
|
||||||
|
AtCmdTxSendLn(env);
|
||||||
|
return AtCmdOkErrAnswer(env, 10 * env->stdRxTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
AtCommandResult AtGsmAnswer(tAtCmd *env) {
|
||||||
|
AtCmdPrepare(env);
|
||||||
|
AtCmdTxClear(env);
|
||||||
|
AtCmdSendStatic(env, "ATA\r\n");
|
||||||
|
return AtCmdOkErrAnswer(env, 10 * env->stdRxTimeout);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,110 @@
|
||||||
|
//
|
||||||
|
// Created by ilya on 14.02.23.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "AtGsm_GetTime.h"
|
||||||
|
#include <SystemDelayInterface.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
|
static 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) && (SystemGetMs() < endMs)) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
AtCommandResult AtGsm_GetTimestamp(tAtCmd *env, time_t *timestamp) {
|
||||||
|
struct tm tmValue;
|
||||||
|
memset(&tmValue, 0, sizeof(tmValue));
|
||||||
|
|
||||||
|
AtCommandResult res = AtGsm_GetTime(env, &tmValue);
|
||||||
|
if (res != AT_OK) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
tmValue.tm_mon -= 1;
|
||||||
|
tmValue.tm_year += 100;
|
||||||
|
*timestamp = mktime(&tmValue);
|
||||||
|
|
||||||
|
return AT_OK;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,113 @@
|
||||||
|
//
|
||||||
|
// Created by xemon on 15.12.22.
|
||||||
|
//
|
||||||
|
#include <SystemDelayInterface.h>
|
||||||
|
#include "AtCmdCommonProtected.h"
|
||||||
|
#include "AsciiStringParsingUtils.h"
|
||||||
|
#include "AtGsm_NetworkRegistrationStatus.h"
|
||||||
|
//
|
||||||
|
//AtCommandResult AtGsm_NetworkRegistration(
|
||||||
|
// tAtCmd *env,
|
||||||
|
// tAtGsm_NetworkRegistrationReportMode *mode,
|
||||||
|
// tAtGsm_NetworkRegistrationState *state
|
||||||
|
//) {
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// AtCmdPrepare(env);
|
||||||
|
// AtCmdSendStatic(env, "AT+COPS?\r\n");
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// uint32_t timeout = 500;
|
||||||
|
// uint32_t endMs = SystemGetMs() + timeout;
|
||||||
|
// uint32_t leftMs = timeout;
|
||||||
|
//
|
||||||
|
// while ((AtCmdReceiveNextLine(env, leftMs) == AT_OK) && (SystemGetMs() < endMs)) {
|
||||||
|
// 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;
|
||||||
|
//}
|
||||||
|
|
||||||
|
AtCommandResult AtGsm_NetworkRegistrationStatus(
|
||||||
|
tAtCmd *env,
|
||||||
|
tAtGsm_NetworkRegistrationReportMode *mode,
|
||||||
|
tAtGsm_NetworkRegistrationState *state
|
||||||
|
) {
|
||||||
|
|
||||||
|
|
||||||
|
AtCmdPrepare(env);
|
||||||
|
AtCmdSendStatic(env, "AT+CREG?\r\n");
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t timeout = 1000;
|
||||||
|
uint32_t endMs = SystemGetMs() + timeout;
|
||||||
|
uint32_t leftMs = timeout;
|
||||||
|
|
||||||
|
while ((AtCmdReceiveNextLine(env, leftMs) == AT_OK) && (SystemGetMs() < endMs)) {
|
||||||
|
leftMs = endMs - SystemGetMs();
|
||||||
|
|
||||||
|
if (AtCmdRxBeginWithStatic(env, "AT+CREG")) {
|
||||||
|
AtCmdRxClear(env);
|
||||||
|
continue;
|
||||||
|
} 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);
|
||||||
|
return AT_OK;
|
||||||
|
} else {
|
||||||
|
AtCmdProcessUnresolvedLine(env);
|
||||||
|
AtCmdRxClear(env);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return AT_ERROR;
|
||||||
|
}
|
||||||
|
|
@ -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
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"dep": [
|
||||||
|
{
|
||||||
|
"type": "git",
|
||||||
|
"provider": "GONEC_NEW",
|
||||||
|
"repo": "AtCmdCommon"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"cmake": {
|
||||||
|
"inc_dirs": [
|
||||||
|
"Inc",
|
||||||
|
"AtCommandsInc"
|
||||||
|
],
|
||||||
|
"srcs": [
|
||||||
|
"AtCommandsSrc/**.c"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue