AT API Reference

Header File

Functions

void esp_at_module_init(const uint8_t *custom_version)

This function should be called only once.

参数

custom_version – version information by custom

esp_at_para_parse_result_type esp_at_get_para_as_digit(int32_t para_index, int32_t *value)

Parse digit parameter from command string.

参数
  • para_index – the index of parameter

  • value – the value parsed

返回

  • ESP_AT_PARA_PARSE_RESULT_OK : succeed

  • ESP_AT_PARA_PARSE_RESULT_FAIL : fail

  • ESP_AT_PARA_PARSE_RESULT_OMITTED : this parameter is OMITTED

esp_at_para_parse_result_type esp_at_get_para_as_float(int32_t para_index, float *value)

Parse float parameter from command string.

参数
  • para_index – the index of parameter

  • value – the value parsed

返回

  • ESP_AT_PARA_PARSE_RESULT_OK : succeed

  • ESP_AT_PARA_PARSE_RESULT_FAIL : fail

  • ESP_AT_PARA_PARSE_RESULT_OMITTED : this parameter is OMITTED

esp_at_para_parse_result_type esp_at_get_para_as_str(int32_t para_index, uint8_t **result)

Parse string parameter from command string.

参数
  • para_index – the index of parameter

  • result – the pointer that point to the result.

返回

  • ESP_AT_PARA_PARSE_RESULT_OK : succeed

  • ESP_AT_PARA_PARSE_RESULT_FAIL : fail

  • ESP_AT_PARA_PARSE_RESULT_OMITTED : this parameter is OMITTED

void esp_at_port_recv_data_notify_from_isr(int32_t len)

Calling the esp_at_port_recv_data_notify_from_isr to notify at module that at port received data. When received this notice,at task will get data by calling get_data_length and read_data in esp_at_device_ops. This function MUST be used in isr.

参数

len – data length

bool esp_at_port_recv_data_notify(int32_t len, uint32_t msec)

Calling the esp_at_port_recv_data_notify to notify at module that at port received data. When received this notice,at task will get data by calling get_data_length and read_data in esp_at_device_ops. This function MUST NOT be used in isr.

参数
  • len – data length

  • msec – timeout time,The unit is millisecond. It waits forever,if msec is portMAX_DELAY.

返回

  • true : succeed

  • false : fail

void esp_at_transmit_terminal_from_isr(void)

terminal transparent transmit mode,This function MUST be used in isr.

void esp_at_transmit_terminal(void)

terminal transparent transmit mode,This function MUST NOT be used in isr.

bool esp_at_custom_cmd_array_regist(const esp_at_cmd_struct *custom_at_cmd_array, uint32_t cmd_num)

regist at command set, which defined by custom,

参数
  • custom_at_cmd_array – at command set

  • cmd_num – command number

void esp_at_device_ops_regist(esp_at_device_ops_struct *ops)

regist device operate functions set,

参数

ops – device operate functions set

bool esp_at_custom_net_ops_regist(int32_t link_id, esp_at_custom_net_ops_struct *ops)
bool esp_at_custom_ble_ops_regist(int32_t conn_index, esp_at_custom_ble_ops_struct *ops)
void esp_at_custom_ops_regist(esp_at_custom_ops_struct *ops)

regist custom operate functions set interacting with AT,

参数

ops – custom operate functions set

uint32_t esp_at_get_version(void)

get at module version number,

返回

at version bit31~bit24: at main version bit23~bit16: at sub version bit15~bit8 : at test version bit7~bit0 : at custom version

void esp_at_response_result(uint8_t result_code)

response AT process result,

参数

result_code – see esp_at_result_code_string_index

int32_t esp_at_port_write_data(uint8_t *data, int32_t len)

write data into device,

参数
  • data – data buffer to be written

  • len – data length

返回

  • >= 0 : the real length of the data written

  • others : fail.

int32_t esp_at_port_active_write_data(uint8_t *data, int32_t len)

call pre_active_write_data_callback() first and then write data into device,

参数
  • data – data buffer to be written

  • len – data length

返回

  • >= 0 : the real length of the data written

  • others : fail.

int32_t esp_at_port_read_data(uint8_t *data, int32_t len)

read data from device,

参数
  • data – data buffer

  • len – data length

返回

  • >= 0 : the real length of the data read from device

  • others : fail

bool esp_at_port_wait_write_complete(int32_t timeout_msec)

wait for transmitting data completely to peer device,

参数

timeout_msec – timeout time,The unit is millisecond.

返回

  • true : succeed,transmit data completely

  • false : fail

int32_t esp_at_port_get_data_length(void)

get the length of the data received,

返回

  • >= 0 : the length of the data received

  • others : fail

bool esp_at_custom_cmd_line_terminator_set(uint8_t *terminator)

Set AT command terminator, by default, the terminator is “\r\n” You can change it by calling this function, but it just supports one character now.

参数

terminator – the line terminator

返回

  • true : succeed,transmit data completely

  • false : fail

uint8_t *esp_at_custom_cmd_line_terminator_get(void)

Get AT command line terminator,by default, the return string is “\r\n”.

返回

the command line terminator

const esp_partition_t *esp_at_custom_partition_find(esp_partition_type_t type, esp_partition_subtype_t subtype, const char *label)

Find the partition which is defined in at_customize.csv.

参数
  • type – the type of the partition

  • subtype – the subtype of the partition

  • label – Partition label

返回

pointer to esp_partition_t structure, or NULL if no partition is found. This pointer is valid for the lifetime of the application

void esp_at_port_enter_specific(esp_at_port_specific_callback_t callback)

Set AT core as specific status, it will call callback if receiving data. for example:

static void wait_data_callback (void)
{
    xSemaphoreGive(sync_sema);
}

void process_task(void* para)
{
    vSemaphoreCreateBinary(sync_sema);
    xSemaphoreTake(sync_sema,portMAX_DELAY);
    esp_at_port_write_data((uint8_t *)">",strlen(">"));
    esp_at_port_enter_specific(wait_data_callback);
    while(xSemaphoreTake(sync_sema,portMAX_DELAY)) {
        len = esp_at_port_read_data(data, data_len);
        // TODO:
    }
}

参数

callback – which will be called when received data from AT port

void esp_at_port_exit_specific(void)

Exit AT core as specific status.

const uint8_t *esp_at_get_current_cmd_name(void)

Get current AT command name.

int32_t esp_at_get_core_version(char *buffer, uint32_t size)

Get the version of the AT core library.

参数
  • buffer – buffer to store the version string

  • size – size of the buffer

返回

  • > 0 : the real length of the version string

  • others : fail

void at_handle_result_code(esp_at_result_code_string_index code, void *pbuf)

Structures

struct esp_at_cmd_struct

esp_at_cmd_struct used for define at command

Public Members

char *at_cmdName

at command name

uint8_t (*at_testCmd)(uint8_t *cmd_name)

Test Command function pointer

uint8_t (*at_queryCmd)(uint8_t *cmd_name)

Query Command function pointer

uint8_t (*at_setupCmd)(uint8_t para_num)

Setup Command function pointer

uint8_t (*at_exeCmd)(uint8_t *cmd_name)

Execute Command function pointer

struct esp_at_device_ops_struct

esp_at_device_ops_struct device operate functions struct for AT

Public Members

int32_t (*read_data)(uint8_t *data, int32_t len)

read data from device

int32_t (*write_data)(uint8_t *data, int32_t len)

write data into device

int32_t (*get_data_length)(void)

get the length of data received

bool (*wait_write_complete)(int32_t timeout_msec)

wait write finish

struct esp_at_custom_net_ops_struct

esp_at_custom_net_ops_struct custom socket callback for AT

Public Members

int32_t (*recv_data)(uint8_t *data, int32_t len)

callback when socket received data

void (*connect_cb)(void)

callback when socket connection is built

void (*disconnect_cb)(void)

callback when socket connection is disconnected

struct esp_at_custom_ble_ops_struct

esp_at_custom_ble_ops_struct custom ble callback for AT

Public Members

int32_t (*recv_data)(uint8_t *data, int32_t len)

callback when ble received data

void (*connect_cb)(void)

callback when ble connection is built

void (*disconnect_cb)(void)

callback when ble connection is disconnected

struct esp_at_custom_ops_struct

esp_at_ops_struct some custom function interacting with AT

Public Members

void (*status_callback)(esp_at_status_type status)

callback when AT status changes

void (*pre_sleep_callback)(at_sleep_mode_t mode)

callback before enter modem sleep and light sleep

void (*pre_deepsleep_callback)(void)

callback before enter deep sleep

void (*pre_restart_callback)(void)

callback before restart

void (*pre_active_write_data_callback)(at_write_data_fn_t)

callback before write data

Macros

at_min(x, y)
at_max(x, y)
ESP_AT_ERROR_NO(subcategory, extension)
ESP_AT_CMD_ERROR_OK

No Error

ESP_AT_CMD_ERROR_NON_FINISH

terminator character not found (“\r\n” expected)

ESP_AT_CMD_ERROR_NOT_FOUND_AT

Starting “AT” not found (or at, At or aT entered)

ESP_AT_CMD_ERROR_PARA_LENGTH(which_para)

parameter length mismatch

ESP_AT_CMD_ERROR_PARA_TYPE(which_para)

parameter type mismatch

ESP_AT_CMD_ERROR_PARA_NUM(need, given)

parameter number mismatch

ESP_AT_CMD_ERROR_PARA_INVALID(which_para)

the parameter is invalid

ESP_AT_CMD_ERROR_PARA_PARSE_FAIL(which_para)

