Skip to content

Commit 7d5ad4f

Browse files
authored
feat(doc): Document isOnline() function in network API
Added documentation for the isOnline() function to check network status.
1 parent 4e7fc2f commit 7d5ad4f

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

docs/en/api/network.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,40 @@ This must be called before using any network interfaces. Returns ``true`` on suc
8282
Network.begin(); // Initialize Network Manager
8383
}
8484
85+
Check if Online
86+
***************
87+
88+
.. code-block:: arduino
89+
90+
bool isOnline();
91+
92+
Check if the device is online by verifying if any network interface (except AP) has an assigned IPv4 or global IPv6 address.
93+
Returns ``true`` if such interface has been found, ``false`` if no interface has assigned IP.
94+
95+
**Example:**
96+
97+
.. code-block:: arduino
98+
99+
#include "Network.h"
100+
101+
void setup() {
102+
Serial.begin(115200);
103+
Network.begin(); // Initialize Network Manager
104+
105+
// Connect to WiFi AP
106+
WiFi.STA.begin();
107+
WiFi.STA.connect("ssid", "password");
108+
109+
// Wait for WiFi to connect
110+
while (!WiFi.STA.hasIP()) {
111+
delay(500);
112+
}
113+
114+
if (Network.isOnline()) {
115+
Serial.println("Network is Online");
116+
}
117+
}
118+
85119
Default Interface Management
86120
****************************
87121

0 commit comments

Comments
 (0)