Service.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <user_config.h>
4 #include <Data/CStringArray.h>
5 #include <memory>
6 
7 #if ENABLE_CUSTOM_LWIP == 2
8 #ifdef ARCH_ESP8266
9 #define MDNS_LWIP 0x0200
10 #else
11 #define MDNS_LWIP 0x0202
12 #endif
13 #elif ENABLE_CUSTOM_LWIP == 1
14 #define MDNS_LWIP 0x0101
15 #else
16 #define MDNS_LWIP 0x0100
17 #endif
18 
19 namespace mDNS
20 {
21 class Responder;
22 
23 class Service
24 {
25 public:
26  enum class Protocol {
27  Udp /* = DNSSD_PROTO_UCP */,
28  Tcp /* = DNSSD_PROTO_TCP */,
29  };
30 
36  struct Info {
37  String name = "Sming";
38  String type = "http";
39  Protocol protocol = Protocol::Tcp;
40  uint16_t port = 80;
41  };
42 
46  virtual Info getInfo() = 0;
47 
56  virtual CStringArray getTxt()
57  {
58  return nullptr;
59  }
60 
61 private:
62  friend class Responder;
63 
64 #if MDNS_LWIP >= 0x0200
65  int8_t id = -1;
66 #else
67  String type;
68  CStringArray txt;
69 #endif
70 };
71 
72 } // namespace mDNS
virtual CStringArray getTxt()
Override to obtain txt items.
Definition: Service.h:56
Definition: Responder.h:7
The String class.
Definition: WString.h:136
Definition: Responder.h:5
Definition: Service.h:23
Basic service information.
Definition: Service.h:36
virtual Info getInfo()=0
Override to obtain service information.
Class to manage a double null-terminated list of strings, such as "one\0two\0three\0".
Definition: CStringArray.h:21
Protocol
Definition: Service.h:26