mirror of
https://github.com/esphome/esphome.git
synced 2026-05-23 03:06:05 +08:00
[mdns] add Sendspin advertisement support (#14013)
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
This commit is contained in:
@@ -21,7 +21,7 @@ DEPENDENCIES = ["network"]
|
||||
# Components that create mDNS services at runtime
|
||||
# IMPORTANT: If you add a new component here, you must also update the corresponding
|
||||
# #ifdef blocks in mdns_component.cpp compile_records_() method
|
||||
COMPONENTS_WITH_MDNS_SERVICES = ("api", "prometheus", "web_server")
|
||||
COMPONENTS_WITH_MDNS_SERVICES = ("api", "prometheus", "sendspin", "web_server")
|
||||
|
||||
mdns_ns = cg.esphome_ns.namespace("mdns")
|
||||
MDNSComponent = mdns_ns.class_("MDNSComponent", cg.Component)
|
||||
|
||||
@@ -29,6 +29,10 @@ static const char *const TAG = "mdns";
|
||||
#define USE_WEBSERVER_PORT 80 // NOLINT
|
||||
#endif
|
||||
|
||||
#ifndef USE_SENDSPIN_PORT
|
||||
#define USE_SENDSPIN_PORT 8928 // NOLINT
|
||||
#endif
|
||||
|
||||
// Define all constant strings using the macro
|
||||
MDNS_STATIC_CONST_CHAR(SERVICE_TCP, "_tcp");
|
||||
|
||||
@@ -150,6 +154,18 @@ void MDNSComponent::compile_records_(StaticVector<MDNSService, MDNS_SERVICE_COUN
|
||||
prom_service.port = USE_WEBSERVER_PORT;
|
||||
#endif
|
||||
|
||||
#ifdef USE_SENDSPIN
|
||||
MDNS_STATIC_CONST_CHAR(SERVICE_SENDSPIN, "_sendspin");
|
||||
MDNS_STATIC_CONST_CHAR(TXT_SENDSPIN_PATH, "path");
|
||||
MDNS_STATIC_CONST_CHAR(VALUE_SENDSPIN_PATH, "/sendspin");
|
||||
|
||||
auto &sendspin_service = services.emplace_next();
|
||||
sendspin_service.service_type = MDNS_STR(SERVICE_SENDSPIN);
|
||||
sendspin_service.proto = MDNS_STR(SERVICE_TCP);
|
||||
sendspin_service.port = USE_SENDSPIN_PORT;
|
||||
sendspin_service.txt_records = {{MDNS_STR(TXT_SENDSPIN_PATH), MDNS_STR(VALUE_SENDSPIN_PATH)}};
|
||||
#endif
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
MDNS_STATIC_CONST_CHAR(SERVICE_HTTP, "_http");
|
||||
|
||||
@@ -159,7 +175,8 @@ void MDNSComponent::compile_records_(StaticVector<MDNSService, MDNS_SERVICE_COUN
|
||||
web_service.port = USE_WEBSERVER_PORT;
|
||||
#endif
|
||||
|
||||
#if !defined(USE_API) && !defined(USE_PROMETHEUS) && !defined(USE_WEBSERVER) && !defined(USE_MDNS_EXTRA_SERVICES)
|
||||
#if !defined(USE_API) && !defined(USE_PROMETHEUS) && !defined(USE_SENDSPIN) && !defined(USE_WEBSERVER) && \
|
||||
!defined(USE_MDNS_EXTRA_SERVICES)
|
||||
MDNS_STATIC_CONST_CHAR(SERVICE_HTTP, "_http");
|
||||
MDNS_STATIC_CONST_CHAR(TXT_VERSION, "version");
|
||||
|
||||
|
||||
@@ -210,6 +210,8 @@
|
||||
#define USE_ESP32_IMPROV_NEXT_URL
|
||||
#define USE_MICROPHONE
|
||||
#define USE_PSRAM
|
||||
#define USE_SENDSPIN
|
||||
#define USE_SENDSPIN_PORT 8928 // NOLINT
|
||||
#define USE_SOCKET_IMPL_BSD_SOCKETS
|
||||
#define USE_SOCKET_SELECT_SUPPORT
|
||||
#define USE_WAKE_LOOP_THREADSAFE
|
||||
|
||||
Reference in New Issue
Block a user