Custom AT Development Guide_Rev1.2
Revision History
Version |
Date |
Author |
Reviewer |
Revision Content |
|---|---|---|---|---|
Rev1.0 |
2023-09-11 |
lxh |
zlc |
Initial document creation |
Rev1.1 |
2024-03-25 |
sxx |
Changed document name |
|
Rev1.2 |
2024-10-25 |
LJZ |
Modified document format |
1 Introduction
This document introduces how to add custom AT command functionality in LTE-EC71X OpenCPU.
2 API Function Overview
Function |
Description |
|---|---|
|
This function is used to enable AT function. |
|
This function is used to register AT table. |
|
This interface is the AT response function. |
3 Type Descriptions
3.1 liot_atCmdType_t
AT command types.
Declaration
typedef enum
{
LIOT_AT_CMD_SET = NA | EQ | AR,
LIOT_AT_CMD_TEST = NA | EQ | QU,
LIOT_AT_CMD_READ = NA | QU,
LIOT_AT_CMD_EXE = NA
} liot_atCmdType_t;
Parameters
LIOT_AT_CMD_SET: AT command setting.
LIOT_AT_CMD_TEST: AT command test.
LIOT_AT_CMD_READ: AT command read.
LIOT_AT_CMD_EXE: AT command execution.
The following text
3.2 liot_atcmd_basic_type_e
AT command basic index types:
Declaration
typedef enum
{
LIOT_AT_BASIC_N_C_IDX = 0,
LIOT_AT_BASIC_N_D_IDX,
LIOT_AT_BASIC_N_E_IDX,
LIOT_AT_BASIC_N_F_IDX,
LIOT_AT_BASIC_N_S_IDX,
LIOT_AT_BASIC_N_V_IDX,
LIOT_AT_BASIC_N_W_IDX,
LIOT_AT_BASIC_E_IDX,
LIOT_AT_BASIC_I_IDX,
LIOT_AT_BASIC_L_IDX,
LIOT_AT_BASIC_M_IDX,
LIOT_AT_BASIC_Q_IDX,
LIOT_AT_BASIC_V_IDX,
LIOT_AT_BASIC_X_IDX,
LIOT_AT_BASIC_Z_IDX,
LIOT_AT_BASIC_T_IDX,
LIOT_AT_BASIC_P_IDX,
} liot_atcmd_basic_type_e;
3.3 liot_at_result_enum_type
AT command return types:
Declaration
typedef enum
{
LIOT_AT_NO_RSP = -1,
LIOT_AT_OK = 0,
LIOT_AT_CONNECT = 1,
LIOT_AT_RING = 2,
LIOT_AT_NO_CARRIER = 3,
LIOT_AT_ERROR = 4,
LIOT_AT_CME_ERROR = 100,
} liot_at_result_enum_type;
Parameters
LIOT_AT_NO_RSP: AT command no response.
LIOT_AT_OK: AT command response successful.
LIOT_AT_CONNECT: AT command continues execution.
LIOT_AT_RING: AT command is executing.
LIOT_AT_ERROR: AT command error.
LIOT_AT_CME_ERROR: AT command execution error.
3.4 liot_atCommand_Input
AT command input parameters:
Declaration
typedef struct liot_atCommand_Input_t
{
CHAR name[LIOT_AT_CMD_NAME_MAX_LEN + 1];
UINT8 op;
liot_atHandle atHandle;
UINT8 args_count;
CHAR *arg[LIOT_AT_CMD_MAX_ARG];
} liot_atCommand_Input;
Parameters
Type |
Parameter |
Description |
|---|---|---|
CHAR |
name |
AT command name |
UINT8 |
op |
AT command execution type, refer to 4.1 |
liot_atHandle |
atHandle |
AT execution handle |
UINT8 |
args_count |
Number of parameters |
CHAR * |
arg |
Command parameter content |
3.5 liot_atCommand
AT command format declaration definition:
Declaration
typedef struct liot_atCommand_t
{
const CHAR *pName;
liot_at_result_enum_type (*atProcFunc)(const liot_atCommand_Input *pAtInputCtx);
} liot_atCommand, *liot_atCommandP;
Parameters
Type |
Parameter |
Description |
|---|---|---|
const CHAR* |
pName |
AT command name |
liot_at_result_enum_type |
atProcFunc |
AT function name |
3.6 liot_atMsgId_e
AT command message ID type enumeration is defined as follows:
Declaration
typedef enum
{
LIOT_AT_MIN_MSG = 0,
LIOT_AT_URC_MSG,
LIOT_AT_SIO_MSG,
LIOT_AT_SIM_MSG,
LIOT_AT_FILE_MSG,
LIOT_AT_SOCKET_MSG,
LIOT_AT_NTP_MSG,
LIOT_AT_PING_MSG,
LIOT_AT_HTTP_MSG,
LIOT_AT_CTCC_SREG_MSG,
LIOT_AT_FTP_MSG,
LIOT_AT_MQTT_MSG,
LIOT_AT_LBS_MSG,
LIOT_AT_LWM2M_MSG,
LIOT_AT_CMCC_DM_MSG,
LIOT_AT_CTWING_MSG,
LIOT_AT_PDP_MSG,
LIOT_AT_DNS_MSG,
LIOT_AT_MAX_MSG
} liot_atMsgId_e;
Parameters
LIOT_AT_MIN_MSG: Minimum message ID.
LIOT_AT_URC_MSG: AT command URC message ID.
LIOT_AT_SIO_MSG: IO message ID.
LIOT_AT_SIM_MSG: SIM card message ID.
LIOT_AT_FILE_MSG: File system message ID.
LIOT_AT_SOCKET_MSG: Socket message ID.
LIOT_AT_NTP_MSG: NTP message ID.
LIOT_AT_PING_MSG: PING message ID.
LIOT_AT_CTCC_SREG_MSG: Telecom self-registration message ID.
LIOT_AT_FTP_MSG: FTP message ID.
LIOT_AT_HTTP_MSG: HTTP message ID.
LIOT_AT_MQTT_MSG: MQTT message ID.
LIOT_AT_LBS_MSG: LBS message ID.
LIOT_AT_LWM2M_MSG: LWM2M message ID.
LIOT_AT_CMCC_DM_MSG: Mobile self-registration message ID.
LIOT_AT_CTWING_MSG: CTWING message ID.
LIOT_AT_PDP_MSG: PDP message ID.
LIOT_AT_DNS_MSG: DNS message ID.
LIOT_AT_MAX_MSG: Maximum message ID.
4 API Function Details
4.1 liot_atcmd_reply
This function is used to return the result after AT command execution, returning the result and error code to the serial port.
Declaration
int liot_atcmd_reply(liot_atHandle atHandle, liot_at_result_enum_type result_code, const CHAR *resp_str);
Parameters
liot_atHandle: [In] AT command handle.
result_code: [In] AT command execution result code.
resp_str: [In] Return string information.
Return Value
int: Execution result code, see 4.2 for reference.
4.2 liot_open_atcmd_init
This function is used to initialize and enable AT command table.
Declaration
void liot_open_atcmd_init(void)
Parameters
void.
Return Value
void.
4.3 liot_atcmd_register
This function is used to register AT command table.
Declaration
void liot_atcmd_register(const liot_atCommandP tab_ptr, const UINT32 tab_size);
Parameters
tab_ptr: [In] AT command table address.
tab_size: [In] AT command table size.
Return Value
void.
Requirements
5 Code Example
Refer to examples/demo/src/demo_atcmd.c for sample code. The following execution result indicates that all information was obtained normally:
Other issues
