SensESP 3.0.1
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
discovery.cpp
Go to the documentation of this file.
1#include "discovery.h"
2
3#include "sensesp_base_app.h"
4
5namespace sensesp {
6
8 event_loop()->onDelay(0, [this]() {
9 String hostname = SensESPBaseApp::get_hostname();
10
11 // MDNS.begin(hostname) will crash if hostname is blank
12 if ((hostname == "")) {
13 ESP_LOGE(__FILENAME__, "hostname has not been set - mDNS can't start");
14 return;
15 }
16 if (!MDNS.begin(
17 hostname.c_str())) { // Start the mDNS responder for hostname.local
18 ESP_LOGW(__FILENAME__, "Error setting up mDNS responder");
19 } else {
20 ESP_LOGI(__FILENAME__, "mDNS responder started for hostname '%s'",
21 hostname.c_str());
22 }
23 mdns_instance_name_set(hostname.c_str()); // mDNS hostname for ESP32
24 });
25}
26
27} // namespace sensesp
static String get_hostname()
Get the current hostname.
std::shared_ptr< reactesp::EventLoop > event_loop()
Definition sensesp.cpp:9