mirror of
https://github.com/esphome/esphome.git
synced 2025-04-15 23:30:28 +01:00
Co-authored-by: Kuba Szczodrzyński <kuba@szczodrzynski.pl> Co-authored-by: Sam Neirinck <git@samneirinck.com> Co-authored-by: David Buezas <dbuezas@users.noreply.github.com> Co-authored-by: Stroe Andrei Catalin <catalin2402@gmail.com> Co-authored-by: Sam Neirinck <github@samneirinck.be> Co-authored-by: Péter Sárközi <xmisterhu@gmail.com> Co-authored-by: Hajo Noerenberg <hn@users.noreply.github.com>
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#ifdef USE_LIBRETINY
|
|
|
|
#include "esphome/components/network/ip_address.h"
|
|
#include "esphome/components/network/util.h"
|
|
#include "esphome/core/log.h"
|
|
#include "mdns_component.h"
|
|
|
|
#include <mDNS.h>
|
|
|
|
namespace esphome {
|
|
namespace mdns {
|
|
|
|
void MDNSComponent::setup() {
|
|
this->compile_records_();
|
|
|
|
MDNS.begin(this->hostname_.c_str());
|
|
|
|
for (const auto &service : this->services_) {
|
|
// Strip the leading underscore from the proto and service_type. While it is
|
|
// part of the wire protocol to have an underscore, and for example ESP-IDF
|
|
// expects the underscore to be there, the ESP8266 implementation always adds
|
|
// the underscore itself.
|
|
auto *proto = service.proto.c_str();
|
|
while (*proto == '_') {
|
|
proto++;
|
|
}
|
|
auto *service_type = service.service_type.c_str();
|
|
while (*service_type == '_') {
|
|
service_type++;
|
|
}
|
|
MDNS.addService(service_type, proto, service.port);
|
|
for (const auto &record : service.txt_records) {
|
|
MDNS.addServiceTxt(service_type, proto, record.key.c_str(), record.value.c_str());
|
|
}
|
|
}
|
|
}
|
|
|
|
void MDNSComponent::on_shutdown() {}
|
|
|
|
} // namespace mdns
|
|
} // namespace esphome
|
|
|
|
#endif
|