parse parameter fail

ESP_AT_CMD_ERROR_CMD_UNSUPPORT

the command is not supported

ESP_AT_CMD_ERROR_CMD_EXEC_FAIL(result)

the command execution failed

ESP_AT_CMD_ERROR_CMD_PROCESSING

processing of previous command is in progress

ESP_AT_CMD_ERROR_CMD_OP_ERROR

the command operation type is error

Type Definitions

typedef int32_t (*at_write_data_fn_t)(uint8_t *data, int32_t len)
typedef void (*esp_at_port_specific_callback_t)(void)

AT specific callback type.

Enumerations

enum esp_at_status_type

esp_at_status some custom function interacting with AT

Values:

enumerator ESP_AT_STATUS_NORMAL

Normal mode.Now mcu can send AT command

enumerator ESP_AT_STATUS_TRANSMIT

Transparent Transmition mode

enum at_sleep_mode_t

Values:

enumerator AT_DISABLE_SLEEP
enumerator AT_MIN_MODEM_SLEEP
enumerator AT_LIGHT_SLEEP
enumerator AT_MAX_MODEM_SLEEP
enumerator AT_SLEEP_MAX
enum esp_at_module

module number,Now just AT module

Values:

enumerator ESP_AT_MODULE_NUM

AT module

enum esp_at_error_code

subcategory number

Values:

enumerator ESP_AT_SUB_OK

OK

enumerator ESP_AT_SUB_COMMON_ERROR

reserved

enumerator ESP_AT_SUB_NO_TERMINATOR

terminator character not found (“\r\n” expected)

enumerator ESP_AT_SUB_NO_AT

Starting “AT” not found (or at, At or aT entered)

enumerator ESP_AT_SUB_PARA_LENGTH_MISMATCH

parameter length mismatch

enumerator ESP_AT_SUB_PARA_TYPE_MISMATCH

parameter type mismatch

enumerator ESP_AT_SUB_PARA_NUM_MISMATCH

parameter number mismatch

enumerator ESP_AT_SUB_PARA_INVALID

the parameter is invalid

enumerator ESP_AT_SUB_PARA_PARSE_FAIL

parse parameter fail

enumerator ESP_AT_SUB_UNSUPPORT_CMD

the command is not supported

enumerator ESP_AT_SUB_CMD_EXEC_FAIL

the command execution failed

enumerator ESP_AT_SUB_CMD_PROCESSING

processing of previous command is in progress

enumerator ESP_AT_SUB_CMD_OP_ERROR

the command operation type is error

enum esp_at_para_parse_result_type

the result of AT parse

Values:

enumerator ESP_AT_PARA_PARSE_RESULT_FAIL

parse fail,Maybe the type of parameter is mismatched,or out of range

enumerator ESP_AT_PARA_PARSE_RESULT_OK

Successful

enumerator ESP_AT_PARA_PARSE_RESULT_OMITTED

the parameter is OMITTED.

enum esp_at_result_code_string_index

the result code of AT command processing

Values:

enumerator ESP_AT_RESULT_CODE_OK

“OK”

enumerator ESP_AT_RESULT_CODE_ERROR

“ERROR”

enumerator ESP_AT_RESULT_CODE_FAIL

“ERROR”

enumerator ESP_AT_RESULT_CODE_SEND_OK

“SEND OK”

enumerator ESP_AT_RESULT_CODE_SEND_FAIL

“SEND FAIL”

enumerator ESP_AT_RESULT_CODE_IGNORE

response nothing, just change internal status

enumerator ESP_AT_RESULT_CODE_PROCESS_DONE

response nothing, just change internal status

enumerator ESP_AT_RESULT_CODE_OK_AND_INPUT_PROMPT
enumerator ESP_AT_RESULT_CODE_MAX

Header File

Functions

const char *esp_at_get_current_module_name(void)

get current module name

const char *esp_at_get_module_name_by_id(uint32_t id)

get module name by index

uint32_t esp_at_get_module_id(void)

get current module id

void esp_at_set_module_id(uint32_t id)

Set current module id.

参数

id[in] the module id to set

void esp_at_set_module_id_by_str(const char *buffer)

Get module id by module name.

参数

buffer[in] pointer to a module name string

void esp_at_main_preprocess(void)

some workarounds for esp-at project

at_mfg_params_storage_mode_t at_get_mfg_params_storage_mode(void)

get storage mode of mfg parameters

返回

at_mfg_params_storage_mode_t

Macros

ESP_AT_PORT_TX_WAIT_MS_MAX
AT_BUFFER_ON_STACK_SIZE

Enumerations

enum at_mfg_params_storage_mode_t

Values:

enumerator AT_PARAMS_NONE
enumerator AT_PARAMS_IN_MFG_NVS
enumerator AT_PARAMS_IN_PARTITION