mirror of
https://github.com/esphome/esphome.git
synced 2025-07-29 14:46:40 +00:00
[modem] network component change (#9801)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
parent
6ac1073469
commit
e94cb03272
@ -13,15 +13,27 @@
|
|||||||
#include "esphome/components/openthread/openthread.h"
|
#include "esphome/components/openthread/openthread.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_MODEM
|
||||||
|
#include "esphome/components/modem/modem_component.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace network {
|
namespace network {
|
||||||
|
|
||||||
|
// The order of the components is important: WiFi should come after any possible main interfaces (it may be used as
|
||||||
|
// an AP that use a previous interface for NAT).
|
||||||
|
|
||||||
bool is_connected() {
|
bool is_connected() {
|
||||||
#ifdef USE_ETHERNET
|
#ifdef USE_ETHERNET
|
||||||
if (ethernet::global_eth_component != nullptr && ethernet::global_eth_component->is_connected())
|
if (ethernet::global_eth_component != nullptr && ethernet::global_eth_component->is_connected())
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_MODEM
|
||||||
|
if (modem::global_modem_component != nullptr)
|
||||||
|
return modem::global_modem_component->is_connected();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_WIFI
|
#ifdef USE_WIFI
|
||||||
if (wifi::global_wifi_component != nullptr)
|
if (wifi::global_wifi_component != nullptr)
|
||||||
return wifi::global_wifi_component->is_connected();
|
return wifi::global_wifi_component->is_connected();
|
||||||
@ -39,6 +51,11 @@ bool is_connected() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool is_disabled() {
|
bool is_disabled() {
|
||||||
|
#ifdef USE_MODEM
|
||||||
|
if (modem::global_modem_component != nullptr)
|
||||||
|
return modem::global_modem_component->is_disabled();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_WIFI
|
#ifdef USE_WIFI
|
||||||
if (wifi::global_wifi_component != nullptr)
|
if (wifi::global_wifi_component != nullptr)
|
||||||
return wifi::global_wifi_component->is_disabled();
|
return wifi::global_wifi_component->is_disabled();
|
||||||
@ -51,6 +68,12 @@ network::IPAddresses get_ip_addresses() {
|
|||||||
if (ethernet::global_eth_component != nullptr)
|
if (ethernet::global_eth_component != nullptr)
|
||||||
return ethernet::global_eth_component->get_ip_addresses();
|
return ethernet::global_eth_component->get_ip_addresses();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_MODEM
|
||||||
|
if (modem::global_modem_component != nullptr)
|
||||||
|
return modem::global_modem_component->get_ip_addresses();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_WIFI
|
#ifdef USE_WIFI
|
||||||
if (wifi::global_wifi_component != nullptr)
|
if (wifi::global_wifi_component != nullptr)
|
||||||
return wifi::global_wifi_component->get_ip_addresses();
|
return wifi::global_wifi_component->get_ip_addresses();
|
||||||
@ -67,6 +90,12 @@ std::string get_use_address() {
|
|||||||
if (ethernet::global_eth_component != nullptr)
|
if (ethernet::global_eth_component != nullptr)
|
||||||
return ethernet::global_eth_component->get_use_address();
|
return ethernet::global_eth_component->get_use_address();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_MODEM
|
||||||
|
if (modem::global_modem_component != nullptr)
|
||||||
|
return modem::global_modem_component->get_use_address();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_WIFI
|
#ifdef USE_WIFI
|
||||||
if (wifi::global_wifi_component != nullptr)
|
if (wifi::global_wifi_component != nullptr)
|
||||||
return wifi::global_wifi_component->get_use_address();
|
return wifi::global_wifi_component->get_use_address();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user