ESPHome  2022.6.3
util.cpp
Go to the documentation of this file.
1 #include "util.h"
2 #include "esphome/core/defines.h"
3 
4 #ifdef USE_WIFI
6 #endif
7 
8 #ifdef USE_ETHERNET
10 #endif
11 
12 namespace esphome {
13 namespace network {
14 
15 bool is_connected() {
16 #ifdef USE_ETHERNET
18  return true;
19 #endif
20 
21 #ifdef USE_WIFI
22  if (wifi::global_wifi_component != nullptr)
24 #endif
25 
26  return false;
27 }
28 
30 #ifdef USE_ETHERNET
31  if (ethernet::global_eth_component != nullptr)
33 #endif
34 #ifdef USE_WIFI
35  if (wifi::global_wifi_component != nullptr)
37 #endif
38  return {};
39 }
40 
41 std::string get_use_address() {
42 #ifdef USE_ETHERNET
43  if (ethernet::global_eth_component != nullptr)
45 #endif
46 #ifdef USE_WIFI
47  if (wifi::global_wifi_component != nullptr)
49 #endif
50  return "";
51 }
52 
53 } // namespace network
54 } // namespace esphome
std::string get_use_address()
Get the active network hostname.
Definition: util.cpp:41
network::IPAddress get_ip_address()
bool is_connected()
Return whether the node is connected to the network (through wifi, eth, ...)
Definition: util.cpp:15
EthernetComponent * global_eth_component
WiFiComponent * global_wifi_component
Definition: a4988.cpp:4
std::string get_use_address() const
network::IPAddress get_ip_address()
Definition: util.cpp:29