ESPHome 2025.6.0
Loading...
Searching...
No Matches
mdns_component.h
Go to the documentation of this file.
1#pragma once
3#ifdef USE_MDNS
4#include <string>
5#include <vector>
8
9namespace esphome {
10namespace mdns {
11
16
18 // service name _including_ underscore character prefix
19 // as defined in RFC6763 Section 7
20 std::string service_type;
21 // second label indicating protocol _including_ underscore character prefix
22 // as defined in RFC6763 Section 7, like "_tcp" or "_udp"
23 std::string proto;
25 std::vector<MDNSTXTRecord> txt_records;
26};
27
28class MDNSComponent : public Component {
29 public:
30 void setup() override;
31 void dump_config() override;
32
33#if (defined(USE_ESP8266) || defined(USE_RP2040)) && defined(USE_ARDUINO)
34 void loop() override;
35#endif
36 float get_setup_priority() const override { return setup_priority::AFTER_CONNECTION; }
37
38 void add_extra_service(MDNSService service) { services_extra_.push_back(std::move(service)); }
39
40 std::vector<MDNSService> get_services();
41
42 void on_shutdown() override;
43
44 protected:
45 std::vector<MDNSService> services_extra_{};
46 std::vector<MDNSService> services_{};
47 std::string hostname_;
48 void compile_records_();
49};
50
51} // namespace mdns
52} // namespace esphome
53#endif
float get_setup_priority() const override
std::vector< MDNSService > services_
void add_extra_service(MDNSService service)
std::vector< MDNSService > get_services()
std::vector< MDNSService > services_extra_
const float AFTER_CONNECTION
For components that should be initialized after a data connection (API/MQTT) is connected.
Definition component.cpp:28
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
TemplatableValue< uint16_t > port
std::vector< MDNSTXTRecord > txt_records
TemplatableValue< std::string > value