Event management

group ESP_EVT

Event helper functions.

Reset detected

Event helper functions for ESP_EVT_RESET_DETECTED event

uint8_t esp_evt_reset_detected_is_forced(esp_evt_t *cc)

Check if detected reset was forced by user.

Return

1 if forced by user, 0 otherwise

Parameters
  • [in] cc: Event handle

Reset event

Event helper functions for ESP_EVT_RESET event

espr_t esp_evt_reset_get_result(esp_evt_t *cc)

Get reset sequence operation status.

Return

Member of espr_t enumeration

Parameters
  • [in] cc: Event data

Restore event

Event helper functions for ESP_EVT_RESTORE event

espr_t esp_evt_restore_get_result(esp_evt_t *cc)

Get restore sequence operation status.

Return

Member of espr_t enumeration

Parameters
  • [in] cc: Event data

Access point or station IP or MAC

Event helper functions for ESP_EVT_AP_IP_STA event

esp_mac_t *esp_evt_ap_ip_sta_get_mac(esp_evt_t *cc)

Get MAC address from station.

Return

MAC address

Parameters
  • [in] cc: Event handle

esp_ip_t *esp_evt_ap_ip_sta_get_ip(esp_evt_t *cc)

Get IP address from station.

Return

IP address

Parameters
  • [in] cc: Event handle

Connected station to access point

Event helper functions for ESP_EVT_AP_CONNECTED_STA event

esp_mac_t *esp_evt_ap_connected_sta_get_mac(esp_evt_t *cc)

Get MAC address from connected station.

Return

MAC address

Parameters
  • [in] cc: Event handle

Disconnected station from access point

Event helper functions for ESP_EVT_AP_DISCONNECTED_STA event

esp_mac_t *esp_evt_ap_disconnected_sta_get_mac(esp_evt_t *cc)

Get MAC address from disconnected station.

Return

MAC address

Parameters
  • [in] cc: Event handle

Connection data received

Event helper functions for ESP_EVT_CONN_RECV event

esp_pbuf_p esp_evt_conn_recv_get_buff(esp_evt_t *cc)

Get buffer from received data.

Return

Buffer handle

Parameters
  • [in] cc: Event handle

esp_conn_p esp_evt_conn_recv_get_conn(esp_evt_t *cc)

Get connection handle for receive.

Return

Connection handle

Parameters
  • [in] cc: Event handle

Connection data send

Event helper functions for ESP_EVT_CONN_SEND event

esp_conn_p esp_evt_conn_send_get_conn(esp_evt_t *cc)

Get connection handle for data sent event.

Return

Connection handle

Parameters
  • [in] cc: Event handle

size_t esp_evt_conn_send_get_length(esp_evt_t *cc)

Get number of bytes sent on connection.

Return

Number of bytes sent

Parameters
  • [in] cc: Event handle

espr_t esp_evt_conn_send_get_result(esp_evt_t *cc)

Check if connection send was successful.

Return

Member of espr_t enumeration

Parameters
  • [in] cc: Event handle

Connection active

Event helper functions for ESP_EVT_CONN_ACTIVE event

esp_conn_p esp_evt_conn_active_get_conn(esp_evt_t *cc)

Get connection handle.

Return

Connection handle

Parameters
  • [in] cc: Event handle

uint8_t esp_evt_conn_active_is_client(esp_evt_t *cc)

Check if new connection is client.

Return

1 if client, 0 otherwise

Parameters
  • [in] cc: Event handle

Connection close event

Event helper functions for ESP_EVT_CONN_CLOSE event

esp_conn_p esp_evt_conn_close_get_conn(esp_evt_t *cc)

Get connection handle.

Return

Connection handle

Parameters
  • [in] cc: Event handle

uint8_t esp_evt_conn_close_is_client(esp_evt_t *cc)

Check if just closed connection was client.

Return

1 if client, 0 otherwise

Parameters
  • [in] cc: Event handle

uint8_t esp_evt_conn_close_is_forced(esp_evt_t *cc)

Check if connection close even was forced by user.

Return

1 if forced, 0 otherwise

Parameters
  • [in] cc: Event handle

espr_t esp_evt_conn_close_get_result(esp_evt_t *cc)

Get connection close event result.

Return

Member of espr_t enumeration

Parameters
  • [in] cc: Event handle

Connection poll

Event helper functions for ESP_EVT_CONN_POLL event

esp_conn_p esp_evt_conn_poll_get_conn(esp_evt_t *cc)

Get connection handle.

Return

Connection handle

Parameters
  • [in] cc: Event handle

Connection error

Event helper functions for ESP_EVT_CONN_ERROR event

espr_t esp_evt_conn_error_get_error(esp_evt_t *cc)

Get connection error type.

Return

Member of espr_t enumeration

Parameters
  • [in] cc: Event handle

esp_conn_type_t esp_evt_conn_error_get_type(esp_evt_t *cc)

Get connection type.

Return

Member of espr_t enumeration

Parameters
  • [in] cc: Event handle

const char *esp_evt_conn_error_get_host(esp_evt_t *cc)

Get connection host.

Return

Host name for connection

Parameters
  • [in] cc: Event handle

esp_port_t esp_evt_conn_error_get_port(esp_evt_t *cc)

Get connection port.

Return

Host port number

Parameters
  • [in] cc: Event handle

void *esp_evt_conn_error_get_arg(esp_evt_t *cc)

Get user argument.

Return

User argument

Parameters
  • [in] cc: Event handle

List access points

Event helper functions for ESP_EVT_STA_LIST_AP event

espr_t esp_evt_sta_list_ap_get_result(esp_evt_t *cc)

Get command success result.

Return

Member of espr_t enumeration

Parameters
  • [in] cc: Event handle

esp_ap_t *esp_evt_sta_list_ap_get_aps(esp_evt_t *cc)

Get access points.

Return

Pointer to esp_ap_t with first access point description

Parameters
  • [in] cc: Event handle

size_t esp_evt_sta_list_ap_get_length(esp_evt_t *cc)

Get number of access points found.

Return

Number of access points found

Parameters
  • [in] cc: Event handle

Join access point

Event helper functions for ESP_EVT_STA_JOIN_AP event

espr_t esp_evt_sta_join_ap_get_result(esp_evt_t *cc)

Get command success result.

Return

Member of espr_t enumeration

Parameters
  • [in] cc: Event handle

Get access point info

Event helper functions for ESP_EVT_STA_INFO_AP event

espr_t esp_evt_sta_info_ap_get_result(esp_evt_t *cc)

Get command result.

Return

Member of espr_t enumeration

Parameters
  • [in] cc: Event handle

const char *esp_evt_sta_info_ap_get_ssid(esp_evt_t *cc)

Get current AP name.

Return

AP name

Parameters
  • [in] cc: Event handle

esp_mac_t esp_evt_sta_info_ap_get_mac(esp_evt_t *cc)

Get current AP MAC address.

Return

AP MAC address

Parameters
  • [in] cc: Event handle

uint8_t esp_evt_sta_info_ap_get_channel(esp_evt_t *cc)

Get current AP channel.

Return

AP channel

Parameters
  • [in] cc: Event handle

int16_t esp_evt_sta_info_ap_get_rssi(esp_evt_t *cc)

Get current AP rssi.

Return

AP rssi

Parameters
  • [in] cc: Event handle

Get host address by name

Event helper functions for ESP_EVT_DNS_HOSTBYNAME event

espr_t esp_evt_dns_hostbyname_get_result(esp_evt_t *cc)

Get resolve result.

Return

Member of espr_t enumeration

Parameters
  • [in] cc: Event handle

const char *esp_evt_dns_hostbyname_get_host(esp_evt_t *cc)

Get hostname used to resolve IP address.

Return

Hostname

Parameters
  • [in] cc: Event handle

esp_ip_t *esp_evt_dns_hostbyname_get_ip(esp_evt_t *cc)

Get IP address from DNS function.

Return

IP address

Parameters
  • [in] cc: Event handle

Ping

Event helper functions for ESP_EVT_PING event

