|
esp_iot_framework
v0.1.0-alpha
© 2026 AmakeSasha, distributed under a license Apache-2.0
|
Network discovery and mDNS management. More...
Macros | |
| #define | EIF_MDNS_TXT_RECORDS_MAX_COUNT 32 |
| Maximum number of mDNS txt-records. | |
Functions | |
| esp_err_t | eif_set_mdns (const char *const hostname, const char *const instance_name) |
| Configure the mDNS hostname and instance name. More... | |
| esp_err_t | eif_set_mdns_records (const mdns_txt_item_t txt_records[EIF_MDNS_TXT_RECORDS_MAX_COUNT], size_t txt_records_count) |
| Set custom TXT records for mDNS service discovery. More... | |
CONFIG_EIF_ENABLE_MDNS is enabled and you include this line at the beginning of the file.: This module allows you to configure mDNS. mDNS enables the device to be discovered via a human-readable name (e.g., my-device.local) instead of an IP address.
The framework automatically appends a unique identifier based on the MAC address to prevent network collisions (e.g., common hostname set: esp32.local, the framework turns this into esp32-1a2b3c.local on a device with MAC XX:XX:XX:1A:2B:3C).
device will be used as the common hostname. To disable mDNS, turn off Kconfig option CONFIG_EIF_ENABLE_MDNS.If you frequently need to enable and disable mDNS during development, you can use the following construct:
| esp_err_t eif_set_mdns | ( | const char *const | hostname, |
| const char *const | instance_name | ||
| ) |
Sets the base identity of the device on the local network.
eif_core_initialize() but before eif_wifi_initialize().| hostname | Base name prefix (e.g., "my-sensor"). Max length: 32. |
| instance_name | Friendly name for discovery tools (e.g., "Main Hall Sensor"). If NULL or empty, the formatted mdns_hostname(with MAC) will be used as the instance name by default. |
ESP_OK: Configuration stored.ESP_ERR_INVALID_ARG: The pointer hostname or instance_name is NULL.ESP_ERR_INVALID_SIZE: The length of the hostname or instance_name is outside the acceptable range.Example of use:
| esp_err_t eif_set_mdns_records | ( | const mdns_txt_item_t | txt_records[EIF_MDNS_TXT_RECORDS_MAX_COUNT], |
| size_t | txt_records_count | ||
| ) |
TXT records allow you to broadcast additional metadata about the device (e.g., firmware version, model, or status). The framework creates an internal copy of the structure, so the original data's lifecycle no longer matters after the call.
eif_core_initialize() but before eif_wifi_initialize().txt_records_count. If the count exceeds the actual array length, a Buffer Overread will occur. If the count is less than the actual length, error ESP_ERR_INVALID_ARG will return. | txt_records | Array of mDNS TXT items. The length should be EIF_MDNS_TXT_RECORDS_MAX_COUNT. |
| txt_records_count | Number of elements in the array. |
ESP_OK: Records applied.ESP_ERR_INVALID_ARG: The pointer key or value from txt_records is NULL.ESP_ERR_INVALID_SIZE: The txt_records length is less than txt_records_count.Example of use: