title
stringlengths
3
56
author
stringclasses
3 values
hostname
stringclasses
1 value
date
stringclasses
3 values
fingerprint
stringlengths
15
16
id
null
license
null
comments
stringclasses
1 value
raw_text
stringlengths
518
796k
text
stringlengths
514
592k
language
null
image
null
pagetype
null
source
stringlengths
68
116
source-hostname
stringclasses
1 value
excerpt
null
categories
stringclasses
1 value
tags
stringclasses
1 value
API Conventions
null
espressif.com
2016-01-01
bc127268662167db
null
null
API Conventions This document describes conventions and assumptions common to ESP-IDF Application Programming Interfaces (APIs). ESP-IDF provides several kinds of programming interfaces: C functions, structures, enums, type definitions, and preprocessor macros declared in public header files of ESP-IDF components. Various pages in the API Reference section of the programming guide contain descriptions of these functions, structures, and types. Build system functions, predefined variables, and options. These are documented in the ESP-IDF CMake Build System API. Kconfig options can be used in code and in the build system ( CMakeLists.txt ) files. Host tools and their command line parameters are also part of the ESP-IDF interfaces. ESP-IDF is made up of multiple components where these components either contain code specifically written for ESP chips, or contain a third-party library (i.e., a third-party component). In some cases, third-party components contain an "ESP-IDF specific" wrapper in order to provide an interface that is either simpler or better integrated with the rest of ESP-IDF's features. In other cases, third-party components present the original API of the underlying library directly. The following sections explain some of the aspects of ESP-IDF APIs and their usage. Error Handling Most ESP-IDF APIs return error codes defined with the esp_err_t type. See Error Handling section for more information about error handling approaches. Error Codes Reference contains the list of error codes returned by ESP-IDF components. Configuration Structures Important Correct initialization of configuration structures is an important part of making the application compatible with future versions of ESP-IDF. Most initialization, configuration, and installation functions in ESP-IDF (typically named ..._init() , ..._config() , and ..._install() ) take a configuration structure pointer as an argument. For example: const esp_timer_create_args_t my_timer_args = { .callback = &my_timer_callback, .arg = callback_arg, .name = "my_timer" }; esp_timer_handle_t my_timer; esp_err_t err = esp_timer_create(&my_timer_args, &my_timer); These functions never store the pointer to the configuration structure, so it is safe to allocate the structure on the stack. The application must initialize all fields of the structure. The following is incorrect: esp_timer_create_args_t my_timer_args; my_timer_args.callback = &my_timer_callback; /* Incorrect! Fields .arg and .name are not initialized */ esp_timer_create(&my_timer_args, &my_timer); Most ESP-IDF examples use C99 designated initializers for structure initialization since they provide a concise way of setting a subset of fields, and zero-initializing the remaining fields: const esp_timer_create_args_t my_timer_args = { .callback = &my_timer_callback, /* Correct, fields .arg and .name are zero-initialized */ }; The C++ language supports designated initializer syntax, too, but the initializers must be in the order of declaration. When using ESP-IDF APIs in C++ code, you may consider using the following pattern: /* Correct, fields .dispatch_method, .name and .skip_unhandled_events are zero-initialized */ const esp_timer_create_args_t my_timer_args = { .callback = &my_timer_callback, .arg = &my_arg, }; ///* Incorrect, .arg is declared after .callback in esp_timer_create_args_t */ //const esp_timer_create_args_t my_timer_args = { // .arg = &my_arg, // .callback = &my_timer_callback, //}; For more information on designated initializers, see Designated Initializers. Note that C++ language versions older than C++20, which are not the default in the current version of ESP-IDF, do not support designated initializers. If you have to compile code with an older C++ standard than C++20, you may use GCC extensions to produce the following pattern: esp_timer_create_args_t my_timer_args = {}; /* All the fields are zero-initialized */ my_timer_args.callback = &my_timer_callback; Default Initializers For some configuration structures, ESP-IDF provides macros for setting default values of fields: httpd_config_t config = HTTPD_DEFAULT_CONFIG(); /* HTTPD_DEFAULT_CONFIG expands to a designated initializer. Now all fields are set to the default values, and any field can still be modified: */ config.server_port = 8081; httpd_handle_t server; esp_err_t err = httpd_start(&server, &config); It is recommended to use default initializer macros whenever they are provided for a particular configuration structure. Private APIs Certain header files in ESP-IDF contain APIs intended to be used only in ESP-IDF source code rather than by the applications. Such header files often contain private or esp_private in their name or path. Certain components, such as hal only contain private APIs. Private APIs may be removed or changed in an incompatible way between minor or patch releases. Components in Example Projects ESP-IDF examples contain a variety of projects demonstrating the usage of ESP-IDF APIs. In order to reduce code duplication in the examples, a few common helpers are defined inside components that are used by multiple examples. This includes components located in common_components directory, as well as some of the components located in the examples themselves. These components are not considered to be part of the ESP-IDF API. It is not recommended to reference these components directly in custom projects (via EXTRA_COMPONENT_DIRS build system variable), as they may change significantly between ESP-IDF versions. When starting a new project based on an ESP-IDF example, copy both the project and the common components it depends on out of ESP-IDF, and treat the common components as part of the project. Note that the common components are written with examples in mind, and might not include all the error handling required for production applications. Before using, take time to read the code and understand if it is applicable to your use case. API Stability ESP-IDF uses Semantic Versioning as explained in the Versioning Scheme. Minor and bugfix releases of ESP-IDF guarantee compatibility with previous releases. The sections below explain different aspects and limitations to compatibility. Source-level Compatibility ESP-IDF guarantees source-level compatibility of C functions, structures, enums, type definitions, and preprocessor macros declared in public header files of ESP-IDF components. Source-level compatibility implies that the application source code can be recompiled with the newer version of ESP-IDF without changes. The following changes are allowed between minor versions and do not break source-level compatibility: Deprecating functions (using the deprecated attribute) and header files (using a preprocessor #warning ). Deprecations are listed in ESP-IDF release notes. It is recommended to update the source code to use the newer functions or files that replace the deprecated ones, however, this is not mandatory. Deprecated functions and files can be removed from major versions of ESP-IDF. Renaming components, moving source and header files between components — provided that the build system ensures that correct files are still found. Renaming Kconfig options. Kconfig system's backward compatibility ensures that the original Kconfig option names can still be used by the application in sdkconfig file, CMake files, and source code. Lack of Binary Compatibility ESP-IDF does not guarantee binary compatibility between releases. This means that if a precompiled library is built with one ESP-IDF version, it is not guaranteed to work the same way with the next minor or bugfix release. The following are the possible changes that keep source-level compatibility but not binary compatibility: Changing numerical values for C enum members. Adding new structure members or changing the order of members. See Configuration Structures for tips that help ensure compatibility. Replacing an extern function with a static inline one with the same signature, or vice versa. Replacing a function-like macro with a compatible C function. Other Exceptions from Compatibility While we try to make upgrading to a new ESP-IDF version easy, there are parts of ESP-IDF that may change between minor versions in an incompatible way. We appreciate issuing reports about any unintended breaking changes that do not fall into the categories below. Features clearly marked as "beta", "preview", or "experimental". Changes made to mitigate security issues or to replace insecure default behaviors with secure ones. Features that were never functional. For example, if it was never possible to use a certain function or an enumeration value, it may get renamed (as part of fixing it) or removed. This includes software features that depend on non-functional chip hardware features. Unexpected or undefined behavior that is not documented explicitly may be fixed/changed, such as due to missing validation of argument ranges. Location of Kconfig options in menuconfig. Location and names of example projects.(...TRUNCATED)
API Conventions This document describes conventions and assumptions common to ESP-IDF Application Programming Interfaces (APIs). ESP-IDF provides several kinds of programming interfaces: C functions, structures, enums, type definitions, and preprocessor macros declared in public header files of ESP-IDF components. Various pages in the API Reference section of the programming guide contain descriptions of these functions, structures, and types. Build system functions, predefined variables, and options. These are documented in the ESP-IDF CMake Build System API. Kconfig options can be used in code and in the build system ( CMakeLists.txt) files. Host tools and their command line parameters are also part of the ESP-IDF interfaces. ESP-IDF is made up of multiple components where these components either contain code specifically written for ESP chips, or contain a third-party library (i.e., a third-party component). In some cases, third-party components contain an "ESP-IDF specific" wrapper in order to provide an interface that is either simpler or better integrated with the rest of ESP-IDF's features. In other cases, third-party components present the original API of the underlying library directly. The following sections explain some of the aspects of ESP-IDF APIs and their usage. Error Handling Most ESP-IDF APIs return error codes defined with the esp_err_t type. See Error Handling section for more information about error handling approaches. Error Codes Reference contains the list of error codes returned by ESP-IDF components. Configuration Structures Important Correct initialization of configuration structures is an important part of making the application compatible with future versions of ESP-IDF. Most initialization, configuration, and installation functions in ESP-IDF (typically named ..._init(), ..._config(), and ..._install()) take a configuration structure pointer as an argument. For example: const esp_timer_create_args_t my_timer_args = { .callback = &my_timer_callback, .arg = callback_arg, .name = "my_timer" }; esp_timer_handle_t my_timer; esp_err_t err = esp_timer_create(&my_timer_args, &my_timer); These functions never store the pointer to the configuration structure, so it is safe to allocate the structure on the stack. The application must initialize all fields of the structure. The following is incorrect: esp_timer_create_args_t my_timer_args; my_timer_args.callback = &my_timer_callback; /* Incorrect! Fields .arg and .name are not initialized */ esp_timer_create(&my_timer_args, &my_timer); Most ESP-IDF examples use C99 designated initializers for structure initialization since they provide a concise way of setting a subset of fields, and zero-initializing the remaining fields: const esp_timer_create_args_t my_timer_args = { .callback = &my_timer_callback, /* Correct, fields .arg and .name are zero-initialized */ }; The C++ language supports designated initializer syntax, too, but the initializers must be in the order of declaration. When using ESP-IDF APIs in C++ code, you may consider using the following pattern: /* Correct, fields .dispatch_method, .name and .skip_unhandled_events are zero-initialized */ const esp_timer_create_args_t my_timer_args = { .callback = &my_timer_callback, .arg = &my_arg, }; ///* Incorrect, .arg is declared after .callback in esp_timer_create_args_t */ //const esp_timer_create_args_t my_timer_args = { // .arg = &my_arg, // .callback = &my_timer_callback, //}; For more information on designated initializers, see Designated Initializers. Note that C++ language versions older than C++20, which are not the default in the current version of ESP-IDF, do not support designated initializers. If you have to compile code with an older C++ standard than C++20, you may use GCC extensions to produce the following pattern: esp_timer_create_args_t my_timer_args = {}; /* All the fields are zero-initialized */ my_timer_args.callback = &my_timer_callback; Default Initializers For some configuration structures, ESP-IDF provides macros for setting default values of fields: httpd_config_t config = HTTPD_DEFAULT_CONFIG(); /* HTTPD_DEFAULT_CONFIG expands to a designated initializer. Now all fields are set to the default values, and any field can still be modified: */ config.server_port = 8081; httpd_handle_t server; esp_err_t err = httpd_start(&server, &config); It is recommended to use default initializer macros whenever they are provided for a particular configuration structure. Private APIs Certain header files in ESP-IDF contain APIs intended to be used only in ESP-IDF source code rather than by the applications. Such header files often contain private or esp_private in their name or path. Certain components, such as hal only contain private APIs. Private APIs may be removed or changed in an incompatible way between minor or patch releases. Components in Example Projects ESP-IDF examples contain a variety of projects demonstrating the usage of ESP-IDF APIs. In order to reduce code duplication in the examples, a few common helpers are defined inside components that are used by multiple examples. This includes components located in common_components directory, as well as some of the components located in the examples themselves. These components are not considered to be part of the ESP-IDF API. It is not recommended to reference these components directly in custom projects (via EXTRA_COMPONENT_DIRS build system variable), as they may change significantly between ESP-IDF versions. When starting a new project based on an ESP-IDF example, copy both the project and the common components it depends on out of ESP-IDF, and treat the common components as part of the project. Note that the common components are written with examples in mind, and might not include all the error handling required for production applications. Before using, take time to read the code and understand if it is applicable to your use case. API Stability ESP-IDF uses Semantic Versioning as explained in the Versioning Scheme. Minor and bugfix releases of ESP-IDF guarantee compatibility with previous releases. The sections below explain different aspects and limitations to compatibility. Source-level Compatibility ESP-IDF guarantees source-level compatibility of C functions, structures, enums, type definitions, and preprocessor macros declared in public header files of ESP-IDF components. Source-level compatibility implies that the application source code can be recompiled with the newer version of ESP-IDF without changes. The following changes are allowed between minor versions and do not break source-level compatibility: Deprecating functions (using the deprecatedattribute) and header files (using a preprocessor #warning). Deprecations are listed in ESP-IDF release notes. It is recommended to update the source code to use the newer functions or files that replace the deprecated ones, however, this is not mandatory. Deprecated functions and files can be removed from major versions of ESP-IDF. Renaming components, moving source and header files between components — provided that the build system ensures that correct files are still found. Renaming Kconfig options. Kconfig system's backward compatibility ensures that the original Kconfig option names can still be used by the application in sdkconfigfile, CMake files, and source code. Lack of Binary Compatibility ESP-IDF does not guarantee binary compatibility between releases. This means that if a precompiled library is built with one ESP-IDF version, it is not guaranteed to work the same way with the next minor or bugfix release. The following are the possible changes that keep source-level compatibility but not binary compatibility: Changing numerical values for C enum members. Adding new structure members or changing the order of members. See Configuration Structures for tips that help ensure compatibility. Replacing an externfunction with a static inlineone with the same signature, or vice versa. Replacing a function-like macro with a compatible C function. Other Exceptions from Compatibility While we try to make upgrading to a new ESP-IDF version easy, there are parts of ESP-IDF that may change between minor versions in an incompatible way. We appreciate issuing reports about any unintended breaking changes that do not fall into the categories below. Features clearly marked as "beta", "preview", or "experimental". Changes made to mitigate security issues or to replace insecure default behaviors with secure ones. Features that were never functional. For example, if it was never possible to use a certain function or an enumeration value, it may get renamed (as part of fixing it) or removed. This includes software features that depend on non-functional chip hardware features. Unexpected or undefined behavior that is not documented explicitly may be fixed/changed, such as due to missing validation of argument ranges. Location of Kconfig options in menuconfig. Location and names of example projects.(...TRUNCATED)
null
null
null
https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/api-conventions.html(...TRUNCATED)
ESP-IDF Programming Guide v5.2.1 documentation
null
ESP-MQTT
null
espressif.com
2016-01-01
6e59fd1e6a0bfa18
null
null
ESP-MQTT Overview ESP-MQTT is an implementation of MQTT protocol client, which is a lightweight publish/subscribe messaging protocol. Now ESP-MQTT supports MQTT v5.0. Features Support MQTT over TCP, SSL with Mbed TLS, MQTT over WebSocket, and MQTT over WebSocket Secure Easy to setup with URI Multiple instances (multiple clients in one application) Support subscribing, publishing, authentication, last will messages, keep alive pings, and all 3 Quality of Service (QoS) levels (it should be a fully functional client) Application Examples protocols/mqtt/tcp: MQTT over TCP, default port 1883 protocols/mqtt/ssl: MQTT over TLS, default port 8883 protocols/mqtt/ssl_ds: MQTT over TLS using digital signature peripheral for authentication, default port 8883 protocols/mqtt/ssl_mutual_auth: MQTT over TLS using certificates for authentication, default port 8883 protocols/mqtt/ssl_psk: MQTT over TLS using pre-shared keys for authentication, default port 8883 protocols/mqtt/ws: MQTT over WebSocket, default port 80 protocols/mqtt/wss: MQTT over WebSocket Secure, default port 443 protocols/mqtt5: Uses ESP-MQTT library to connect to broker with MQTT v5.0 MQTT Message Retransmission A new MQTT message is created by calling esp_mqtt_client_publish or its non blocking counterpart esp_mqtt_client_enqueue . Messages with QoS 0 is sent only once. QoS 1 and 2 have different behaviors since the protocol requires extra steps to complete the process. The ESP-MQTT library opts to always retransmit unacknowledged QoS 1 and 2 publish messages to avoid losses in faulty connections, even though the MQTT specification requires the re-transmission only on reconnect with Clean Session flag been set to 0 (set disable_clean_session to true for this behavior). QoS 1 and 2 messages that may need retransmission are always enqueued, but first transmission try occurs immediately if esp_mqtt_client_publish is used. A transmission retry for unacknowledged messages will occur after message_retransmit_timeout . After CONFIG_MQTT_OUTBOX_EXPIRED_TIMEOUT_MS messages will expire and be deleted. If CONFIG_MQTT_REPORT_DELETED_MESSAGES is set, an event will be sent to notify the user. Configuration The configuration is made by setting fields in esp_mqtt_client_config_t struct. The configuration struct has the following sub structs to configure different aspects of the client operation. esp_mqtt_client_config_t::broker_t - Allow to set address and security verification. esp_mqtt_client_config_t::credentials_t - Client credentials for authentication. esp_mqtt_client_config_t::session_t - Configuration for MQTT session aspects. esp_mqtt_client_config_t::network_t - Networking related configuration. esp_mqtt_client_config_t::task_t - Allow to configure FreeRTOS task. esp_mqtt_client_config_t::buffer_t - Buffer size for input and output. In the following sections, the most common aspects are detailed. Broker Address Broker address can be set by usage of address struct. The configuration can be made by usage of uri field or the combination of hostname , transport and port . Optionally, path could be set, this field is useful in WebSocket connections. The uri field is used in the format scheme://hostname:port/path . Curently support mqtt , mqtts , ws , wss schemes MQTT over TCP samples: mqtt://mqtt.eclipseprojects.io : MQTT over TCP, default port 1883 mqtt://mqtt.eclipseprojects.io:1884 : MQTT over TCP, port 1884 mqtt://username:password@mqtt.eclipseprojects.io:1884 : MQTT over TCP, port 1884, with username and password mqtt://mqtt.eclipseprojects.io : MQTT over TCP, default port 1883 mqtt://mqtt.eclipseprojects.io:1884 : MQTT over TCP, port 1884 mqtt://username:password@mqtt.eclipseprojects.io:1884 : MQTT over TCP, port 1884, with username and password mqtt://mqtt.eclipseprojects.io : MQTT over TCP, default port 1883 MQTT over SSL samples: mqtts://mqtt.eclipseprojects.io : MQTT over SSL, port 8883 mqtts://mqtt.eclipseprojects.io:8884 : MQTT over SSL, port 8884 mqtts://mqtt.eclipseprojects.io : MQTT over SSL, port 8883 mqtts://mqtt.eclipseprojects.io:8884 : MQTT over SSL, port 8884 mqtts://mqtt.eclipseprojects.io : MQTT over SSL, port 8883 MQTT over WebSocket samples: ws://mqtt.eclipseprojects.io:80/mqtt ws://mqtt.eclipseprojects.io:80/mqtt ws://mqtt.eclipseprojects.io:80/mqtt MQTT over WebSocket Secure samples: wss://mqtt.eclipseprojects.io:443/mqtt wss://mqtt.eclipseprojects.io:443/mqtt wss://mqtt.eclipseprojects.io:443/mqtt Minimal configurations: const esp_mqtt_client_config_t mqtt_cfg = { .broker.address.uri = "mqtt://mqtt.eclipseprojects.io", }; esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg); esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, client); esp_mqtt_client_start(client); Note By default MQTT client uses event loop library to post related MQTT events (connected, subscribed, published, etc.). Verification For secure connections with TLS used, and to guarantee Broker's identity, the verification struct must be set. The broker certificate may be set in PEM or DER format. To select DER, the equivalent certificate_len field must be set. Otherwise, a null-terminated string in PEM format should be provided to certificate field. Get certificate from server, example: mqtt.eclipseprojects.io openssl s_client -showcerts -connect mqtt.eclipseprojects.io:8883 < /dev/null \ 2> /dev/null | openssl x509 -outform PEM > mqtt_eclipse_org.pem Get certificate from server, example: mqtt.eclipseprojects.io openssl s_client -showcerts -connect mqtt.eclipseprojects.io:8883 < /dev/null \ 2> /dev/null | openssl x509 -outform PEM > mqtt_eclipse_org.pem Get certificate from server, example: mqtt.eclipseprojects.io Check the sample application: protocols/mqtt/ssl Configuration: const esp_mqtt_client_config_t mqtt_cfg = { .broker = { .address.uri = "mqtts://mqtt.eclipseprojects.io:8883", .verification.certificate = (const char *)mqtt_eclipse_org_pem_start, }, }; For details about other fields, please check the API Reference and TLS Server Verification. Client Credentials All client related credentials are under the credentials field. Authentication It is possible to set authentication parameters through the authentication field. The client supports the following authentication methods: password : use a password by setting certificate and key : mutual authentication with TLS, and both can be provided in PEM or DER format use_secure_element : use secure element available in ESP32-WROOM-32SE ds_data : use Digital Signature Peripheral available in some Espressif devices Session For MQTT session related configurations, session fields should be used. Last Will and Testament MQTT allows for a last will and testament (LWT) message to notify other clients when a client ungracefully disconnects. This is configured by the following fields in the last_will struct. Events The following events may be posted by the MQTT client: MQTT_EVENT_BEFORE_CONNECT : The client is initialized and about to start connecting to the broker. MQTT_EVENT_CONNECTED : The client has successfully established a connection to the broker. The client is now ready to send and receive data. MQTT_EVENT_DISCONNECTED : The client has aborted the connection due to being unable to read or write data, e.g., because the server is unavailable. MQTT_EVENT_SUBSCRIBED : The broker has acknowledged the client's subscribe request. The event data contains the message ID of the subscribe message. MQTT_EVENT_UNSUBSCRIBED : The broker has acknowledged the client's unsubscribe request. The event data contains the message ID of the unsubscribe message. MQTT_EVENT_PUBLISHED : The broker has acknowledged the client's publish message. This is only posted for QoS level 1 and 2, as level 0 does not use acknowledgements. The event data contains the message ID of the publish message. MQTT_EVENT_DATA : The client has received a publish message. The event data contains: message ID, name of the topic it was published to, received data and its length. For data that exceeds the internal buffer, multiple MQTT_EVENT_DATA events are posted and current_data_offset and total_data_len from event data updated to keep track of the fragmented message. MQTT_EVENT_ERROR : The client has encountered an error. The field error_handle in the event data contains error_type that can be used to identify the error. The type of error determines which parts of the error_handle struct is filled. API Reference Header File This header file can be included with: #include "mqtt_client.h" This header file is a part of the API provided by the mqtt component. To declare that your component depends on mqtt , add the following to your CMakeLists.txt: REQUIRES mqtt or PRIV_REQUIRES mqtt Functions esp_mqtt_client_handle_t esp_mqtt_client_init(const esp_mqtt_client_config_t *config) Creates MQTT client handle based on the configuration. Parameters config -- MQTT configuration structure Returns mqtt_client_handle if successfully created, NULL on error Parameters config -- MQTT configuration structure Returns mqtt_client_handle if successfully created, NULL on error esp_err_t esp_mqtt_client_set_uri(esp_mqtt_client_handle_t client, const char *uri) Sets MQTT connection URI. This API is usually used to overrides the URI configured in esp_mqtt_client_init. Parameters client -- MQTT client handle uri -- client -- MQTT client handle uri -- client -- MQTT client handle Returns ESP_FAIL if URI parse error, ESP_OK on success Parameters client -- MQTT client handle uri -- Returns ESP_FAIL if URI parse error, ESP_OK on success esp_err_t esp_mqtt_client_start(esp_mqtt_client_handle_t client) Starts MQTT client with already created client handle. Parameters client -- MQTT client handle Returns ESP_OK on success ESP_ERR_INVALID_ARG on wrong initialization ESP_FAIL on other error Parameters client -- MQTT client handle Returns ESP_OK on success ESP_ERR_INVALID_ARG on wrong initialization ESP_FAIL on other error esp_err_t esp_mqtt_client_reconnect(esp_mqtt_client_handle_t client) This api is typically used to force reconnection upon a specific event. Parameters client -- MQTT client handle Returns ESP_OK on success ESP_ERR_INVALID_ARG on wrong initialization ESP_FAIL if client is in invalid state Parameters client -- MQTT client handle Returns ESP_OK on success ESP_ERR_INVALID_ARG on wrong initialization ESP_FAIL if client is in invalid state esp_err_t esp_mqtt_client_disconnect(esp_mqtt_client_handle_t client) This api is typically used to force disconnection from the broker. Parameters client -- MQTT client handle Returns ESP_OK on success ESP_ERR_INVALID_ARG on wrong initialization Parameters client -- MQTT client handle Returns ESP_OK on success ESP_ERR_INVALID_ARG on wrong initialization esp_err_t esp_mqtt_client_stop(esp_mqtt_client_handle_t client) Stops MQTT client tasks. Notes: Cannot be called from the MQTT event handler Notes: Cannot be called from the MQTT event handler Parameters client -- MQTT client handle Returns ESP_OK on success ESP_ERR_INVALID_ARG on wrong initialization ESP_FAIL if client is in invalid state Parameters client -- MQTT client handle Returns ESP_OK on success ESP_ERR_INVALID_ARG on wrong initialization ESP_FAIL if client is in invalid state Notes: int esp_mqtt_client_subscribe_single(esp_mqtt_client_handle_t client, const char *topic, int qos) Subscribe the client to defined topic with defined qos. Notes: Client must be connected to send subscribe message This API is could be executed from a user task or from a MQTT event callback i.e. internal MQTT task (API is protected by internal mutex, so it might block if a longer data receive operation is in progress. esp_mqtt_client_subscribe could be used to call this function. Client must be connected to send subscribe message This API is could be executed from a user task or from a MQTT event callback i.e. internal MQTT task (API is protected by internal mutex, so it might block if a longer data receive operation is in progress. esp_mqtt_client_subscribe could be used to call this function. Parameters client -- MQTT client handle topic -- topic filter to subscribe qos -- Max qos level of the subscription client -- MQTT client handle topic -- topic filter to subscribe qos -- Max qos level of the subscription client -- MQTT client handle Returns message_id of the subscribe message on success -1 on failure -2 in case of full outbox. Parameters client -- MQTT client handle topic -- topic filter to subscribe qos -- Max qos level of the subscription Returns message_id of the subscribe message on success -1 on failure -2 in case of full outbox. Client must be connected to send subscribe message int esp_mqtt_client_subscribe_multiple(esp_mqtt_client_handle_t client, const esp_mqtt_topic_t *topic_list, int size) Subscribe the client to a list of defined topics with defined qos. Notes: Client must be connected to send subscribe message This API is could be executed from a user task or from a MQTT event callback i.e. internal MQTT task (API is protected by internal mutex, so it might block if a longer data receive operation is in progress. esp_mqtt_client_subscribe could be used to call this function. Client must be connected to send subscribe message This API is could be executed from a user task or from a MQTT event callback i.e. internal MQTT task (API is protected by internal mutex, so it might block if a longer data receive operation is in progress. esp_mqtt_client_subscribe could be used to call this function. Parameters client -- MQTT client handle topic_list -- List of topics to subscribe size -- size of topic_list client -- MQTT client handle topic_list -- List of topics to subscribe size -- size of topic_list client -- MQTT client handle Returns message_id of the subscribe message on success -1 on failure -2 in case of full outbox. Parameters client -- MQTT client handle topic_list -- List of topics to subscribe size -- size of topic_list Returns message_id of the subscribe message on success -1 on failure -2 in case of full outbox. Client must be connected to send subscribe message int esp_mqtt_client_unsubscribe(esp_mqtt_client_handle_t client, const char *topic) Unsubscribe the client from defined topic. Notes: Client must be connected to send unsubscribe message It is thread safe, please refer to esp_mqtt_client_subscribe_single for details Client must be connected to send unsubscribe message It is thread safe, please refer to esp_mqtt_client_subscribe_single for details Parameters client -- MQTT client handle topic -- client -- MQTT client handle topic -- client -- MQTT client handle Returns message_id of the subscribe message on success -1 on failure Parameters client -- MQTT client handle topic -- Returns message_id of the subscribe message on success -1 on failure Client must be connected to send unsubscribe message int esp_mqtt_client_publish(esp_mqtt_client_handle_t client, const char *topic, const char *data, int len, int qos, int retain) Client to send a publish message to the broker. Notes: This API might block for several seconds, either due to network timeout (10s) or if publishing payloads longer than internal buffer (due to message fragmentation) Client doesn't have to be connected for this API to work, enqueueing the messages with qos>1 (returning -1 for all the qos=0 messages if disconnected). If MQTT_SKIP_PUBLISH_IF_DISCONNECTED is enabled, this API will not attempt to publish when the client is not connected and will always return -1. It is thread safe, please refer to esp_mqtt_client_subscribe for details This API might block for several seconds, either due to network timeout (10s) or if publishing payloads longer than internal buffer (due to message fragmentation) Client doesn't have to be connected for this API to work, enqueueing the messages with qos>1 (returning -1 for all the qos=0 messages if disconnected). If MQTT_SKIP_PUBLISH_IF_DISCONNECTED is enabled, this API will not attempt to publish when the client is not connected and will always return -1. It is thread safe, please refer to esp_mqtt_client_subscribe for details Parameters client -- MQTT client handle topic -- topic string data -- payload string (set to NULL, sending empty payload message) len -- data length, if set to 0, length is calculated from payload string qos -- QoS of publish message retain -- retain flag client -- MQTT client handle topic -- topic string data -- payload string (set to NULL, sending empty payload message) len -- data length, if set to 0, length is calculated from payload string qos -- QoS of publish message retain -- retain flag client -- MQTT client handle Returns message_id of the publish message (for QoS 0 message_id will always be zero) on success. -1 on failure, -2 in case of full outbox. Parameters client -- MQTT client handle topic -- topic string data -- payload string (set to NULL, sending empty payload message) len -- data length, if set to 0, length is calculated from payload string qos -- QoS of publish message retain -- retain flag Returns message_id of the publish message (for QoS 0 message_id will always be zero) on success. -1 on failure, -2 in case of full outbox. This API might block for several seconds, either due to network timeout (10s) or if publishing payloads longer than internal buffer (due to message fragmentation) int esp_mqtt_client_enqueue(esp_mqtt_client_handle_t client, const char *topic, const char *data, int len, int qos, int retain, bool store) Enqueue a message to the outbox, to be sent later. Typically used for messages with qos>0, but could be also used for qos=0 messages if store=true. This API generates and stores the publish message into the internal outbox and the actual sending to the network is performed in the mqtt-task context (in contrast to the esp_mqtt_client_publish() which sends the publish message immediately in the user task's context). Thus, it could be used as a non blocking version of esp_mqtt_client_publish(). Parameters client -- MQTT client handle topic -- topic string data -- payload string (set to NULL, sending empty payload message) len -- data length, if set to 0, length is calculated from payload string qos -- QoS of publish message retain -- retain flag store -- if true, all messages are enqueued; otherwise only QoS 1 and QoS 2 are enqueued client -- MQTT client handle topic -- topic string data -- payload string (set to NULL, sending empty payload message) len -- data length, if set to 0, length is calculated from payload string qos -- QoS of publish message retain -- retain flag store -- if true, all messages are enqueued; otherwise only QoS 1 and QoS 2 are enqueued client -- MQTT client handle Returns message_id if queued successfully, -1 on failure, -2 in case of full outbox. Parameters client -- MQTT client handle topic -- topic string data -- payload string (set to NULL, sending empty payload message) len -- data length, if set to 0, length is calculated from payload string qos -- QoS of publish message retain -- retain flag store -- if true, all messages are enqueued; otherwise only QoS 1 and QoS 2 are enqueued Returns message_id if queued successfully, -1 on failure, -2 in case of full outbox. esp_err_t esp_mqtt_client_destroy(esp_mqtt_client_handle_t client) Destroys the client handle. Notes: Cannot be called from the MQTT event handler Cannot be called from the MQTT event handler Parameters client -- MQTT client handle Returns ESP_OK ESP_ERR_INVALID_ARG on wrong initialization Parameters client -- MQTT client handle Returns ESP_OK ESP_ERR_INVALID_ARG on wrong initialization Cannot be called from the MQTT event handler esp_err_t esp_mqtt_set_config(esp_mqtt_client_handle_t client, const esp_mqtt_client_config_t *config) Set configuration structure, typically used when updating the config (i.e. on "before_connect" event. Parameters client -- MQTT client handle config -- MQTT configuration structure client -- MQTT client handle config -- MQTT configuration structure client -- MQTT client handle Returns ESP_ERR_NO_MEM if failed to allocate ESP_ERR_INVALID_ARG if conflicts on transport configuration. ESP_OK on success Parameters client -- MQTT client handle config -- MQTT configuration structure Returns ESP_ERR_NO_MEM if failed to allocate ESP_ERR_INVALID_ARG if conflicts on transport configuration. ESP_OK on success esp_err_t esp_mqtt_client_register_event(esp_mqtt_client_handle_t client, esp_mqtt_event_id_t event, esp_event_handler_t event_handler, void *event_handler_arg) Registers MQTT event. Parameters client -- MQTT client handle event -- event type event_handler -- handler callback event_handler_arg -- handlers context client -- MQTT client handle event -- event type event_handler -- handler callback event_handler_arg -- handlers context client -- MQTT client handle Returns ESP_ERR_NO_MEM if failed to allocate ESP_ERR_INVALID_ARG on wrong initialization ESP_OK on success Parameters client -- MQTT client handle event -- event type event_handler -- handler callback event_handler_arg -- handlers context Returns ESP_ERR_NO_MEM if failed to allocate ESP_ERR_INVALID_ARG on wrong initialization ESP_OK on success esp_err_t esp_mqtt_client_unregister_event(esp_mqtt_client_handle_t client, esp_mqtt_event_id_t event, esp_event_handler_t event_handler) Unregisters mqtt event. Parameters client -- mqtt client handle event -- event ID event_handler -- handler to unregister client -- mqtt client handle event -- event ID event_handler -- handler to unregister client -- mqtt client handle Returns ESP_ERR_NO_MEM if failed to allocate ESP_ERR_INVALID_ARG on invalid event ID ESP_OK on success Parameters client -- mqtt client handle event -- event ID event_handler -- handler to unregister Returns ESP_ERR_NO_MEM if failed to allocate ESP_ERR_INVALID_ARG on invalid event ID ESP_OK on success int esp_mqtt_client_get_outbox_size(esp_mqtt_client_handle_t client) Get outbox size. Parameters client -- MQTT client handle Returns outbox size 0 on wrong initialization Parameters client -- MQTT client handle Returns outbox size 0 on wrong initialization esp_err_t esp_mqtt_dispatch_custom_event(esp_mqtt_client_handle_t client, esp_mqtt_event_t *event) Dispatch user event to the mqtt internal event loop. Parameters client -- MQTT client handle event -- MQTT event handle structure client -- MQTT client handle event -- MQTT event handle structure client -- MQTT client handle Returns ESP_OK on success ESP_ERR_TIMEOUT if the event couldn't be queued (ref also CONFIG_MQTT_EVENT_QUEUE_SIZE) Parameters client -- MQTT client handle event -- MQTT event handle structure Returns ESP_OK on success ESP_ERR_TIMEOUT if the event couldn't be queued (ref also CONFIG_MQTT_EVENT_QUEUE_SIZE) Structures struct esp_mqtt_error_codes 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 | Internal error reported from MQTT broker on connection | Public Members int esp_tls_stack_err tls specific error code reported from underlying tls stack int esp_tls_stack_err tls specific error code reported from underlying tls stack int esp_tls_cert_verify_flags tls flags reported from underlying tls stack during certificate verification int esp_tls_cert_verify_flags tls flags reported from underlying tls stack during certificate verification esp_mqtt_error_type_t error_type error type referring to the source of the error esp_mqtt_error_type_t error_type error type referring to the source of the error esp_mqtt_connect_return_code_t connect_return_code connection refused error code reported from MQTT* broker on connection esp_mqtt_connect_return_code_t connect_return_code connection refused error code reported from MQTT* broker on connection int esp_transport_sock_errno errno from the underlying socket int esp_transport_sock_errno errno from the underlying socket int esp_tls_stack_err struct esp_mqtt_event_t MQTT event configuration structure Public Members esp_mqtt_event_id_t event_id MQTT event type esp_mqtt_event_id_t event_id MQTT event type esp_mqtt_client_handle_t client MQTT client handle for this event esp_mqtt_client_handle_t client MQTT client handle for this event char *data Data associated with this event char *data Data associated with this event int data_len Length of the data for this event int data_len Length of the data for this event int total_data_len Total length of the data (longer data are supplied with multiple events) int total_data_len Total length of the data (longer data are supplied with multiple events) int current_data_offset Actual offset for the data associated with this event int current_data_offset Actual offset for the data associated with this event char *topic Topic associated with this event char *topic Topic associated with this event int topic_len Length of the topic for this event associated with this event int topic_len Length of the topic for this event associated with this event int msg_id MQTT messaged id of message int msg_id MQTT messaged id of message int session_present MQTT session_present flag for connection event int session_present MQTT session_present flag for connection event esp_mqtt_error_codes_t *error_handle esp-mqtt error handle including esp-tls errors as well as internal MQTT errors esp_mqtt_error_codes_t *error_handle esp-mqtt error handle including esp-tls errors as well as internal MQTT errors bool retain Retained flag of the message associated with this event bool retain Retained flag of the message associated with this event int qos QoS of the messages associated with this event int qos QoS of the messages associated with this event bool dup dup flag of the message associated with this event bool dup dup flag of the message associated with this event esp_mqtt_protocol_ver_t protocol_ver MQTT protocol version used for connection, defaults to value from menuconfig esp_mqtt_protocol_ver_t protocol_ver MQTT protocol version used for connection, defaults to value from menuconfig esp_mqtt_event_id_t event_id struct esp_mqtt_client_config_t MQTT client configuration structure Default values can be set via menuconfig All certificates and key data could be passed in PEM or DER format. PEM format must have a terminating NULL character and the related len field set to 0. DER format requires a related len field set to the correct length. Default values can be set via menuconfig All certificates and key data could be passed in PEM or DER format. PEM format must have a terminating NULL character and the related len field set to 0. DER format requires a related len field set to the correct length. Public Members struct esp_mqtt_client_config_t::broker_t broker Broker address and security verification struct esp_mqtt_client_config_t::broker_t broker Broker address and security verification struct esp_mqtt_client_config_t::credentials_t credentials User credentials for broker struct esp_mqtt_client_config_t::credentials_t credentials User credentials for broker struct esp_mqtt_client_config_t::session_t session MQTT session configuration. struct esp_mqtt_client_config_t::session_t session MQTT session configuration. struct esp_mqtt_client_config_t::network_t network Network configuration struct esp_mqtt_client_config_t::network_t network Network configuration struct esp_mqtt_client_config_t::task_t task FreeRTOS task configuration. struct esp_mqtt_client_config_t::task_t task FreeRTOS task configuration. struct esp_mqtt_client_config_t::buffer_t buffer Buffer size configuration. struct esp_mqtt_client_config_t::buffer_t buffer Buffer size configuration. struct esp_mqtt_client_config_t::outbox_config_t outbox Outbox configuration. struct esp_mqtt_client_config_t::outbox_config_t outbox Outbox configuration. struct broker_t Broker related configuration Public Members struct esp_mqtt_client_config_t::broker_t::address_t address Broker address configuration struct esp_mqtt_client_config_t::broker_t::address_t address Broker address configuration struct esp_mqtt_client_config_t::broker_t::verification_t verification Security verification of the broker struct esp_mqtt_client_config_t::broker_t::verification_t verification Security verification of the broker struct address_t Broker address uri have precedence over other fields If uri isn't set at least hostname, transport and port should. uri have precedence over other fields If uri isn't set at least hostname, transport and port should. uri have precedence over other fields struct address_t Broker address uri have precedence over other fields If uri isn't set at least hostname, transport and port should. struct verification_t Broker identity verification If fields are not set broker's identity isn't verified. it's recommended to set the options in this struct for security reasons. Public Members bool use_global_ca_store Use a global ca_store, look esp-tls documentation for details. bool use_global_ca_store Use a global ca_store, look esp-tls documentation for details. esp_err_t (*crt_bundle_attach)(void *conf) Pointer to ESP x509 Certificate Bundle attach function for the usage of certificate bundles. esp_err_t (*crt_bundle_attach)(void *conf) Pointer to ESP x509 Certificate Bundle attach function for the usage of certificate bundles. const char *certificate Certificate data, default is NULL, not required to verify the server. const char *certificate Certificate data, default is NULL, not required to verify the server. size_t certificate_len Length of the buffer pointed to by certificate. size_t certificate_len Length of the buffer pointed to by certificate. const struct psk_key_hint *psk_hint_key Pointer to PSK struct defined in esp_tls.h to enable PSK authentication (as alternative to certificate verification). PSK is enabled only if there are no other ways to verify broker. const struct psk_key_hint *psk_hint_key Pointer to PSK struct defined in esp_tls.h to enable PSK authentication (as alternative to certificate verification). PSK is enabled only if there are no other ways to verify broker. bool skip_cert_common_name_check Skip any validation of server certificate CN field, this reduces the security of TLS and makes the MQTT client susceptible to MITM attacks bool skip_cert_common_name_check Skip any validation of server certificate CN field, this reduces the security of TLS and makes the MQTT client susceptible to MITM attacks const char **alpn_protos NULL-terminated list of supported application protocols to be used for ALPN const char **alpn_protos NULL-terminated list of supported application protocols to be used for ALPN const char *common_name Pointer to the string containing server certificate common name. If non-NULL, server certificate CN must match this name, If NULL, server certificate CN must match hostname. This is ignored if skip_cert_common_name_check=true. const char *common_name Pointer to the string containing server certificate common name. If non-NULL, server certificate CN must match this name, If NULL, server certificate CN must match hostname. This is ignored if skip_cert_common_name_check=true. bool use_global_ca_store struct verification_t Broker identity verification If fields are not set broker's identity isn't verified. it's recommended to set the options in this struct for security reasons. Public Members bool use_global_ca_store Use a global ca_store, look esp-tls documentation for details. esp_err_t (*crt_bundle_attach)(void *conf) Pointer to ESP x509 Certificate Bundle attach function for the usage of certificate bundles. const char *certificate Certificate data, default is NULL, not required to verify the server. size_t certificate_len Length of the buffer pointed to by certificate. const struct psk_key_hint *psk_hint_key Pointer to PSK struct defined in esp_tls.h to enable PSK authentication (as alternative to certificate verification). PSK is enabled only if there are no other ways to verify broker. bool skip_cert_common_name_check Skip any validation of server certificate CN field, this reduces the security of TLS and makes the MQTT client susceptible to MITM attacks const char **alpn_protos NULL-terminated list of supported application protocols to be used for ALPN const char *common_name Pointer to the string containing server certificate common name. If non-NULL, server certificate CN must match this name, If NULL, server certificate CN must match hostname. This is ignored if skip_cert_common_name_check=true. struct esp_mqtt_client_config_t::broker_t::address_t address struct broker_t Broker related configuration Public Members struct esp_mqtt_client_config_t::broker_t::address_t address Broker address configuration struct esp_mqtt_client_config_t::broker_t::verification_t verification Security verification of the broker struct address_t Broker address uri have precedence over other fields If uri isn't set at least hostname, transport and port should. struct verification_t Broker identity verification If fields are not set broker's identity isn't verified. it's recommended to set the options in this struct for security reasons. Public Members bool use_global_ca_store Use a global ca_store, look esp-tls documentation for details. esp_err_t (*crt_bundle_attach)(void *conf) Pointer to ESP x509 Certificate Bundle attach function for the usage of certificate bundles. const char *certificate Certificate data, default is NULL, not required to verify the server. size_t certificate_len Length of the buffer pointed to by certificate. const struct psk_key_hint *psk_hint_key Pointer to PSK struct defined in esp_tls.h to enable PSK authentication (as alternative to certificate verification). PSK is enabled only if there are no other ways to verify broker. bool skip_cert_common_name_check Skip any validation of server certificate CN field, this reduces the security of TLS and makes the MQTT client susceptible to MITM attacks const char **alpn_protos NULL-terminated list of supported application protocols to be used for ALPN const char *common_name Pointer to the string containing server certificate common name. If non-NULL, server certificate CN must match this name, If NULL, server certificate CN must match hostname. This is ignored if skip_cert_common_name_check=true. struct buffer_t Client buffer size configuration Client have two buffers for input and output respectivelly. struct buffer_t Client buffer size configuration Client have two buffers for input and output respectivelly. struct credentials_t Client related credentials for authentication. Public Members const char *username MQTT username const char *username MQTT username const char *client_id Set MQTT client identifier. Ignored if set_null_client_id == true If NULL set the default client id. Default client id is ESP32_CHIPID% where CHIPID% are last 3 bytes of MAC address in hex format const char *client_id Set MQTT client identifier. Ignored if set_null_client_id == true If NULL set the default client id. Default client id is ESP32_CHIPID% where CHIPID% are last 3 bytes of MAC address in hex format bool set_null_client_id Selects a NULL client id bool set_null_client_id Selects a NULL client id struct esp_mqtt_client_config_t::credentials_t::authentication_t authentication Client authentication struct esp_mqtt_client_config_t::credentials_t::authentication_t authentication Client authentication struct authentication_t Client authentication Fields related to client authentication by broker For mutual authentication using TLS, user could select certificate and key, secure element or digital signature peripheral if available. Public Members const char *password MQTT password const char *password MQTT password const char *certificate Certificate for ssl mutual authentication, not required if mutual authentication is not needed. Must be provided with key . const char *certificate Certificate for ssl mutual authentication, not required if mutual authentication is not needed. Must be provided with key . size_t certificate_len Length of the buffer pointed to by certificate. size_t certificate_len Length of the buffer pointed to by certificate. const char *key Private key for SSL mutual authentication, not required if mutual authentication is not needed. If it is not NULL, also certificate has to be provided. const char *key Private key for SSL mutual authentication, not required if mutual authentication is not needed. If it is not NULL, also certificate has to be provided. size_t key_len Length of the buffer pointed to by key. size_t key_len Length of the buffer pointed to by key. const char *key_password Client key decryption password, not PEM nor DER, if provided key_password_len must be correctly set. const char *key_password Client key decryption password, not PEM nor DER, if provided key_password_len must be correctly set. int key_password_len Length of the password pointed to by key_password int key_password_len Length of the password pointed to by key_password bool use_secure_element Enable secure element, available in ESP32-ROOM-32SE, for SSL connection bool use_secure_element Enable secure element, available in ESP32-ROOM-32SE, for SSL connection void *ds_data Carrier of handle for digital signature parameters, digital signature peripheral is available in some Espressif devices. void *ds_data Carrier of handle for digital signature parameters, digital signature peripheral is available in some Espressif devices. const char *password struct authentication_t Client authentication Fields related to client authentication by broker For mutual authentication using TLS, user could select certificate and key, secure element or digital signature peripheral if available. Public Members const char *password MQTT password const char *certificate Certificate for ssl mutual authentication, not required if mutual authentication is not needed. Must be provided with key . size_t certificate_len Length of the buffer pointed to by certificate. const char *key Private key for SSL mutual authentication, not required if mutual authentication is not needed. If it is not NULL, also certificate has to be provided. size_t key_len Length of the buffer pointed to by key. const char *key_password Client key decryption password, not PEM nor DER, if provided key_password_len must be correctly set. int key_password_len Length of the password pointed to by key_password bool use_secure_element Enable secure element, available in ESP32-ROOM-32SE, for SSL connection void *ds_data Carrier of handle for digital signature parameters, digital signature peripheral is available in some Espressif devices. const char *username struct credentials_t Client related credentials for authentication. Public Members const char *username MQTT username const char *client_id Set MQTT client identifier. Ignored if set_null_client_id == true If NULL set the default client id. Default client id is ESP32_CHIPID% where CHIPID% are last 3 bytes of MAC address in hex format bool set_null_client_id Selects a NULL client id struct esp_mqtt_client_config_t::credentials_t::authentication_t authentication Client authentication struct authentication_t Client authentication Fields related to client authentication by broker For mutual authentication using TLS, user could select certificate and key, secure element or digital signature peripheral if available. Public Members const char *password MQTT password const char *certificate Certificate for ssl mutual authentication, not required if mutual authentication is not needed. Must be provided with key . size_t certificate_len Length of the buffer pointed to by certificate. const char *key Private key for SSL mutual authentication, not required if mutual authentication is not needed. If it is not NULL, also certificate has to be provided. size_t key_len Length of the buffer pointed to by key. const char *key_password Client key decryption password, not PEM nor DER, if provided key_password_len must be correctly set. int key_password_len Length of the password pointed to by key_password bool use_secure_element Enable secure element, available in ESP32-ROOM-32SE, for SSL connection void *ds_data Carrier of handle for digital signature parameters, digital signature peripheral is available in some Espressif devices. struct network_t Network related configuration Public Members int reconnect_timeout_ms Reconnect to the broker after this value in miliseconds if auto reconnect is not disabled (defaults to 10s) int reconnect_timeout_ms Reconnect to the broker after this value in miliseconds if auto reconnect is not disabled (defaults to 10s) int timeout_ms Abort network operation if it is not completed after this value, in milliseconds (defaults to 10s). int timeout_ms Abort network operation if it is not completed after this value, in milliseconds (defaults to 10s). int refresh_connection_after_ms Refresh connection after this value (in milliseconds) int refresh_connection_after_ms Refresh connection after this value (in milliseconds) bool disable_auto_reconnect Client will reconnect to server (when errors/disconnect). Set disable_auto_reconnect=true to disable bool disable_auto_reconnect Client will reconnect to server (when errors/disconnect). Set disable_auto_reconnect=true to disable esp_transport_handle_t transport Custom transport handle to use. Warning: The transport should be valid during the client lifetime and is destroyed when esp_mqtt_client_destroy is called. esp_transport_handle_t transport Custom transport handle to use. Warning: The transport should be valid during the client lifetime and is destroyed when esp_mqtt_client_destroy is called. struct ifreq *if_name The name of interface for data to go through. Use the default interface without setting struct ifreq *if_name The name of interface for data to go through. Use the default interface without setting int reconnect_timeout_ms struct network_t Network related configuration Public Members int reconnect_timeout_ms Reconnect to the broker after this value in miliseconds if auto reconnect is not disabled (defaults to 10s) int timeout_ms Abort network operation if it is not completed after this value, in milliseconds (defaults to 10s). int refresh_connection_after_ms Refresh connection after this value (in milliseconds) bool disable_auto_reconnect Client will reconnect to server (when errors/disconnect). Set disable_auto_reconnect=true to disable esp_transport_handle_t transport Custom transport handle to use. Warning: The transport should be valid during the client lifetime and is destroyed when esp_mqtt_client_destroy is called. struct ifreq *if_name The name of interface for data to go through. Use the default interface without setting struct outbox_config_t Client outbox configuration options. Public Members uint64_t limit Size limit for the outbox in bytes. uint64_t limit Size limit for the outbox in bytes. uint64_t limit struct outbox_config_t Client outbox configuration options. Public Members uint64_t limit Size limit for the outbox in bytes. struct session_t MQTT Session related configuration Public Members struct esp_mqtt_client_config_t::session_t::last_will_t last_will Last will configuration struct esp_mqtt_client_config_t::session_t::last_will_t last_will Last will configuration bool disable_clean_session MQTT clean session, default clean_session is true bool disable_clean_session MQTT clean session, default clean_session is true int keepalive MQTT keepalive, default is 120 seconds When configuring this value, keep in mind that the client attempts to communicate with the broker at half the interval that is actually set. This conservative approach allows for more attempts before the broker's timeout occurs int keepalive MQTT keepalive, default is 120 seconds When configuring this value, keep in mind that the client attempts to communicate with the broker at half the interval that is actually set. This conservative approach allows for more attempts before the broker's timeout occurs bool disable_keepalive Set disable_keepalive=true to turn off keep-alive mechanism, keepalive is active by default. Note: setting the config value keepalive to 0 doesn't disable keepalive feature, but uses a default keepalive period bool disable_keepalive Set disable_keepalive=true to turn off keep-alive mechanism, keepalive is active by default. Note: setting the config value keepalive to 0 doesn't disable keepalive feature, but uses a default keepalive period esp_mqtt_protocol_ver_t protocol_ver MQTT protocol version used for connection. esp_mqtt_protocol_ver_t protocol_ver MQTT protocol version used for connection. int message_retransmit_timeout timeout for retransmitting of failed packet int message_retransmit_timeout timeout for retransmitting of failed packet struct last_will_t Last Will and Testament message configuration. struct last_will_t Last Will and Testament message configuration. struct esp_mqtt_client_config_t::session_t::last_will_t last_will struct session_t MQTT Session related configuration Public Members struct esp_mqtt_client_config_t::session_t::last_will_t last_will Last will configuration bool disable_clean_session MQTT clean session, default clean_session is true int keepalive MQTT keepalive, default is 120 seconds When configuring this value, keep in mind that the client attempts to communicate with the broker at half the interval that is actually set. This conservative approach allows for more attempts before the broker's timeout occurs bool disable_keepalive Set disable_keepalive=true to turn off keep-alive mechanism, keepalive is active by default. Note: setting the config value keepalive to 0 doesn't disable keepalive feature, but uses a default keepalive period esp_mqtt_protocol_ver_t protocol_ver MQTT protocol version used for connection. int message_retransmit_timeout timeout for retransmitting of failed packet struct last_will_t Last Will and Testament message configuration. struct task_t Client task configuration struct task_t Client task configuration Default values can be set via menuconfig struct topic_t Topic definition struct Macros MQTT_ERROR_TYPE_ESP_TLS MQTT_ERROR_TYPE_TCP_TRANSPORT error type hold all sorts of transport layer errors, including ESP-TLS error, but in the past only the errors from MQTT_ERROR_TYPE_ESP_TLS layer were reported, so the ESP-TLS error type is re-defined here for backward compatibility esp_mqtt_client_subscribe(client_handle, topic_type, qos_or_size) Convenience macro to select subscribe function to use. Notes: Usage of esp_mqtt_client_subscribe_single is the same as previous esp_mqtt_client_subscribe, refer to it for details. Usage of esp_mqtt_client_subscribe_single is the same as previous esp_mqtt_client_subscribe, refer to it for details. Parameters client_handle -- MQTT client handle topic_type -- Needs to be char* for single subscription or esp_mqtt_topic_t for multiple topics qos_or_size -- It's either a qos when subscribing to a single topic or the size of the subscription array when subscribing to multiple topics. client_handle -- MQTT client handle topic_type -- Needs to be char* for single subscription or esp_mqtt_topic_t for multiple topics qos_or_size -- It's either a qos when subscribing to a single topic or the size of the subscription array when subscribing to multiple topics. client_handle -- MQTT client handle Returns message_id of the subscribe message on success -1 on failure -2 in case of full outbox. Parameters client_handle -- MQTT client handle topic_type -- Needs to be char* for single subscription or esp_mqtt_topic_t for multiple topics qos_or_size -- It's either a qos when subscribing to a single topic or the size of the subscription array when subscribing to multiple topics. Returns message_id of the subscribe message on success -1 on failure -2 in case of full outbox. Usage of esp_mqtt_client_subscribe_single is the same as previous esp_mqtt_client_subscribe, refer to it for details. Type Definitions typedef struct esp_mqtt_client *esp_mqtt_client_handle_t typedef enum esp_mqtt_event_id_t esp_mqtt_event_id_t MQTT event types. User event handler receives context data in esp_mqtt_event_t structure with client - MQTT client handle various other data depending on event type client - MQTT client handle various other data depending on event type client - MQTT client handle typedef enum esp_mqtt_connect_return_code_t esp_mqtt_connect_return_code_t MQTT connection error codes propagated via ERROR event typedef enum esp_mqtt_error_type_t esp_mqtt_error_type_t MQTT connection error codes propagated via ERROR event typedef enum esp_mqtt_transport_t esp_mqtt_transport_t typedef enum esp_mqtt_protocol_ver_t esp_mqtt_protocol_ver_t MQTT protocol version used for connection 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 | Internal error reported from MQTT broker on connection | typedef struct esp_mqtt_event_t esp_mqtt_event_t MQTT event configuration structure typedef esp_mqtt_event_t *esp_mqtt_event_handle_t typedef struct esp_mqtt_client_config_t esp_mqtt_client_config_t MQTT client configuration structure Default values can be set via menuconfig All certificates and key data could be passed in PEM or DER format. PEM format must have a terminating NULL character and the related len field set to 0. DER format requires a related len field set to the correct length. Default values can be set via menuconfig All certificates and key data could be passed in PEM or DER format. PEM format must have a terminating NULL character and the related len field set to 0. DER format requires a related len field set to the correct length. Default values can be set via menuconfig Enumerations enum esp_mqtt_event_id_t MQTT event types. User event handler receives context data in esp_mqtt_event_t structure with client - MQTT client handle various other data depending on event type client - MQTT client handle various other data depending on event type Values: enumerator MQTT_EVENT_ANY enumerator MQTT_EVENT_ANY enumerator MQTT_EVENT_ERROR on error event, additional context: connection return code, error handle from esp_tls (if supported) enumerator MQTT_EVENT_ERROR on error event, additional context: connection return code, error handle from esp_tls (if supported) enumerator MQTT_EVENT_CONNECTED connected event, additional context: session_present flag enumerator MQTT_EVENT_CONNECTED connected event, additional context: session_present flag enumerator MQTT_EVENT_DISCONNECTED disconnected event enumerator MQTT_EVENT_DISCONNECTED disconnected event enumerator MQTT_EVENT_SUBSCRIBED subscribed event, additional context: msg_id message id error_handle error_type in case subscribing failed data pointer to broker response, check for errors. data_len length of the data for this event msg_id message id error_handle error_type in case subscribing failed data pointer to broker response, check for errors. data_len length of the data for this event msg_id message id enumerator MQTT_EVENT_SUBSCRIBED subscribed event, additional context: msg_id message id error_handle error_type in case subscribing failed data pointer to broker response, check for errors. data_len length of the data for this event enumerator MQTT_EVENT_UNSUBSCRIBED unsubscribed event, additional context: msg_id enumerator MQTT_EVENT_UNSUBSCRIBED unsubscribed event, additional context: msg_id enumerator MQTT_EVENT_PUBLISHED published event, additional context: msg_id enumerator MQTT_EVENT_PUBLISHED published event, additional context: msg_id enumerator 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 qos QoS level of the message dup dup 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. 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 qos QoS level of the message dup dup 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. msg_id message id enumerator 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 qos QoS level of the message dup dup 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. enumerator MQTT_EVENT_BEFORE_CONNECT The event occurs before connecting enumerator MQTT_EVENT_BEFORE_CONNECT The event occurs before connecting enumerator MQTT_EVENT_DELETED Notification on delete of one message from the internal outbox, if the message couldn't have been sent and acknowledged before expiring defined in OUTBOX_EXPIRED_TIMEOUT_MS. (events are not posted upon deletion of successfully acknowledged messages) This event id is posted only if MQTT_REPORT_DELETED_MESSAGES==1 Additional context: msg_id (id of the deleted message). This event id is posted only if MQTT_REPORT_DELETED_MESSAGES==1 Additional context: msg_id (id of the deleted message). This event id is posted only if MQTT_REPORT_DELETED_MESSAGES==1 enumerator MQTT_EVENT_DELETED Notification on delete of one message from the internal outbox, if the message couldn't have been sent and acknowledged before expiring defined in OUTBOX_EXPIRED_TIMEOUT_MS. (events are not posted upon deletion of successfully acknowledged messages) This event id is posted only if MQTT_REPORT_DELETED_MESSAGES==1 Additional context: msg_id (id of the deleted message). enumerator MQTT_USER_EVENT Custom event used to queue tasks into mqtt event handler All fields from the esp_mqtt_event_t type could be used to pass an additional context data to the handler. enumerator MQTT_USER_EVENT Custom event used to queue tasks into mqtt event handler All fields from the esp_mqtt_event_t type could be used to pass an additional context data to the handler. client - MQTT client handle enum esp_mqtt_connect_return_code_t MQTT connection error codes propagated via ERROR event Values: enumerator MQTT_CONNECTION_ACCEPTED Connection accepted enumerator MQTT_CONNECTION_ACCEPTED Connection accepted enumerator MQTT_CONNECTION_REFUSE_PROTOCOL MQTT connection refused reason: Wrong protocol enumerator MQTT_CONNECTION_REFUSE_PROTOCOL MQTT connection refused reason: Wrong protocol enumerator MQTT_CONNECTION_REFUSE_ID_REJECTED MQTT connection refused reason: ID rejected enumerator MQTT_CONNECTION_REFUSE_ID_REJECTED MQTT connection refused reason: ID rejected enumerator MQTT_CONNECTION_REFUSE_SERVER_UNAVAILABLE MQTT connection refused reason: Server unavailable enumerator MQTT_CONNECTION_REFUSE_SERVER_UNAVAILABLE MQTT connection refused reason: Server unavailable enumerator MQTT_CONNECTION_REFUSE_BAD_USERNAME MQTT connection refused reason: Wrong user enumerator MQTT_CONNECTION_REFUSE_BAD_USERNAME MQTT connection refused reason: Wrong user enumerator MQTT_CONNECTION_REFUSE_NOT_AUTHORIZED MQTT connection refused reason: Wrong username or password enumerator MQTT_CONNECTION_REFUSE_NOT_AUTHORIZED MQTT connection refused reason: Wrong username or password enumerator MQTT_CONNECTION_ACCEPTED enum esp_mqtt_error_type_t MQTT connection error codes propagated via ERROR event Values: enumerator MQTT_ERROR_TYPE_NONE enumerator MQTT_ERROR_TYPE_NONE enumerator MQTT_ERROR_TYPE_TCP_TRANSPORT enumerator MQTT_ERROR_TYPE_TCP_TRANSPORT enumerator MQTT_ERROR_TYPE_CONNECTION_REFUSED enumerator MQTT_ERROR_TYPE_CONNECTION_REFUSED enumerator MQTT_ERROR_TYPE_SUBSCRIBE_FAILED enumerator MQTT_ERROR_TYPE_SUBSCRIBE_FAILED enumerator MQTT_ERROR_TYPE_NONE enum esp_mqtt_transport_t Values: enumerator MQTT_TRANSPORT_UNKNOWN enumerator MQTT_TRANSPORT_UNKNOWN enumerator MQTT_TRANSPORT_OVER_TCP MQTT over TCP, using scheme: MQTT enumerator MQTT_TRANSPORT_OVER_TCP MQTT over TCP, using scheme: MQTT enumerator MQTT_TRANSPORT_OVER_SSL MQTT over SSL, using scheme: MQTTS enumerator MQTT_TRANSPORT_OVER_SSL MQTT over SSL, using scheme: MQTTS enumerator MQTT_TRANSPORT_OVER_WS MQTT over Websocket, using scheme:: ws enumerator MQTT_TRANSPORT_OVER_WS MQTT over Websocket, using scheme:: ws enumerator MQTT_TRANSPORT_OVER_WSS MQTT over Websocket Secure, using scheme: wss enumerator MQTT_TRANSPORT_OVER_WSS MQTT over Websocket Secure, using scheme: wss enumerator MQTT_TRANSPORT_UNKNOWN(...TRUNCATED)
ESP-MQTT Overview ESP-MQTT is an implementation of MQTT protocol client, which is a lightweight publish/subscribe messaging protocol. Now ESP-MQTT supports MQTT v5.0. Features - Support MQTT over TCP, SSL with Mbed TLS, MQTT over WebSocket, and MQTT over WebSocket Secure - Easy to setup with URI - Multiple instances (multiple clients in one application) - Support subscribing, publishing, authentication, last will messages, keep alive pings, and all 3 Quality of Service (QoS) levels (it should be a fully functional client) Application Examples - protocols/mqtt/tcp: MQTT over TCP, default port 1883 - protocols/mqtt/ssl: MQTT over TLS, default port 8883 - protocols/mqtt/ssl_ds: MQTT over TLS using digital signature peripheral for authentication, default port 8883 - protocols/mqtt/ssl_mutual_auth: MQTT over TLS using certificates for authentication, default port 8883 - protocols/mqtt/ssl_psk: MQTT over TLS using pre-shared keys for authentication, default port 8883 - protocols/mqtt/ws: MQTT over WebSocket, default port 80 - protocols/mqtt/wss: MQTT over WebSocket Secure, default port 443 - protocols/mqtt5: Uses ESP-MQTT library to connect to broker with MQTT v5.0 MQTT Message Retransmission A new MQTT message is created by calling esp_mqtt_client_publish or its non blocking counterpart esp_mqtt_client_enqueue. Messages with QoS 0 is sent only once. QoS 1 and 2 have different behaviors since the protocol requires extra steps to complete the process. The ESP-MQTT library opts to always retransmit unacknowledged QoS 1 and 2 publish messages to avoid losses in faulty connections, even though the MQTT specification requires the re-transmission only on reconnect with Clean Session flag been set to 0 (set disable_clean_session to true for this behavior). QoS 1 and 2 messages that may need retransmission are always enqueued, but first transmission try occurs immediately if esp_mqtt_client_publish is used. A transmission retry for unacknowledged messages will occur after message_retransmit_timeout. After CONFIG_MQTT_OUTBOX_EXPIRED_TIMEOUT_MS messages will expire and be deleted. If CONFIG_MQTT_REPORT_DELETED_MESSAGES is set, an event will be sent to notify the user. Configuration The configuration is made by setting fields in esp_mqtt_client_config_t struct. The configuration struct has the following sub structs to configure different aspects of the client operation. - esp_mqtt_client_config_t::broker_t- Allow to set address and security verification. - esp_mqtt_client_config_t::credentials_t- Client credentials for authentication. - esp_mqtt_client_config_t::session_t- Configuration for MQTT session aspects. - esp_mqtt_client_config_t::network_t- Networking related configuration. - esp_mqtt_client_config_t::task_t- Allow to configure FreeRTOS task. - esp_mqtt_client_config_t::buffer_t- Buffer size for input and output. In the following sections, the most common aspects are detailed. Broker Address Broker address can be set by usage of address struct. The configuration can be made by usage of uri field or the combination of hostname, transport and port. Optionally, path could be set, this field is useful in WebSocket connections. The uri field is used in the format scheme://hostname:port/path. Curently support mqtt, mqtts, ws, wssschemes MQTT over TCP samples: mqtt://mqtt.eclipseprojects.io: MQTT over TCP, default port 1883 mqtt://mqtt.eclipseprojects.io:1884: MQTT over TCP, port 1884 mqtt://username:password@mqtt.eclipseprojects.io:1884: MQTT over TCP, port 1884, with username and password - MQTT over SSL samples: mqtts://mqtt.eclipseprojects.io: MQTT over SSL, port 8883 mqtts://mqtt.eclipseprojects.io:8884: MQTT over SSL, port 8884 - MQTT over WebSocket samples: ws://mqtt.eclipseprojects.io:80/mqtt - MQTT over WebSocket Secure samples: wss://mqtt.eclipseprojects.io:443/mqtt - Minimal configurations: const esp_mqtt_client_config_t mqtt_cfg = { .broker.address.uri = "mqtt://mqtt.eclipseprojects.io", }; esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg); esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, client); esp_mqtt_client_start(client); Note By default MQTT client uses event loop library to post related MQTT events (connected, subscribed, published, etc.). Verification For secure connections with TLS used, and to guarantee Broker's identity, the verification struct must be set. The broker certificate may be set in PEM or DER format. To select DER, the equivalent certificate_len field must be set. Otherwise, a null-terminated string in PEM format should be provided to certificate field. - Get certificate from server, example: mqtt.eclipseprojects.io openssl s_client -showcerts -connect mqtt.eclipseprojects.io:8883 < /dev/null \ 2> /dev/null | openssl x509 -outform PEM > mqtt_eclipse_org.pem - Get certificate from server, example: Check the sample application: protocols/mqtt/ssl Configuration: const esp_mqtt_client_config_t mqtt_cfg = { .broker = { .address.uri = "mqtts://mqtt.eclipseprojects.io:8883", .verification.certificate = (const char *)mqtt_eclipse_org_pem_start, }, }; For details about other fields, please check the API Reference and TLS Server Verification. Client Credentials All client related credentials are under the credentials field. Authentication It is possible to set authentication parameters through the authentication field. The client supports the following authentication methods: - password: use a password by setting - certificateand key: mutual authentication with TLS, and both can be provided in PEM or DER format - use_secure_element: use secure element available in ESP32-WROOM-32SE - ds_data: use Digital Signature Peripheral available in some Espressif devices Session For MQTT session related configurations, session fields should be used. Last Will and Testament MQTT allows for a last will and testament (LWT) message to notify other clients when a client ungracefully disconnects. This is configured by the following fields in the last_will struct. Events The following events may be posted by the MQTT client: MQTT_EVENT_BEFORE_CONNECT: The client is initialized and about to start connecting to the broker. MQTT_EVENT_CONNECTED: The client has successfully established a connection to the broker. The client is now ready to send and receive data. MQTT_EVENT_DISCONNECTED: The client has aborted the connection due to being unable to read or write data, e.g., because the server is unavailable. MQTT_EVENT_SUBSCRIBED: The broker has acknowledged the client's subscribe request. The event data contains the message ID of the subscribe message. MQTT_EVENT_UNSUBSCRIBED: The broker has acknowledged the client's unsubscribe request. The event data contains the message ID of the unsubscribe message. MQTT_EVENT_PUBLISHED: The broker has acknowledged the client's publish message. This is only posted for QoS level 1 and 2, as level 0 does not use acknowledgements. The event data contains the message ID of the publish message. MQTT_EVENT_DATA: The client has received a publish message. The event data contains: message ID, name of the topic it was published to, received data and its length. For data that exceeds the internal buffer, multiple MQTT_EVENT_DATAevents are posted and current_data_offsetand total_data_lenfrom event data updated to keep track of the fragmented message. MQTT_EVENT_ERROR: The client has encountered an error. The field error_handlein the event data contains error_typethat can be used to identify the error. The type of error determines which parts of the error_handlestruct is filled. API Reference Header File This header file can be included with: #include "mqtt_client.h" This header file is a part of the API provided by the mqttcomponent. To declare that your component depends on mqtt, add the following to your CMakeLists.txt: REQUIRES mqtt or PRIV_REQUIRES mqtt Functions - esp_mqtt_client_handle_t esp_mqtt_client_init(const esp_mqtt_client_config_t *config) Creates MQTT client handle based on the configuration. - Parameters config -- MQTT configuration structure - Returns mqtt_client_handle if successfully created, NULL on error - esp_err_t esp_mqtt_client_set_uri(esp_mqtt_client_handle_t client, const char *uri) Sets MQTT connection URI. This API is usually used to overrides the URI configured in esp_mqtt_client_init. - Parameters client -- MQTT client handle uri -- - - Returns ESP_FAIL if URI parse error, ESP_OK on success - esp_err_t esp_mqtt_client_start(esp_mqtt_client_handle_t client) Starts MQTT client with already created client handle. - Parameters client -- MQTT client handle - Returns ESP_OK on success ESP_ERR_INVALID_ARG on wrong initialization ESP_FAIL on other error - esp_err_t esp_mqtt_client_reconnect(esp_mqtt_client_handle_t client) This api is typically used to force reconnection upon a specific event. - Parameters client -- MQTT client handle - Returns ESP_OK on success ESP_ERR_INVALID_ARG on wrong initialization ESP_FAIL if client is in invalid state - esp_err_t esp_mqtt_client_disconnect(esp_mqtt_client_handle_t client) This api is typically used to force disconnection from the broker. - Parameters client -- MQTT client handle - Returns ESP_OK on success ESP_ERR_INVALID_ARG on wrong initialization - esp_err_t esp_mqtt_client_stop(esp_mqtt_client_handle_t client) Stops MQTT client tasks. Notes: Cannot be called from the MQTT event handler - Parameters client -- MQTT client handle - Returns ESP_OK on success ESP_ERR_INVALID_ARG on wrong initialization ESP_FAIL if client is in invalid state - - int esp_mqtt_client_subscribe_single(esp_mqtt_client_handle_t client, const char *topic, int qos) Subscribe the client to defined topic with defined qos. Notes: Client must be connected to send subscribe message This API is could be executed from a user task or from a MQTT event callback i.e. internal MQTT task (API is protected by internal mutex, so it might block if a longer data receive operation is in progress. esp_mqtt_client_subscribecould be used to call this function. - Parameters client -- MQTT client handle topic -- topic filter to subscribe qos -- Max qos level of the subscription - - Returns message_id of the subscribe message on success -1 on failure -2 in case of full outbox. - - int esp_mqtt_client_subscribe_multiple(esp_mqtt_client_handle_t client, const esp_mqtt_topic_t *topic_list, int size) Subscribe the client to a list of defined topics with defined qos. Notes: Client must be connected to send subscribe message This API is could be executed from a user task or from a MQTT event callback i.e. internal MQTT task (API is protected by internal mutex, so it might block if a longer data receive operation is in progress. esp_mqtt_client_subscribecould be used to call this function. - Parameters client -- MQTT client handle topic_list -- List of topics to subscribe size -- size of topic_list - - Returns message_id of the subscribe message on success -1 on failure -2 in case of full outbox. - - int esp_mqtt_client_unsubscribe(esp_mqtt_client_handle_t client, const char *topic) Unsubscribe the client from defined topic. Notes: Client must be connected to send unsubscribe message It is thread safe, please refer to esp_mqtt_client_subscribe_singlefor details - Parameters client -- MQTT client handle topic -- - - Returns message_id of the subscribe message on success -1 on failure - - int esp_mqtt_client_publish(esp_mqtt_client_handle_t client, const char *topic, const char *data, int len, int qos, int retain) Client to send a publish message to the broker. Notes: This API might block for several seconds, either due to network timeout (10s) or if publishing payloads longer than internal buffer (due to message fragmentation) Client doesn't have to be connected for this API to work, enqueueing the messages with qos>1 (returning -1 for all the qos=0 messages if disconnected). If MQTT_SKIP_PUBLISH_IF_DISCONNECTED is enabled, this API will not attempt to publish when the client is not connected and will always return -1. It is thread safe, please refer to esp_mqtt_client_subscribefor details - Parameters client -- MQTT client handle topic -- topic string data -- payload string (set to NULL, sending empty payload message) len -- data length, if set to 0, length is calculated from payload string qos -- QoS of publish message retain -- retain flag - - Returns message_id of the publish message (for QoS 0 message_id will always be zero) on success. -1 on failure, -2 in case of full outbox. - - int esp_mqtt_client_enqueue(esp_mqtt_client_handle_t client, const char *topic, const char *data, int len, int qos, int retain, bool store) Enqueue a message to the outbox, to be sent later. Typically used for messages with qos>0, but could be also used for qos=0 messages if store=true. This API generates and stores the publish message into the internal outbox and the actual sending to the network is performed in the mqtt-task context (in contrast to the esp_mqtt_client_publish() which sends the publish message immediately in the user task's context). Thus, it could be used as a non blocking version of esp_mqtt_client_publish(). - Parameters client -- MQTT client handle topic -- topic string data -- payload string (set to NULL, sending empty payload message) len -- data length, if set to 0, length is calculated from payload string qos -- QoS of publish message retain -- retain flag store -- if true, all messages are enqueued; otherwise only QoS 1 and QoS 2 are enqueued - - Returns message_id if queued successfully, -1 on failure, -2 in case of full outbox. - esp_err_t esp_mqtt_client_destroy(esp_mqtt_client_handle_t client) Destroys the client handle. Notes: Cannot be called from the MQTT event handler - Parameters client -- MQTT client handle - Returns ESP_OK ESP_ERR_INVALID_ARG on wrong initialization - - esp_err_t esp_mqtt_set_config(esp_mqtt_client_handle_t client, const esp_mqtt_client_config_t *config) Set configuration structure, typically used when updating the config (i.e. on "before_connect" event. - Parameters client -- MQTT client handle config -- MQTT configuration structure - - Returns ESP_ERR_NO_MEM if failed to allocate ESP_ERR_INVALID_ARG if conflicts on transport configuration. ESP_OK on success - esp_err_t esp_mqtt_client_register_event(esp_mqtt_client_handle_t client, esp_mqtt_event_id_t event, esp_event_handler_t event_handler, void *event_handler_arg) Registers MQTT event. - Parameters client -- MQTT client handle event -- event type event_handler -- handler callback event_handler_arg -- handlers context - - Returns ESP_ERR_NO_MEM if failed to allocate ESP_ERR_INVALID_ARG on wrong initialization ESP_OK on success - esp_err_t esp_mqtt_client_unregister_event(esp_mqtt_client_handle_t client, esp_mqtt_event_id_t event, esp_event_handler_t event_handler) Unregisters mqtt event. - Parameters client -- mqtt client handle event -- event ID event_handler -- handler to unregister - - Returns ESP_ERR_NO_MEM if failed to allocate ESP_ERR_INVALID_ARG on invalid event ID ESP_OK on success - int esp_mqtt_client_get_outbox_size(esp_mqtt_client_handle_t client) Get outbox size. - Parameters client -- MQTT client handle - Returns outbox size 0 on wrong initialization - esp_err_t esp_mqtt_dispatch_custom_event(esp_mqtt_client_handle_t client, esp_mqtt_event_t *event) Dispatch user event to the mqtt internal event loop. - Parameters client -- MQTT client handle event -- MQTT event handle structure - - Returns ESP_OK on success ESP_ERR_TIMEOUT if the event couldn't be queued (ref also CONFIG_MQTT_EVENT_QUEUE_SIZE) Structures - struct esp_mqtt_error_codes MQTT error code structure to be passed as a contextual information into ERROR event Important: This structure extends esp_tls_last_errorerror structure and is backward compatible with it (so might be down-casted and treated as esp_tls_last_errorerror, 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 | Internal error reported from MQTT broker on connection | Public Members - int esp_tls_stack_err tls specific error code reported from underlying tls stack - int esp_tls_cert_verify_flags tls flags reported from underlying tls stack during certificate verification - esp_mqtt_error_type_t error_type error type referring to the source of the error - esp_mqtt_connect_return_code_t connect_return_code connection refused error code reported from MQTT* broker on connection - int esp_transport_sock_errno errno from the underlying socket - int esp_tls_stack_err - struct esp_mqtt_event_t MQTT event configuration structure Public Members - esp_mqtt_event_id_t event_id MQTT event type - esp_mqtt_client_handle_t client MQTT client handle for this event - char *data Data associated with this event - int data_len Length of the data for this event - int total_data_len Total length of the data (longer data are supplied with multiple events) - int current_data_offset Actual offset for the data associated with this event - char *topic Topic associated with this event - int topic_len Length of the topic for this event associated with this event - int msg_id MQTT messaged id of message - int session_present MQTT session_present flag for connection event - esp_mqtt_error_codes_t *error_handle esp-mqtt error handle including esp-tls errors as well as internal MQTT errors - bool retain Retained flag of the message associated with this event - int qos QoS of the messages associated with this event - bool dup dup flag of the message associated with this event - esp_mqtt_protocol_ver_t protocol_ver MQTT protocol version used for connection, defaults to value from menuconfig - esp_mqtt_event_id_t event_id - struct esp_mqtt_client_config_t MQTT client configuration structure Default values can be set via menuconfig All certificates and key data could be passed in PEM or DER format. PEM format must have a terminating NULL character and the related len field set to 0. DER format requires a related len field set to the correct length. Public Members - struct esp_mqtt_client_config_t::broker_t broker Broker address and security verification - struct esp_mqtt_client_config_t::credentials_t credentials User credentials for broker - struct esp_mqtt_client_config_t::session_t session MQTT session configuration. - struct esp_mqtt_client_config_t::network_t network Network configuration - struct esp_mqtt_client_config_t::task_t task FreeRTOS task configuration. - struct esp_mqtt_client_config_t::buffer_t buffer Buffer size configuration. - struct esp_mqtt_client_config_t::outbox_config_t outbox Outbox configuration. - struct broker_t Broker related configuration Public Members - struct esp_mqtt_client_config_t::broker_t::address_t address Broker address configuration - struct esp_mqtt_client_config_t::broker_t::verification_t verification Security verification of the broker - struct address_t Broker address uri have precedence over other fields If uri isn't set at least hostname, transport and port should. - - struct verification_t Broker identity verification If fields are not set broker's identity isn't verified. it's recommended to set the options in this struct for security reasons. Public Members - bool use_global_ca_store Use a global ca_store, look esp-tls documentation for details. - esp_err_t (*crt_bundle_attach)(void *conf) Pointer to ESP x509 Certificate Bundle attach function for the usage of certificate bundles. - const char *certificate Certificate data, default is NULL, not required to verify the server. - size_t certificate_len Length of the buffer pointed to by certificate. - const struct psk_key_hint *psk_hint_key Pointer to PSK struct defined in esp_tls.h to enable PSK authentication (as alternative to certificate verification). PSK is enabled only if there are no other ways to verify broker. - bool skip_cert_common_name_check Skip any validation of server certificate CN field, this reduces the security of TLS and makes the MQTT client susceptible to MITM attacks - const char **alpn_protos NULL-terminated list of supported application protocols to be used for ALPN - const char *common_name Pointer to the string containing server certificate common name. If non-NULL, server certificate CN must match this name, If NULL, server certificate CN must match hostname. This is ignored if skip_cert_common_name_check=true. - bool use_global_ca_store - struct esp_mqtt_client_config_t::broker_t::address_t address - struct buffer_t Client buffer size configuration Client have two buffers for input and output respectivelly. - struct credentials_t Client related credentials for authentication. Public Members - const char *username MQTT username - const char *client_id Set MQTT client identifier. Ignored if set_null_client_id == true If NULL set the default client id. Default client id is ESP32_CHIPID%where CHIPID%are last 3 bytes of MAC address in hex format - bool set_null_client_id Selects a NULL client id - struct esp_mqtt_client_config_t::credentials_t::authentication_t authentication Client authentication - struct authentication_t Client authentication Fields related to client authentication by broker For mutual authentication using TLS, user could select certificate and key, secure element or digital signature peripheral if available. Public Members - const char *password MQTT password - const char *certificate Certificate for ssl mutual authentication, not required if mutual authentication is not needed. Must be provided with key. - size_t certificate_len Length of the buffer pointed to by certificate. - const char *key Private key for SSL mutual authentication, not required if mutual authentication is not needed. If it is not NULL, also certificatehas to be provided. - size_t key_len Length of the buffer pointed to by key. - const char *key_password Client key decryption password, not PEM nor DER, if provided key_password_lenmust be correctly set. - int key_password_len Length of the password pointed to by key_password - bool use_secure_element Enable secure element, available in ESP32-ROOM-32SE, for SSL connection - void *ds_data Carrier of handle for digital signature parameters, digital signature peripheral is available in some Espressif devices. - const char *password - const char *username - struct network_t Network related configuration Public Members - int reconnect_timeout_ms Reconnect to the broker after this value in miliseconds if auto reconnect is not disabled (defaults to 10s) - int timeout_ms Abort network operation if it is not completed after this value, in milliseconds (defaults to 10s). - int refresh_connection_after_ms Refresh connection after this value (in milliseconds) - bool disable_auto_reconnect Client will reconnect to server (when errors/disconnect). Set disable_auto_reconnect=trueto disable - esp_transport_handle_t transport Custom transport handle to use. Warning: The transport should be valid during the client lifetime and is destroyed when esp_mqtt_client_destroy is called. - struct ifreq *if_name The name of interface for data to go through. Use the default interface without setting - int reconnect_timeout_ms - struct outbox_config_t Client outbox configuration options. Public Members - uint64_t limit Size limit for the outbox in bytes. - uint64_t limit - struct session_t MQTT Session related configuration Public Members - struct esp_mqtt_client_config_t::session_t::last_will_t last_will Last will configuration - bool disable_clean_session MQTT clean session, default clean_session is true - int keepalive MQTT keepalive, default is 120 seconds When configuring this value, keep in mind that the client attempts to communicate with the broker at half the interval that is actually set. This conservative approach allows for more attempts before the broker's timeout occurs - bool disable_keepalive Set disable_keepalive=trueto turn off keep-alive mechanism, keepalive is active by default. Note: setting the config value keepaliveto 0doesn't disable keepalive feature, but uses a default keepalive period - esp_mqtt_protocol_ver_t protocol_ver MQTT protocol version used for connection. - int message_retransmit_timeout timeout for retransmitting of failed packet - struct last_will_t Last Will and Testament message configuration. - struct esp_mqtt_client_config_t::session_t::last_will_t last_will - struct task_t Client task configuration - - struct topic_t Topic definition struct Macros - MQTT_ERROR_TYPE_ESP_TLS MQTT_ERROR_TYPE_TCP_TRANSPORT error type hold all sorts of transport layer errors, including ESP-TLS error, but in the past only the errors from MQTT_ERROR_TYPE_ESP_TLS layer were reported, so the ESP-TLS error type is re-defined here for backward compatibility - esp_mqtt_client_subscribe(client_handle, topic_type, qos_or_size) Convenience macro to select subscribe function to use. Notes: Usage of esp_mqtt_client_subscribe_singleis the same as previous esp_mqtt_client_subscribe, refer to it for details. - Parameters client_handle -- MQTT client handle topic_type -- Needs to be char* for single subscription or esp_mqtt_topic_tfor multiple topics qos_or_size -- It's either a qos when subscribing to a single topic or the size of the subscription array when subscribing to multiple topics. - - Returns message_id of the subscribe message on success -1 on failure -2 in case of full outbox. - Type Definitions - typedef struct esp_mqtt_client *esp_mqtt_client_handle_t - typedef enum esp_mqtt_event_id_t esp_mqtt_event_id_t MQTT event types. User event handler receives context data in esp_mqtt_event_tstructure with client - MQTT client handle various other data depending on event type - - typedef enum esp_mqtt_connect_return_code_t esp_mqtt_connect_return_code_t MQTT connection error codes propagated via ERROR event - typedef enum esp_mqtt_error_type_t esp_mqtt_error_type_t MQTT connection error codes propagated via ERROR event - typedef enum esp_mqtt_transport_t esp_mqtt_transport_t - typedef enum esp_mqtt_protocol_ver_t esp_mqtt_protocol_ver_t MQTT protocol version used for connection - 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_errorerror structure and is backward compatible with it (so might be down-casted and treated as esp_tls_last_errorerror, 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 | Internal error reported from MQTT broker on connection | - typedef struct esp_mqtt_event_t esp_mqtt_event_t MQTT event configuration structure - typedef esp_mqtt_event_t *esp_mqtt_event_handle_t - typedef struct esp_mqtt_client_config_t esp_mqtt_client_config_t MQTT client configuration structure Default values can be set via menuconfig All certificates and key data could be passed in PEM or DER format. PEM format must have a terminating NULL character and the related len field set to 0. DER format requires a related len field set to the correct length. - Enumerations - enum esp_mqtt_event_id_t MQTT event types. User event handler receives context data in esp_mqtt_event_tstructure with client - MQTT client handle various other data depending on event type Values: - enumerator MQTT_EVENT_ANY - enumerator MQTT_EVENT_ERROR on error event, additional context: connection return code, error handle from esp_tls (if supported) - enumerator MQTT_EVENT_CONNECTED connected event, additional context: session_present flag - enumerator MQTT_EVENT_DISCONNECTED disconnected event - enumerator MQTT_EVENT_SUBSCRIBED subscribed event, additional context: msg_id message id error_handle error_typein case subscribing failed data pointer to broker response, check for errors. data_len length of the data for this event - - enumerator MQTT_EVENT_UNSUBSCRIBED unsubscribed event, additional context: msg_id - enumerator MQTT_EVENT_PUBLISHED published event, additional context: msg_id - enumerator 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 qos QoS level of the message dup dup 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. - - enumerator MQTT_EVENT_BEFORE_CONNECT The event occurs before connecting - enumerator MQTT_EVENT_DELETED Notification on delete of one message from the internal outbox, if the message couldn't have been sent and acknowledged before expiring defined in OUTBOX_EXPIRED_TIMEOUT_MS. (events are not posted upon deletion of successfully acknowledged messages) This event id is posted only if MQTT_REPORT_DELETED_MESSAGES==1 Additional context: msg_id (id of the deleted message). - - enumerator MQTT_USER_EVENT Custom event used to queue tasks into mqtt event handler All fields from the esp_mqtt_event_t type could be used to pass an additional context data to the handler. - - enum esp_mqtt_connect_return_code_t MQTT connection error codes propagated via ERROR event Values: - enumerator MQTT_CONNECTION_ACCEPTED Connection accepted - enumerator MQTT_CONNECTION_REFUSE_PROTOCOL MQTT connection refused reason: Wrong protocol - enumerator MQTT_CONNECTION_REFUSE_ID_REJECTED MQTT connection refused reason: ID rejected - enumerator MQTT_CONNECTION_REFUSE_SERVER_UNAVAILABLE MQTT connection refused reason: Server unavailable - enumerator MQTT_CONNECTION_REFUSE_BAD_USERNAME MQTT connection refused reason: Wrong user - enumerator MQTT_CONNECTION_REFUSE_NOT_AUTHORIZED MQTT connection refused reason: Wrong username or password - enumerator MQTT_CONNECTION_ACCEPTED - enum esp_mqtt_error_type_t MQTT connection error codes propagated via ERROR event Values: - enumerator MQTT_ERROR_TYPE_NONE - enumerator MQTT_ERROR_TYPE_TCP_TRANSPORT - enumerator MQTT_ERROR_TYPE_CONNECTION_REFUSED - enumerator MQTT_ERROR_TYPE_SUBSCRIBE_FAILED - enumerator MQTT_ERROR_TYPE_NONE - enum esp_mqtt_transport_t Values: - enumerator MQTT_TRANSPORT_UNKNOWN - enumerator MQTT_TRANSPORT_OVER_TCP MQTT over TCP, using scheme: MQTT - enumerator MQTT_TRANSPORT_OVER_SSL MQTT over SSL, using scheme: MQTTS - enumerator MQTT_TRANSPORT_OVER_WS MQTT over Websocket, using scheme:: ws - enumerator MQTT_TRANSPORT_OVER_WSS MQTT over Websocket Secure, using scheme: wss - enumerator MQTT_TRANSPORT_UNKNOWN(...TRUNCATED)
null
null
null
https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/protocols/mqtt.html(...TRUNCATED)
ESP-IDF Programming Guide v5.2.1 documentation
null
ESP-TLS
null
espressif.com
2016-01-01
745bfc5af690d090
null
null
"ESP-TLS Overview The ESP-TLS component provides a simplified API interface for accessing th(...TRUNCATED)
"ESP-TLS\nOverview\nThe ESP-TLS component provides a simplified API interface for accessing the comm(...TRUNCATED)
null
null
null
https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/protocols/esp_tls.html(...TRUNCATED)
ESP-IDF Programming Guide v5.2.1 documentation
null
ESP HTTP Client
Int Max Authorization Retries
espressif.com
2016-01-01
b25bfd1e6219ee90
null
null
"ESP HTTP Client Overview esp_http_client component provides a set of APIs for making HTTP/(...TRUNCATED)
"ESP HTTP Client\nOverview\nesp_http_client component provides a set of APIs for making HTTP/S reque(...TRUNCATED)
null
null
null
"https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/protocols/esp_http_client(...TRUNCATED)
ESP-IDF Programming Guide v5.2.1 documentation
null
ESP Local Control
null
espressif.com
2016-01-01
2289ac90e489fa49
null
null
"ESP Local Control Overview ESP Local Control (esp_local_ctrl) component in ESP-IDF provides(...TRUNCATED)
"ESP Local Control\nOverview\nESP Local Control (esp_local_ctrl) component in ESP-IDF provides capab(...TRUNCATED)
null
null
null
"https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/protocols/esp_local_ctrl.(...TRUNCATED)
ESP-IDF Programming Guide v5.2.1 documentation
null
ESP Serial Slave Link
null
espressif.com
2016-01-01
9edb9e9ee3429119
null
null
"ESP Serial Slave Link Overview Espressif provides several chips that can work as slaves. Th(...TRUNCATED)
"ESP Serial Slave Link\nOverview\nEspressif provides several chips that can work as slaves. These sl(...TRUNCATED)
null
null
null
"https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/protocols/esp_serial_slav(...TRUNCATED)
ESP-IDF Programming Guide v5.2.1 documentation
null
ESP x509 Certificate Bundle
null
espressif.com
2016-01-01
2d29627b1e191694
null
null
"ESP x509 Certificate Bundle Overview The ESP x509 Certificate Bundle API provides an easy w(...TRUNCATED)
"ESP x509 Certificate Bundle\nOverview\nThe ESP x509 Certificate Bundle API provides an easy way to (...TRUNCATED)
null
null
null
"https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/protocols/esp_crt_bundle.(...TRUNCATED)
ESP-IDF Programming Guide v5.2.1 documentation
null
HTTP Server
null
espressif.com
2016-01-01
e753bdcbfc02d09f
null
null
"HTTP Server Overview The HTTP Server component provides an ability for running a lightweigh(...TRUNCATED)
"HTTP Server\nOverview\nThe HTTP Server component provides an ability for running a lightweight web (...TRUNCATED)
null
null
null
"https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/protocols/esp_http_server(...TRUNCATED)
ESP-IDF Programming Guide v5.2.1 documentation
null
HTTPS Server
null
espressif.com
2016-01-01
cc52bd4bb812f89d
null
null
"HTTPS Server Overview This component is built on top of HTTP Server. The HTTPS server takes(...TRUNCATED)
"HTTPS Server\nOverview\nThis component is built on top of HTTP Server. The HTTPS server takes advan(...TRUNCATED)
null
null
null
"https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/protocols/esp_https_serve(...TRUNCATED)
ESP-IDF Programming Guide v5.2.1 documentation
null
ICMP Echo
null
espressif.com
2016-01-01
a4f8bdb0a61cb1f1
null
null
"ICMP Echo Overview ICMP (Internet Control Message Protocol) is used for diagnostic or contr(...TRUNCATED)
"ICMP Echo\nOverview\nICMP (Internet Control Message Protocol) is used for diagnostic or control pur(...TRUNCATED)
null
null
null
https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/protocols/icmp_echo.html(...TRUNCATED)
ESP-IDF Programming Guide v5.2.1 documentation
null
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
0
Edit dataset card