ESPHome 2025.5.0
Loading...
Searching...
No Matches
mdns_libretiny.cpp
Go to the documentation of this file.
2#if defined(USE_LIBRETINY) && defined(USE_MDNS)
3
6#include "esphome/core/log.h"
7#include "mdns_component.h"
8
9#include <mDNS.h>
10
11namespace esphome {
12namespace mdns {
13
15 this->compile_records_();
16
17 MDNS.begin(this->hostname_.c_str());
18
19 for (const auto &service : this->services_) {
20 // Strip the leading underscore from the proto and service_type. While it is
21 // part of the wire protocol to have an underscore, and for example ESP-IDF
22 // expects the underscore to be there, the ESP8266 implementation always adds
23 // the underscore itself.
24 auto *proto = service.proto.c_str();
25 while (*proto == '_') {
26 proto++;
27 }
28 auto *service_type = service.service_type.c_str();
29 while (*service_type == '_') {
30 service_type++;
31 }
32 uint16_t port_ = const_cast<TemplatableValue<uint16_t> &>(service.port).value();
33 MDNS.addService(service_type, proto, port_);
34 for (const auto &record : service.txt_records) {
35 MDNS.addServiceTxt(service_type, proto, record.key.c_str(),
36 const_cast<TemplatableValue<std::string> &>(record.value).value().c_str());
37 }
38 }
39}
40
42
43} // namespace mdns
44} // namespace esphome
45
46#endif
std::vector< MDNSService > services_
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7