1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-21 01:58:16 +00:00
esphome/esphome/components/mdns/mdns_component.h
2023-02-09 10:25:44 +13:00

49 lines
1.2 KiB
C++

#pragma once
#include <string>
#include <vector>
#include "esphome/core/component.h"
namespace esphome {
namespace mdns {
struct MDNSTXTRecord {
std::string key;
std::string value;
};
struct MDNSService {
// service name _including_ underscore character prefix
// as defined in RFC6763 Section 7
std::string service_type;
// second label indicating protocol _including_ underscore character prefix
// as defined in RFC6763 Section 7, like "_tcp" or "_udp"
std::string proto;
uint16_t port;
std::vector<MDNSTXTRecord> txt_records;
};
class MDNSComponent : public Component {
public:
void setup() override;
void dump_config() override;
#if (defined(USE_ESP8266) || defined(USE_RP2040)) && defined(USE_ARDUINO)
void loop() override;
#endif
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
void add_extra_service(MDNSService service) { services_extra_.push_back(std::move(service)); }
void on_shutdown() override;
protected:
std::vector<MDNSService> services_extra_{};
std::vector<MDNSService> services_{};
std::string hostname_;
void compile_records_();
};
} // namespace mdns
} // namespace esphome