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
5
namespace
sensesp
{
6
7
MDNSDiscovery::MDNSDiscovery
() {
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
sensesp::MDNSDiscovery::MDNSDiscovery
MDNSDiscovery()
Definition
discovery.cpp:7
sensesp::SensESPBaseApp::get_hostname
static String get_hostname()
Get the current hostname.
Definition
sensesp_base_app.h:104
discovery.h
sensesp
Definition
sensesp.cpp:7
sensesp::event_loop
std::shared_ptr< reactesp::EventLoop > event_loop()
Definition
sensesp.cpp:9
sensesp_base_app.h
src
sensesp
net
discovery.cpp
Generated by
1.12.0