mirror of
https://github.com/esphome/esphome.git
synced 2026-09-11 23:37:34 +00:00
[mdns] Add mDNS to Zephyr and nRF52 (#16924)
Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
This commit is contained in:
co-authored by
Jonathan Swoboda
parent
f49bed47de
commit
be8523a73c
@@ -100,7 +100,7 @@ void MDNSComponent::compile_records_(StaticVector<MDNSService, MDNS_SERVICE_COUN
|
||||
if (!friendly_name_empty) {
|
||||
txt_count++; // friendly_name
|
||||
}
|
||||
#if defined(USE_ESP8266) || defined(USE_ESP32) || defined(USE_RP2040) || defined(USE_LIBRETINY)
|
||||
#if defined(USE_ESP8266) || defined(USE_ESP32) || defined(USE_RP2040) || defined(USE_LIBRETINY) || defined(USE_NRF52)
|
||||
txt_count++; // platform
|
||||
#endif
|
||||
#if defined(USE_WIFI) || defined(USE_ETHERNET) || defined(USE_OPENTHREAD)
|
||||
@@ -141,6 +141,9 @@ void MDNSComponent::compile_records_(StaticVector<MDNSService, MDNS_SERVICE_COUN
|
||||
txt_records.push_back({MDNS_STR(TXT_PLATFORM), MDNS_STR(PLATFORM_RP2040)});
|
||||
#elif defined(USE_LIBRETINY)
|
||||
txt_records.push_back({MDNS_STR(TXT_PLATFORM), MDNS_STR(lt_cpu_get_model_name())});
|
||||
#elif defined(USE_NRF52)
|
||||
MDNS_STATIC_CONST_CHAR(PLATFORM_NRF52, "nRF52");
|
||||
txt_records.push_back({MDNS_STR(TXT_PLATFORM), MDNS_STR(PLATFORM_NRF52)});
|
||||
#endif
|
||||
|
||||
txt_records.push_back({MDNS_STR(TXT_BOARD), MDNS_STR(VALUE_BOARD)});
|
||||
|
||||
@@ -2,13 +2,20 @@
|
||||
#if defined(USE_ZEPHYR) && defined(USE_MDNS)
|
||||
|
||||
#include "mdns_component.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome::mdns {
|
||||
|
||||
static const char *const TAG = "mdns.zephyr";
|
||||
#ifdef USE_MDNS_STORE_SERVICES
|
||||
// Zephyr has no local IP mDNS responder. When a consumer (ex. the OpenThread SRP
|
||||
// client) enables service storage, it reads the compiled records via get_services()
|
||||
// and advertises them itself. We only need to compile and store the records here.
|
||||
static void register_zephyr(MDNSComponent *, StaticVector<MDNSService, MDNS_SERVICE_COUNT> &) {}
|
||||
|
||||
void MDNSComponent::setup() { ESP_LOGW(TAG, "mDNS is not implemented for Zephyr"); }
|
||||
void MDNSComponent::setup() { this->setup_buffers_and_register_(register_zephyr); }
|
||||
#else
|
||||
// No responder and nothing consuming the records, so skip the boot-time compile.
|
||||
void MDNSComponent::setup() {}
|
||||
#endif
|
||||
|
||||
void MDNSComponent::on_shutdown() {}
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
network:
|
||||
enable_ipv6: true
|
||||
|
||||
mdns:
|
||||
Reference in New Issue
Block a user