ESPHome  2024.10.2
util.cpp
Go to the documentation of this file.
1 #include "util.h"
2 #include "esphome/core/defines.h"
3 #ifdef USE_NETWORK
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 #ifdef USE_HOST
27  return true; // Assume its connected
28 #endif
29  return false;
30 }
31 
32 bool is_disabled() {
33 #ifdef USE_WIFI
34  if (wifi::global_wifi_component != nullptr)
36 #endif
37  return false;
38 }
39 
41 #ifdef USE_ETHERNET
42  if (ethernet::global_eth_component != nullptr)
44 #endif
45 #ifdef USE_WIFI
46  if (wifi::global_wifi_component != nullptr)
48 #endif
49  return {};
50 }
51 
52 std::string get_use_address() {
53 #ifdef USE_ETHERNET
54  if (ethernet::global_eth_component != nullptr)
56 #endif
57 #ifdef USE_WIFI
58  if (wifi::global_wifi_component != nullptr)
60 #endif
61  return "";
62 }
63 
64 } // namespace network
65 } // namespace esphome
66 #endif
network::IPAddresses get_ip_addresses()
std::string get_use_address()
Get the active network hostname.
Definition: util.cpp:52
bool is_connected()
Return whether the node is connected to the network (through wifi, eth, ...)
Definition: util.cpp:15
EthernetComponent * global_eth_component
network::IPAddresses get_ip_addresses()
Definition: util.cpp:40
WiFiComponent * global_wifi_component
std::array< IPAddress, 5 > IPAddresses
Definition: ip_address.h:141
bool is_disabled()
Return whether the network is disabled (only wifi for now)
Definition: util.cpp:32
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
std::string get_use_address() const