AT API Reference

Header File

Functions

void esp_at_module_init(uint32_t netconn_max, const uint8_t *custom_version)

This function should be called only once, before any other AT functions are called.

Parameters
  • netconn_max: the maximum number of the link in the at module
  • 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.

Return
  • ESP_AT_PARA_PARSE_RESULT_OK : succeed
  • ESP_AT_PARA_PARSE_RESULT_FAIL : fail
  • ESP_AT_PARA_PARSE_RESULT_OMITTED : this parameter is OMITTED
Parameters
  • para_index: the index of parameter
  • value: the value parsed

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.

Return
  • ESP_AT_PARA_PARSE_RESULT_OK : succeed
  • ESP_AT_PARA_PARSE_RESULT_FAIL : fail
  • ESP_AT_PARA_PARSE_RESULT_OMITTED : this parameter is OMITTED
Parameters
  • para_index: the index of parameter
  • result: the pointer that point to the result.

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.

Parameters
  • 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.

Return
  • true : succeed
  • false : fail
Parameters
  • len: data length
  • msec: timeout time,The unit is millisecond. It waits forever,if msec is portMAX_DELAY.

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,

Parameters
  • 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,

Parameters
  • 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,

Parameters
  • ops: custom operate functions set

uint32_t esp_at_get_version(void)

get at module version number,

Return
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,

Parameters
  • 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,

Return
  • >= 0 : the real length of the data written
  • others : fail.
Parameters
  • data: data buffer to be written
  • len: data length

int32_t esp_at_port_read_data(uint8_t *data, int32_t len)

read data from device,

Return
  • >= 0 : the real length of the data read from device
  • others : fail
Parameters
  • data: data buffer
  • len: data length

bool esp_at_port_wait_write_complete(int32_t timeout_msec)

wait for transmitting data completely to peer device,

Return
  • true : succeed,transmit data completely
  • false : fail
Parameters
  • timeout_msec: timeout time,The unit is millisecond.

int32_t esp_at_port_get_data_length(void)

get the length of the data received,

Return
  • >= 0 : the length of the data received
  • others : fail

bool esp_at_base_cmd_regist(void)

regist at base command set. If not,you can not use AT base command

bool esp_at_wifi_cmd_regist(void)

regist at wifi command set. If not,you can not use AT wifi command

bool esp_at_net_cmd_regist(void)

regist at net command set. If not,you can not use AT net command

bool esp_at_mdns_cmd_regist(void)

regist at mdns command set. If not,you can not use AT mdns command

bool esp_at_wps_cmd_regist(void)

regist at wps command set. If not,you can not use AT wps command

bool esp_at_smartconfig_cmd_regist(void)

regist at smartconfig command set. If not,you can not use AT smartconfig command

bool esp_at_ping_cmd_regist(void)

regist at ping command set. If not,you can not use AT ping command

bool esp_at_http_cmd_regist(void)

regist at http command set. If not,you can not use AT http command

bool esp_at_mqtt_cmd_regist(void)

regist at mqtt command set. If not,you can not use AT mqtt command

bool esp_at_ble_cmd_regist(void)

regist at ble command set. If not,you can not use AT ble command

bool esp_at_ble_hid_cmd_regist(void)

regist at ble hid command set. If not,you can not use AT ble hid command

bool esp_at_blufi_cmd_regist(void)

regist at blufi command set. If not,you can not use AT blufi command

bool esp_at_bt_cmd_regist(void)

regist at bt command set. If not,you can not use AT bt command

bool esp_at_bt_spp_cmd_regist(void)

regist at bt spp command set. If not,you can not use AT bt spp command

bool esp_at_bt_a2dp_cmd_regist(void)

regist at bt a2dp command set. If not,you can not use AT bt a2dp command

bool esp_at_fs_cmd_regist(void)

regist at fs command set. If not,you can not use AT fs command

bool esp_at_eap_cmd_regist(void)

regist at WPA2 Enterprise AP command set. If not,you can not use AT EAP command

bool esp_at_eth_cmd_regist(void)

regist at ethernet command set. If not,you can not use AT ethernet command

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.

Return
  • true : succeed,transmit data completely
  • false : fail
Parameters
  • terminator: the line terminator

uint8_t *esp_at_custom_cmd_line_terminator_get(void)

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

Return
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.

Return
pointer to esp_partition_t structure, or NULL if no partition is found. This pointer is valid for the lifetime of the application
Parameters
  • type: the type of the partition
  • subtype: the subtype of the partition
  • label: Partition label

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:
    }
}
Parameters
  • 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.

esp_err_t esp_at_wifi_event_handler(void *ctx, system_event_t *event)

Wi-Fi event handler callback, which used in AT core.

Return
  • ESP_OK: succeed
  • others: fail
Parameters
  • ctx: reserved for user
  • event: event type defined in this file

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_deepsleep_callback)(void)

callback before enter deep sleep

void (*pre_restart_callback)(void)

callback before restart

Macros

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 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:

ESP_AT_STATUS_NORMAL = 0x0

Normal mode.Now mcu can send AT command

ESP_AT_STATUS_TRANSMIT

Transparent Transmition mode

enum esp_at_module

module number,Now just AT module

Values:

ESP_AT_MODULE_NUM = 0x01

AT module

enum esp_at_error_code

subcategory number

Values:

ESP_AT_SUB_OK = 0x00

OK

ESP_AT_SUB_COMMON_ERROR = 0x01

reserved

ESP_AT_SUB_NO_TERMINATOR = 0x02

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

ESP_AT_SUB_NO_AT = 0x03

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

ESP_AT_SUB_PARA_LENGTH_MISMATCH = 0x04

parameter length mismatch

ESP_AT_SUB_PARA_TYPE_MISMATCH = 0x05

parameter type mismatch

ESP_AT_SUB_PARA_NUM_MISMATCH = 0x06

parameter number mismatch

ESP_AT_SUB_PARA_INVALID = 0x07

the parameter is invalid

ESP_AT_SUB_PARA_PARSE_FAIL = 0x08

parse parameter fail

ESP_AT_SUB_UNSUPPORT_CMD = 0x09

the command is not supported

ESP_AT_SUB_CMD_EXEC_FAIL = 0x0A

the command execution failed

ESP_AT_SUB_CMD_PROCESSING = 0x0B

processing of previous command is in progress

ESP_AT_SUB_CMD_OP_ERROR = 0x0C

the command operation type is error

enum esp_at_para_parse_result_type

the result of AT parse

Values:

ESP_AT_PARA_PARSE_RESULT_FAIL = -1

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

ESP_AT_PARA_PARSE_RESULT_OK = 0

Successful

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:

ESP_AT_RESULT_CODE_OK = 0x00

“OK”

ESP_AT_RESULT_CODE_ERROR = 0x01

“ERROR”

ESP_AT_RESULT_CODE_FAIL = 0x02

“ERROR”

ESP_AT_RESULT_CODE_SEND_OK = 0x03

“SEND OK”

ESP_AT_RESULT_CODE_SEND_FAIL = 0x04

“SEND FAIL”

ESP_AT_RESULT_CODE_IGNORE = 0x05

response nothing, just change internal status

ESP_AT_RESULT_CODE_PROCESS_DONE = 0x06

response nothing, just change internal status

ESP_AT_RESULT_CODE_MAX