ESPHome  2024.6.1
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  void add_extra_service(MDNSService service) { services_extra_.push_back(std::move(service)); }
37 
38  void on_shutdown() override;
39 
40  protected:
41  std::vector<MDNSService> services_extra_{};
42  std::vector<MDNSService> services_{};
43  std::string hostname_;
44  void compile_records_();
45 };
46 
47 } // namespace mdns
48 } // namespace esphome
void setup()
void loop()
const float AFTER_WIFI
For components that should be initialized after WiFi is connected.
Definition: component.cpp:26
std::vector< MDNSTXTRecord > txt_records
float get_setup_priority() const override
void add_extra_service(MDNSService service)
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7