DeterministicESPAsyncWebServer v6.28.0
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
mdns_service.h File Reference

Optional mDNS / DNS-SD advertisement (DETWS_ENABLE_MDNS). More...

#include "ServerConfig.h"
#include <stdint.h>

Go to the source code of this file.

Functions

bool detws_mdns_begin (const char *hostname, uint16_t http_port=80)
 Start mDNS responder and advertise an HTTP service.
 
bool detws_mdns_txt (const char *key, const char *value)
 Add a TXT key/value record to the advertised _http._tcp service.
 
bool detws_mdns_add_service (const char *service_type, const char *proto, uint16_t port)
 Advertise an additional service, e.g. ("_https", "_tcp", 443).
 

Detailed Description

Optional mDNS / DNS-SD advertisement (DETWS_ENABLE_MDNS).

Thin wrapper over the ESP-IDF mdns component so a headless device is reachable at <hostname>.local and advertises an _http._tcp service for browsers and Bonjour / DNS-SD tools (with optional TXT records and extra service types). Compiled to a no-op stub when DETWS_ENABLE_MDNS is 0 or on non-Arduino builds, so it costs nothing unless enabled.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file mdns_service.h.

Function Documentation

◆ detws_mdns_begin()

bool detws_mdns_begin ( const char *  hostname,
uint16_t  http_port = 80 
)

Start mDNS responder and advertise an HTTP service.

Call once after the WiFi link is up (wifi_ready()) and after begin(). The device becomes reachable at <hostname>.local and advertises _http._tcp on http_port.

Parameters
hostnameHost label without the .local suffix (e.g. "mydevice").
http_portTCP port the HTTP server listens on (default 80).
Returns
true if the responder started; false if disabled at compile time, not on Arduino, or the mdns component failed to start.

Definition at line 49 of file mdns_service.cpp.

◆ detws_mdns_txt()

bool detws_mdns_txt ( const char *  key,
const char *  value 
)

Add a TXT key/value record to the advertised _http._tcp service.

Bonjour / DNS-SD browsers display these (e.g. "path"="/", "fw"="1.2.3"). Call after detws_mdns_begin().

Returns
true on success; false if mDNS is disabled or not running.

◆ detws_mdns_add_service()

bool detws_mdns_add_service ( const char *  service_type,
const char *  proto,
uint16_t  port 
)

Advertise an additional service, e.g. ("_https", "_tcp", 443).

Parameters
service_typeDNS-SD service type, e.g. "_https".
proto"_tcp" or "_udp".
portTCP/UDP port the service listens on.
Returns
true on success; false if mDNS is disabled or not running.