Init
This commit is contained in:
commit
9df75e05a5
|
|
@ -0,0 +1,33 @@
|
|||
//
|
||||
// Created by cfif on 07.06.2024.
|
||||
//
|
||||
|
||||
#ifndef SMART_COMPONENTS_ATGSMEPSNETWORKREGISTRATIONSTATUS_H
|
||||
#define SMART_COMPONENTS_ATGSMEPSNETWORKREGISTRATIONSTATUS_H
|
||||
|
||||
#include "AtCmdBase.h"
|
||||
/*
|
||||
typedef enum {
|
||||
AT_EPS_NETWORK_REGISTRATION_GSM = 0,
|
||||
AT_EPS_NETWORK_REGISTRATION_GSM_COMPACT = 1,
|
||||
AT_EPS_NETWORK_REGISTRATION_UTRAN = 2,
|
||||
AT_EPS_NETWORK_REGISTRATION_GSM_EGPRS = 3,
|
||||
AT_EPS_NETWORK_REGISTRATION_UTRAN_HSDPA = 4,
|
||||
AT_EPS_NETWORK_REGISTRATION_UTRAN_HSUPA = 5,
|
||||
AT_EPS_NETWORK_REGISTRATION_UTRAN_HSDPA_HSUPA = 6,
|
||||
AT_EPS_NETWORK_REGISTRATION_E_UTRAN = 7,
|
||||
} eAtGsm_EpsNetworkRegistrationStatus;
|
||||
|
||||
AtCommandResult AtGsm_EpsNetworkRegistrationStatus(
|
||||
tAtCmd *env,
|
||||
eAtGsm_EpsNetworkRegistrationStatus *status
|
||||
);
|
||||
*/
|
||||
|
||||
AtCommandResult AtGsm_EpsNetworkRegistrationStatus(
|
||||
tAtCmd *env,
|
||||
uint8_t *status
|
||||
);
|
||||
|
||||
|
||||
#endif //SMART_COMPONENTS_ATGSMEPSNETWORKREGISTRATIONSTATUS_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
|
||||
|
|
@ -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,23 @@
|
|||
//
|
||||
// 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;
|
||||
|
||||
void RegCost(bool state);
|
||||
|
||||
AtCommandResult AtGsm_OperatorSelectionAutomatic(tAtCmd *env);
|
||||
|
||||
AtCommandResult AtGsm_OperatorSelectionDeregister(tAtCmd *env);
|
||||
|
||||
#endif //UVEOS_ON_NATION_ATGSMOPERATORSELECTION_H
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
//
|
||||
// Created by cfif on 07.06.2024.
|
||||
//
|
||||
|
||||
#ifndef SMART_COMPONENTS_ATGSMQUERYSIGNALQUALITY_H
|
||||
#define SMART_COMPONENTS_ATGSMQUERYSIGNALQUALITY_H
|
||||
|
||||
#include "AtCmdBase.h"
|
||||
|
||||
AtCommandResult AtGsm_QuerySignalQuality(
|
||||
tAtCmd *env,
|
||||
uint8_t *rssi
|
||||
);
|
||||
|
||||
#endif //SMART_COMPONENTS_ATGSMQUERYSIGNALQUALITY_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,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
|
||||
|
|
@ -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,58 @@
|
|||
//
|
||||
// Created by cfif on 07.06.2024.
|
||||
//
|
||||
#include <SystemDelayInterface.h>
|
||||
#include "AtCmdCommonProtected.h"
|
||||
#include "AsciiStringParsingUtils.h"
|
||||
#include "AtGsmEpsNetworkRegistrationStatus.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
AtCommandResult AtGsm_EpsNetworkRegistrationStatus(
|
||||
tAtCmd *env,
|
||||
uint8_t *status
|
||||
) {
|
||||
|
||||
AtCmdPrepare(env);
|
||||
AtCmdRxClear(env);
|
||||
AtCmdSendStatic(env, "AT+CNSMOD?\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+CNSMOD")) {
|
||||
AtCmdRxClear(env);
|
||||
continue;
|
||||
|
||||
} else if (AtCmdRxBeginWithStatic(env, "ERROR")) {
|
||||
AtCmdRxClear(env);
|
||||
return AT_ERROR;
|
||||
|
||||
} else if (AtCmdRxBeginWithStatic(env, "+CNSMOD: ")) {
|
||||
|
||||
char *front;
|
||||
char *div = env->rxBuffer.data + sizeof("+CNSMOD:") - 1;
|
||||
char *end = div + env->rxBuffer.len;
|
||||
|
||||
if (iAsciiStringMoveToNextParsingBlock(&front, &div, end, ',')) {
|
||||
uint8_t n = atoi(front);
|
||||
}
|
||||
|
||||
if (iAsciiStringMoveToNextParsingBlock(&front, &div, end, ',')) {
|
||||
*(uint8_t *) status = atoi(front);
|
||||
}
|
||||
|
||||
AtCmdRxClear(env);
|
||||
return AT_OK;
|
||||
} else {
|
||||
AtCmdProcessUnresolvedLine(env);
|
||||
AtCmdRxClear(env);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return AT_ERROR;
|
||||
}
|
||||
|
|
@ -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,31 @@
|
|||
//
|
||||
// Created by xemon on 14.12.22.
|
||||
//
|
||||
#include "AtGsmOperatorSelection.h"
|
||||
#include "AtCmdCommonProtected.h"
|
||||
|
||||
bool isCost = false;
|
||||
tAtCmd *env1;
|
||||
|
||||
void RegCost(bool state){
|
||||
if (state){
|
||||
AtCmdPrepare(env1);
|
||||
AtCmdSendStatic(env1, "AT+COPS=2\r\n");
|
||||
}
|
||||
isCost = state;
|
||||
}
|
||||
|
||||
AtCommandResult AtGsm_OperatorSelectionAutomatic(tAtCmd *env) {
|
||||
// return AT_OK;
|
||||
AtCmdPrepare(env);
|
||||
AtCmdSendStatic(env, "AT+COPS=0\r\n");
|
||||
return AtCmdOkErrAnswer(env, 10 * env->stdRxTimeout);
|
||||
}
|
||||
|
||||
AtCommandResult AtGsm_OperatorSelectionDeregister(tAtCmd *env) {
|
||||
// return AT_OK;
|
||||
AtCmdPrepare(env);
|
||||
AtCmdRxClear(env);
|
||||
AtCmdSendStatic(env, "AT+COPS=2\r\n");
|
||||
return AtCmdOkErrAnswer(env, 1 * env->stdRxTimeout);
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
//
|
||||
// Created by cfif on 07.06.2024.
|
||||
//
|
||||
#include <SystemDelayInterface.h>
|
||||
#include "AtCmdCommonProtected.h"
|
||||
#include "AsciiStringParsingUtils.h"
|
||||
#include "AtGsmQuerySignalQuality.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
AtCommandResult AtGsm_QuerySignalQuality(
|
||||
tAtCmd *env,
|
||||
uint8_t *rssi
|
||||
) {
|
||||
|
||||
AtCmdPrepare(env);
|
||||
AtCmdRxClear(env);
|
||||
AtCmdSendStatic(env, "AT+CSQ\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+CSQ")) {
|
||||
AtCmdRxClear(env);
|
||||
continue;
|
||||
|
||||
} else if (AtCmdRxBeginWithStatic(env, "ERROR")) {
|
||||
AtCmdRxClear(env);
|
||||
return AT_ERROR;
|
||||
|
||||
} else if (AtCmdRxBeginWithStatic(env, "+CSQ: ")) {
|
||||
|
||||
char *front;
|
||||
char *div = env->rxBuffer.data + sizeof("+CSQ:") - 1;
|
||||
char *end = div + env->rxBuffer.len;
|
||||
|
||||
uint8_t Ber = 0;
|
||||
uint8_t Rssi = 0;
|
||||
if (iAsciiStringMoveToNextParsingBlock(&front, &div, end, ',')) {
|
||||
Rssi = atoi(front);
|
||||
*(uint8_t *) rssi = Rssi;
|
||||
}
|
||||
|
||||
if (iAsciiStringMoveToNextParsingBlock(&front, &div, end, ',')) {
|
||||
Ber = atoi(front);
|
||||
}
|
||||
|
||||
AtCmdRxClear(env);
|
||||
return AT_OK;
|
||||
} else {
|
||||
AtCmdProcessUnresolvedLine(env);
|
||||
AtCmdRxClear(env);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return AT_ERROR;
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
//
|
||||
// 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,94 @@
|
|||
//
|
||||
// Created by ilya on 14.02.23.
|
||||
//
|
||||
|
||||
#include "AtGsm_GetTime.h"
|
||||
#include <SystemDelayInterface.h>
|
||||
#include <stdlib.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 = (int)year + 100;
|
||||
time->tm_mon = (int)month - 1;
|
||||
time->tm_mday = (int)day;
|
||||
time->tm_hour = (int)hour;
|
||||
time->tm_min = (int)min;
|
||||
time->tm_sec = (int)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) && (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;
|
||||
}
|
||||
}
|
||||
SystemDelayMs(400);
|
||||
return AT_ERROR;
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
//
|
||||
// Created by xemon on 15.12.22.
|
||||
//
|
||||
#include <SystemDelayInterface.h>
|
||||
#include "AtCmdCommonProtected.h"
|
||||
#include "AsciiStringParsingUtils.h"
|
||||
#include "AtGsm_NetworkRegistrationStatus.h"
|
||||
|
||||
AtCommandResult AtGsm_NetworkRegistrationStatus(
|
||||
tAtCmd *env,
|
||||
tAtGsm_NetworkRegistrationReportMode *mode,
|
||||
tAtGsm_NetworkRegistrationState *state
|
||||
) {
|
||||
AtCmdPrepare(env);
|
||||
AtCmdRxClear(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,17 @@
|
|||
//
|
||||
// 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": "Smart_Components_Aurus",
|
||||
"repo": "AtCmdCommon"
|
||||
}
|
||||
],
|
||||
"cmake": {
|
||||
"inc_dirs": [
|
||||
"Inc",
|
||||
"AtCommandsInc"
|
||||
],
|
||||
"srcs": [
|
||||
"AtCommandsSrc/**.c"
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue