EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #528 background imageLoading...
Page #528 background image
Chapter 2. API Reference
Type Definitions
typedef struct esp_mqtt_client *esp_mqtt_client_handle_t
typedef struct esp_mqtt_error_codes esp_mqtt_error_codes_t
MQTT error code structure to be passed as a contextual information into ERROR event.
Important: This structure extends esp_tls_last_error error structure and is backward compatible with
it (so might be down-casted and treated as esp_tls_last_error error, but recommended to update
applications if used this way previously)
Use this structure directly checking error_type first and then appropriate error code depending on the source
of the error:
| error_type | related member variables | note | | MQTT_ERROR_TYPE_TCP_TRANSPORT |
esp_tls_last_esp_err, esp_tls_stack_err, esp_tls_cert_verify_flags, sock_errno | Error reported from
tcp_transport/esp-tls | | MQTT_ERROR_TYPE_CONNECTION_REFUSED | connect_return_code | Inter-
nal error reported from MQTT broker on connection |
typedef esp_mqtt_event_t *esp_mqtt_event_handle_t
typedef esp_err_t (*mqtt_event_callback_t)(esp_mqtt_event_handle_t event)
Enumerations
enum esp_mqtt_event_id_t
MQTT event types.
User event handler receives context data in esp_mqtt_event_t structure with
user_context - user data from esp_mqtt_client_config_t
client - mqtt client handle
various other data depending on event type
Values:
MQTT_EVENT_ANY = -1
MQTT_EVENT_ERROR = 0
on error event, additional context: connection return code, error handle from esp_tls (if supported)
MQTT_EVENT_CONNECTED
connected event, additional context: session_present flag
MQTT_EVENT_DISCONNECTED
disconnected event
MQTT_EVENT_SUBSCRIBED
subscribed event, additional context: msg_id
MQTT_EVENT_UNSUBSCRIBED
unsubscribed event
MQTT_EVENT_PUBLISHED
published event, additional context: msg_id
MQTT_EVENT_DATA
data event, additional context:
msg_id message id
topic pointer to the received topic
topic_len length of the topic
data pointer to the received data
data_len length of the data for this event
current_data_offset offset of the current data for this event
total_data_len total length of the data received
retain retain flag of the message Note: Multiple MQTT_EVENT_DATA could be fired for one
message, if it is longer than internal buffer. In that case only first event contains topic pointer and
length, other contain data only with current data length and current data offset updating.
Espressif Systems 517
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish