mirror of
https://github.com/esphome/esphome.git
synced 2025-02-21 20:38:16 +00:00
Make mDNS on rp2040 work (#3936)
This commit is contained in:
parent
f8ce597918
commit
702b60ce66
@ -36,6 +36,8 @@ async def to_code(config):
|
|||||||
cg.add_library("ESPmDNS", None)
|
cg.add_library("ESPmDNS", None)
|
||||||
elif CORE.is_esp8266:
|
elif CORE.is_esp8266:
|
||||||
cg.add_library("ESP8266mDNS", None)
|
cg.add_library("ESP8266mDNS", None)
|
||||||
|
elif CORE.is_rp2040:
|
||||||
|
cg.add_library("LEAmDNS", None)
|
||||||
|
|
||||||
if config[CONF_DISABLED]:
|
if config[CONF_DISABLED]:
|
||||||
return
|
return
|
||||||
|
@ -28,7 +28,7 @@ class MDNSComponent : public Component {
|
|||||||
void setup() override;
|
void setup() override;
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
|
|
||||||
#if defined(USE_ESP8266) && defined(USE_ARDUINO)
|
#if (defined(USE_ESP8266) || defined(USE_RP2040)) && defined(USE_ARDUINO)
|
||||||
void loop() override;
|
void loop() override;
|
||||||
#endif
|
#endif
|
||||||
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
#include "mdns_component.h"
|
#include "mdns_component.h"
|
||||||
|
|
||||||
|
#include <ESP8266mDNS.h>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace mdns {
|
namespace mdns {
|
||||||
|
|
||||||
@ -12,28 +14,30 @@ void MDNSComponent::setup() {
|
|||||||
this->compile_records_();
|
this->compile_records_();
|
||||||
|
|
||||||
network::IPAddress addr = network::get_ip_address();
|
network::IPAddress addr = network::get_ip_address();
|
||||||
// MDNS.begin(this->hostname_.c_str(), (uint32_t) addr);
|
MDNS.begin(this->hostname_.c_str(), (uint32_t) addr);
|
||||||
|
|
||||||
// for (const auto &service : this->services_) {
|
for (const auto &service : this->services_) {
|
||||||
// // Strip the leading underscore from the proto and service_type. While it is
|
// Strip the leading underscore from the proto and service_type. While it is
|
||||||
// // part of the wire protocol to have an underscore, and for example ESP-IDF
|
// part of the wire protocol to have an underscore, and for example ESP-IDF
|
||||||
// // expects the underscore to be there, the ESP8266 implementation always adds
|
// expects the underscore to be there, the ESP8266 implementation always adds
|
||||||
// // the underscore itself.
|
// the underscore itself.
|
||||||
// auto *proto = service.proto.c_str();
|
auto *proto = service.proto.c_str();
|
||||||
// while (*proto == '_') {
|
while (*proto == '_') {
|
||||||
// proto++;
|
proto++;
|
||||||
// }
|
}
|
||||||
// auto *service_type = service.service_type.c_str();
|
auto *service_type = service.service_type.c_str();
|
||||||
// while (*service_type == '_') {
|
while (*service_type == '_') {
|
||||||
// service_type++;
|
service_type++;
|
||||||
// }
|
}
|
||||||
// MDNS.addService(service_type, proto, service.port);
|
MDNS.addService(service_type, proto, service.port);
|
||||||
// for (const auto &record : service.txt_records) {
|
for (const auto &record : service.txt_records) {
|
||||||
// MDNS.addServiceTxt(service_type, proto, record.key.c_str(), record.value.c_str());
|
MDNS.addServiceTxt(service_type, proto, record.key.c_str(), record.value.c_str());
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MDNSComponent::loop() { MDNS.update(); }
|
||||||
|
|
||||||
} // namespace mdns
|
} // namespace mdns
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user