-
Notifications
You must be signed in to change notification settings - Fork 6
/
zeroconf.h
45 lines (35 loc) · 972 Bytes
/
zeroconf.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
#include <string>
#include <list>
#include "esphome/core/component.h"
#ifdef ARDUINO_ARCH_ESP32
#include <ESPmDNS.h>
#endif
#ifdef ARDUINO_ARCH_ESP8266
#include <ESP8266mDNS.h>
#endif
namespace esphome {
namespace zeroconf {
struct Service {
const char *name;
const char *protocol;
uint16_t port;
};
struct Txt {
const char *key;
const char *value;
};
class Zeroconf : public Component {
public:
void setup() override;
void dump_config() override;
float get_setup_priority() const override { return esphome::setup_priority::AFTER_WIFI; }
void set_service(const char *name, const char *protocol, uint16_t port) { service_ = { name, protocol, port }; };
void add_txt(const char *key, const char *value) { txts_.push_back({ key, value }); };
protected:
Service service_;
std::list<Txt> txts_{};
std::string txts_to_string();
};
} // namespace zeroconf
} // namespace esphome