espr_t esp_evt_ping_get_result(esp_evt_t *cc)

Get ping status.

Return

Member of espr_t enumeration

Parameters
  • [in] cc: Event handle

const char *esp_evt_ping_get_host(esp_evt_t *cc)

Get hostname used to ping.

Return

Hostname

Parameters
  • [in] cc: Event handle

uint32_t esp_evt_ping_get_time(esp_evt_t *cc)

Get time required for ping.

Return

Ping time

Parameters
  • [in] cc: Event handle

Server

Event helper functions for ESP_EVT_SERVER event

espr_t esp_evt_server_get_result(esp_evt_t *cc)

Get server command result.

Return

Member of espr_t enumeration

Parameters
  • [in] cc: Event handle

esp_port_t esp_evt_server_get_port(esp_evt_t *cc)

Get port for server operation.

Return

Server port

Parameters
  • [in] cc: Event handle

uint8_t esp_evt_server_is_enable(esp_evt_t *cc)

Check if operation was to enable or disable server.

Return

1 if enable, 0 otherwise

Parameters
  • [in] cc: Event handle

Typedefs

typedef espr_t (*esp_evt_fn)(struct esp_evt *evt)

Event function prototype.

Return

espOK on success, member of espr_t otherwise

Parameters
  • [in] evt: Callback event data

Enums

enum esp_evt_type_t

List of possible callback types received to user.

Values:

ESP_EVT_INIT_FINISH

Initialization has been finished at this point

ESP_EVT_RESET_DETECTED

Device reset detected

ESP_EVT_RESET

Device reset operation finished

ESP_EVT_RESTORE

Device restore operation finished

ESP_EVT_CMD_TIMEOUT

Timeout on command. When application receives this event, it may reset system as there was (maybe) a problem in device

ESP_EVT_DEVICE_PRESENT

Notification when device present status changes

ESP_EVT_AT_VERSION_NOT_SUPPORTED

Library does not support firmware version on ESP device.

ESP_EVT_CONN_RECV

Connection data received

ESP_EVT_CONN_SEND

Connection data send

ESP_EVT_CONN_ACTIVE

Connection just became active

ESP_EVT_CONN_ERROR

Client connection start was not successful

ESP_EVT_CONN_CLOSE

Connection close event. Check status if successful

ESP_EVT_CONN_POLL

Poll for connection if there are any changes

ESP_EVT_SERVER

Server status changed

ESP_EVT_WIFI_CONNECTED

Station just connected to AP

ESP_EVT_WIFI_GOT_IP

Station has valid IP. When this event is received to application, no IP has been read from device. Stack will proceed with IP read from device and will later send ESP_EVT_WIFI_IP_ACQUIRED event

ESP_EVT_WIFI_DISCONNECTED

Station just disconnected from AP

ESP_EVT_WIFI_IP_ACQUIRED

Station IP address acquired. At this point, valid IP address has been received from device. Application may use esp_sta_copy_ip function to read it

ESP_EVT_STA_LIST_AP

Station listed APs event

ESP_EVT_STA_JOIN_AP

Join to access point

ESP_EVT_STA_INFO_AP

Station AP info (name, mac, channel, rssi)

ESP_EVT_AP_CONNECTED_STA

New station just connected to ESP’s access point

ESP_EVT_AP_DISCONNECTED_STA

New station just disconnected from ESP’s access point

ESP_EVT_AP_IP_STA

New station just received IP from ESP’s access point

ESP_EVT_DNS_HOSTBYNAME

DNS domain service finished

ESP_EVT_PING

PING service finished

Functions

espr_t esp_evt_register(esp_evt_fn fn)

Register event function for global (non-connection based) events.

Return

espOK on success, member of espr_t enumeration otherwise

Parameters
  • [in] fn: Callback function to call on specific event

espr_t esp_evt_unregister(esp_evt_fn fn)

Unregister callback function for global (non-connection based) events.

Note

Function must be first registered using esp_evt_register

Return

espOK on success, member of espr_t enumeration otherwise

Parameters
  • [in] fn: Callback function to remove from event list

esp_evt_type_t esp_evt_get_type(esp_evt_t *cc)

Get event type.

Return

Event type. Member of esp_evt_type_t enumeration

Parameters
  • [in] cc: Event handle

struct esp_evt_t
#include <esp_typedefs.h>

Global callback structure to pass as parameter to callback function.

Public Members

esp_evt_type_t type

Callback type

uint8_t forced

Set to 1 if reset forced by user

Set to 1 if connection action was forced (when active: 1 = CLIENT, 0 = SERVER: when closed, 1 = CMD, 0 = REMOTE)

struct esp_evt_t::[anonymous]::[anonymous] reset_detected

Reset occurred. Use with ESP_EVT_RESET_DETECTED event

espr_t res

Reset operation result

Restore operation result

Send data result

Result of close event. Set to espOK on success

Status of command

Result of command

struct esp_evt_t::[anonymous]::[anonymous] reset

Reset sequence finish. Use with ESP_EVT_RESET event

struct esp_evt_t::[anonymous]::[anonymous] restore

Restore sequence finish. Use with ESP_EVT_RESTORE event

esp_conn_p conn

Connection where data were received

Connection where data were sent

Pointer to connection

Set connection pointer

esp_pbuf_p buff

Pointer to received data

struct esp_evt_t::[anonymous]::[anonymous] conn_data_recv

Network data received. Use with ESP_EVT_CONN_RECV event

size_t sent

Number of bytes sent on connection

struct esp_evt_t::[anonymous]::[anonymous] conn_data_send

Data send. Use with ESP_EVT_CONN_SEND event

const char *host

Host to use for connection

Host name for DNS lookup

Host name for ping

esp_port_t port

Remote port used for connection

Server port number

esp_conn_type_t type

Connection type

void *arg

Connection user argument

espr_t err

Error value

struct esp_evt_t::[anonymous]::[anonymous] conn_error

Client connection start error. Use with ESP_EVT_CONN_ERROR event

uint8_t client

Set to 1 if connection is/was client mode

struct esp_evt_t::[anonymous]::[anonymous] conn_active_close

Process active and closed statuses at the same time. Use with ESP_EVT_CONN_ACTIVE or ESP_EVT_CONN_CLOSE events

struct esp_evt_t::[anonymous]::[anonymous] conn_poll

Polling active connection to check for timeouts. Use with ESP_EVT_CONN_POLL event

uint8_t en

Status to enable/disable server

struct esp_evt_t::[anonymous]::[anonymous] server

Server change event. Use with ESP_EVT_SERVER event

esp_ap_t *aps

Pointer to access points

size_t len

Number of access points found

struct esp_evt_t::[anonymous]::[anonymous] sta_list_ap

Station list access points. Use with ESP_EVT_STA_LIST_AP event

struct esp_evt_t::[anonymous]::[anonymous] sta_join_ap

Join to access point. Use with ESP_EVT_STA_JOIN_AP event

esp_sta_info_ap_t *info

AP info of current station

struct esp_evt_t::[anonymous]::[anonymous] sta_info_ap

Current AP informations. Use with ESP_EVT_STA_INFO_AP event

esp_mac_t *mac

Station MAC address

struct esp_evt_t::[anonymous]::[anonymous] ap_conn_disconn_sta

A new station connected or disconnected to ESP’s access point. Use with ESP_EVT_AP_CONNECTED_STA or ESP_EVT_AP_DISCONNECTED_STA events

esp_ip_t *ip

Station IP address

Pointer to IP result

struct esp_evt_t::[anonymous]::[anonymous] ap_ip_sta

Station got IP address from ESP’s access point. Use with ESP_EVT_AP_IP_STA event

struct esp_evt_t::[anonymous]::[anonymous] dns_hostbyname

DNS domain service finished. Use with ESP_EVT_DNS_HOSTBYNAME event

uint32_t time

Time required for ping. Valid only if operation succedded

struct esp_evt_t::[anonymous]::[anonymous] ping

Ping finished. Use with ESP_EVT_PING event

union esp_evt_t::[anonymous] evt

Callback event union