ESPHome  2022.12.8
mdns_component.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <vector>
6 
7 namespace esphome {
8 namespace mdns {
9 
10 struct MDNSTXTRecord {
11  std::string key;
12  std::string value;
13 };
14 
15 struct MDNSService {
16  // service name _including_ underscore character prefix
17  // as defined in RFC6763 Section 7
18  std::string service_type;
19  // second label indicating protocol _including_ underscore character prefix
20  // as defined in RFC6763 Section 7, like "_tcp" or "_udp"
21  std::string proto;
22  uint16_t port;
23  std::vector<MDNSTXTRecord> txt_records;
24 };
25 
26 class MDNSComponent : public Component {
27  public:
28  void setup() override;
29  void dump_config() override;
30 
31 #if (defined(USE_ESP8266) || defined(USE_RP2040)) && defined(USE_ARDUINO)
32  void loop() override;
33 #endif
34  float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
35 
36  protected:
37  std::vector<MDNSService> services_{};
38  std::string hostname_;
39  void compile_records_();
40 };
41 
42 } // namespace mdns
43 } // namespace esphome
void setup()
void loop()
const float AFTER_WIFI
For components that should be initialized after WiFi is connected.
Definition: component.cpp:25
std::vector< MDNSTXTRecord > txt_records
float get_setup_priority() const override
Definition: a4988.cpp:4