Chapter 2. API Reference
Return
• ESP_OK success
• ESP_ERR_INVALID_STATE mDNS is not running
• ESP_ERR_INVALID_ARG Parameter error
• ESP_ERR_NO_MEM memory error
Parameters
• hostname: Hostname to remove
bool mdns_hostname_exists(const char *hostname)
Query whether a hostname has been added.
Return
• true The hostname has been added.
• false The hostname has not been added.
Parameters
• hostname: Hostname to query
esp_err_t
mdns_instance_name_set(const char *instance_name)
Set the default instance name for mDNS server.
Return
• ESP_OK success
• ESP_ERR_INVALID_ARG Parameter error
• ESP_ERR_NO_MEM memory error
Parameters
• instance_name: Instance name to set
esp_err_t
mdns_service_add(const char *instance_name, const char *service_type, const char
Add service to mDNS server.
Note The value length of txt items will be automatically decided by strlen
Return
• ESP_OK success
• ESP_ERR_INVALID_ARG Parameter error
• ESP_ERR_NO_MEM memory error
• ESP_FAIL failed to add service
Parameters
• instance_name: instance name to set. If NULL, global instance name or hostname will be used.
Note that MDNS_MULTIPLE_INSTANCE config option needs to be enabled for adding multiple
instances with the same instance type.
• service_type: service type (_http, _ftp, etc)
• proto: service protocol (_tcp, _udp)
• port: service port
• txt: string array of TXT data (eg. {{"var","val"},{"other","2"}})
• num_items: number of items in TXT data
esp_err_t
mdns_service_add_for_host(const char *instance_name, const char *service_type,
Add service to mDNS server with a delegated hostname.
Note The value length of txt items will be automatically decided by strlen
Return
• ESP_OK success
• ESP_ERR_INVALID_ARG Parameter error
• ESP_ERR_NO_MEM memory error
• ESP_FAIL failed to add service
Parameters
• instance_name: instance name to set. If NULL, global instance name or hostname will be used
Note that MDNS_MULTIPLE_INSTANCE config option needs to be enabled for adding multiple
instances with the same instance type.
Espressif Systems
*proto, uint16_t port,
mdns_txt_item_t
const char *proto, const char *hostname, uint16_t port,
mdns_txt_item_t
612
Submit Document Feedback
txt[], size_t num_items)
txt[], size_t num_items)
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?
Questions and answers