mirror of
https://github.com/esphome/esphome.git
synced 2025-01-22 12:26:01 +01:00
Add has_network() to tell of there is a network
component setup
This commit is contained in:
parent
208edf89dc
commit
f659af0f6a
2 changed files with 19 additions and 1 deletions
|
@ -12,6 +12,23 @@
|
|||
namespace esphome {
|
||||
namespace network {
|
||||
|
||||
bool has_network() {
|
||||
#ifdef USE_ETHERNET
|
||||
if (ethernet::global_eth_component != nullptr)
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#ifdef USE_WIFI
|
||||
if (wifi::global_wifi_component != nullptr)
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#ifdef USE_HOST
|
||||
return true; // Assume its connected
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_connected() {
|
||||
#ifdef USE_ETHERNET
|
||||
if (ethernet::global_eth_component != nullptr && ethernet::global_eth_component->is_connected())
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
|
||||
namespace esphome {
|
||||
namespace network {
|
||||
|
||||
/// Return whether has network components enabled (through wifi, eth, ...)
|
||||
bool has_network();
|
||||
/// Return whether the node is connected to the network (through wifi, eth, ...)
|
||||
bool is_connected();
|
||||
/// Return whether the network is disabled (only wifi for now)
|
||||
|
|
Loading…
Reference in a new issue