Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions libraries/Network/src/NetworkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,18 @@ NetworkInterface *NetworkManager::getDefaultInterface() {
return NULL;
}

bool NetworkManager::isOnline() {
for (int i = 0; i < ESP_NETIF_ID_MAX; ++i) {
if (i != ESP_NETIF_ID_AP) {
NetworkInterface *iface = getNetifByID((Network_Interface_ID)i);
if (iface != NULL && (iface->hasIP() || iface->hasGlobalIPv6())) {
return true;
}
}
}
return false;
}

size_t NetworkManager::printTo(Print &out) const {
size_t bytes = 0;

Expand Down
3 changes: 3 additions & 0 deletions libraries/Network/src/NetworkManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class NetworkManager : public NetworkEvents, public Printable {
bool setDefaultInterface(NetworkInterface &ifc);
NetworkInterface *getDefaultInterface();

// Returns true if any interface (except AP) has assigned IPv4 or global IPv6
bool isOnline();

size_t printTo(Print &out) const;

static const char *getHostname();
Expand Down
Loading