@@ -30,14 +30,14 @@ The Network library follows a tree-like hierarchical structure:
3030 ├── NetworkInterface (Base Class)
3131 │ │
3232 │ ├── Wi-Fi
33- │ │ ├── STAClass (Station Mode)
34- │ │ └── APClass (Access Point Mode)
33+ │ │ ├── STAClass WiFi.STA (Station Mode)
34+ │ │ └── APClass WiFi.AP (Access Point Mode)
3535 │ │
3636 │ ├── Ethernet
37- │ │ └── ETHClass
37+ │ │ └── ETHClass ETH
3838 │ │
3939 │ └── PPP
40- │ └── PPPClass
40+ │ └── PPPClass PPP
4141 │
4242 └── Network Communication
4343 ├── NetworkClient
@@ -101,15 +101,16 @@ Sets or gets the default network interface. The default interface is used for ne
101101
102102 void setup() {
103103 Network.begin();
104- WiFi.begin("ssid", "password");
104+ WiFi.STA.begin();
105+ WiFi.STA.connect("ssid", "password");
105106
106107 // Wait for WiFi to connect
107- while (WiFi.status() != WL_CONNECTED ) {
108+ while (! WiFi.STA.hasIP() ) {
108109 delay(500);
109110 }
110111
111112 // Set WiFi as default interface
112- Network.setDefaultInterface(WiFi);
113+ Network.setDefaultInterface(WiFi.STA );
113114
114115 // Get current default interface
115116 NetworkInterface *defaultIf = Network.getDefaultInterface();
@@ -400,8 +401,9 @@ For server interfaces (Wi-Fi AP), ``dns1`` is the DHCP lease range start and ``d
400401 IPAddress dns1(8, 8, 8, 8);
401402 IPAddress dns2(8, 8, 4, 4);
402403
403- WiFi.config(local_ip, gateway, subnet, dns1, dns2);
404- WiFi.begin("ssid", "password");
404+ WiFi.STA.begin();
405+ WiFi.STA.config(local_ip, gateway, subnet, dns1, dns2);
406+ WiFi.STA.connect("ssid", "password");
405407 }
406408
407409 Hostname
@@ -418,8 +420,8 @@ Gets or sets the hostname for the specific interface.
418420
419421.. code-block :: arduino
420422
421- WiFi.setHostname("my-wifi-device");
422- Serial.println(WiFi.getHostname());
423+ WiFi.STA. setHostname("my-wifi-device");
424+ Serial.println(WiFi.STA. getHostname());
423425
424426 Status Checking
425427***************
@@ -439,15 +441,15 @@ Check the status of the network interface.
439441
440442.. code-block :: arduino
441443
442- if (WiFi.started()) {
444+ if (WiFi.STA. started()) {
443445 Serial.println("WiFi interface started");
444446 }
445447
446- if (WiFi.connected()) {
448+ if (WiFi.STA. connected()) {
447449 Serial.println("WiFi connected");
448450 }
449451
450- if (WiFi.hasIP()) {
452+ if (WiFi.STA. hasIP()) {
451453 Serial.println("WiFi has IP address");
452454 }
453455
@@ -464,10 +466,10 @@ Enables or disables IPv6 support on the interface.
464466
465467.. code-block :: arduino
466468
467- WiFi.enableIPv6(true);
469+ WiFi.STA. enableIPv6(true);
468470
469- if (WiFi.hasGlobalIPv6()) {
470- IPAddress ipv6 = WiFi.globalIPv6();
471+ if (WiFi.STA. hasGlobalIPv6()) {
472+ IPAddress ipv6 = WiFi.STA. globalIPv6();
471473 Serial.print("Global IPv6: ");
472474 Serial.println(ipv6);
473475 }
@@ -494,25 +496,25 @@ Get IP address information from the interface.
494496.. code-block :: arduino
495497
496498 Serial.print("Local IP: ");
497- Serial.println(WiFi.localIP());
499+ Serial.println(WiFi.STA. localIP());
498500
499501 Serial.print("Subnet Mask: ");
500- Serial.println(WiFi.subnetMask());
502+ Serial.println(WiFi.STA. subnetMask());
501503
502504 Serial.print("Gateway: ");
503- Serial.println(WiFi.gatewayIP());
505+ Serial.println(WiFi.STA. gatewayIP());
504506
505507 Serial.print("DNS: ");
506- Serial.println(WiFi.dnsIP());
508+ Serial.println(WiFi.STA. dnsIP());
507509
508510 Serial.print("Broadcast: ");
509- Serial.println(WiFi.broadcastIP());
511+ Serial.println(WiFi.STA. broadcastIP());
510512
511513 Serial.print("Network ID: ");
512- Serial.println(WiFi.networkID());
514+ Serial.println(WiFi.STA. networkID());
513515
514516 Serial.print("Subnet CIDR: /");
515- Serial.println(WiFi.subnetCIDR());
517+ Serial.println(WiFi.STA. subnetCIDR());
516518
517519 MAC Address
518520***********
@@ -529,7 +531,7 @@ Get the MAC address of the interface.
529531.. code-block :: arduino
530532
531533 uint8_t mac[6];
532- WiFi.macAddress(mac);
534+ WiFi.STA. macAddress(mac);
533535 Serial.print("MAC: ");
534536 for (int i = 0; i < 6; i++) {
535537 if (i > 0) Serial.print(":");
@@ -538,7 +540,7 @@ Get the MAC address of the interface.
538540 Serial.println();
539541
540542 // Or as String
541- Serial.println(WiFi.macAddress());
543+ Serial.println(WiFi.STA. macAddress());
542544
543545 Default Interface
544546*****************
@@ -554,12 +556,12 @@ Set this interface as the default network interface, or check if it is the defau
554556
555557.. code-block :: arduino
556558
557- // Set WiFi as default
558- WiFi.setDefault();
559+ // Set WiFi STA as default
560+ WiFi.STA. setDefault();
559561
560562 // Check if it's default
561- if (WiFi.isDefault()) {
562- Serial.println("WiFi is the default interface");
563+ if (WiFi.STA. isDefault()) {
564+ Serial.println("WiFi STA is the default interface");
563565 }
564566
565567 Route Priority
@@ -579,7 +581,7 @@ Gets or sets the route priority for the interface. Higher priority interfaces ar
579581 #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 5, 0)
580582 // Set higher priority for Ethernet
581583 ETH.setRoutePrio(100);
582- WiFi.setRoutePrio(50);
584+ WiFi.STA. setRoutePrio(50);
583585 #endif
584586
585587 Status Bits and Waiting
@@ -605,9 +607,9 @@ Get current status bits or wait for specific status bits to be set.
605607
606608.. code-block :: arduino
607609
608- // Wait for WiFi to get IP address (with 10 second timeout)
609- if (WiFi.waitStatusBits(ESP_NETIF_HAS_IP_BIT, 10000) & ESP_NETIF_HAS_IP_BIT) {
610- Serial.println("WiFi got IP address!");
610+ // Wait for WiFi STA to get IP address (with 10 second timeout)
611+ if (WiFi.STA. waitStatusBits(ESP_NETIF_HAS_IP_BIT, 10000) & ESP_NETIF_HAS_IP_BIT) {
612+ Serial.println("WiFi STA got IP address!");
611613 } else {
612614 Serial.println("Timeout waiting for IP address");
613615 }
@@ -630,24 +632,24 @@ Get interface identification and description information.
630632.. code-block :: arduino
631633
632634 Serial.print("Interface key: ");
633- Serial.println(WiFi.ifkey());
635+ Serial.println(WiFi.STA. ifkey());
634636
635637 Serial.print("Description: ");
636- Serial.println(WiFi.desc());
638+ Serial.println(WiFi.STA. desc());
637639
638640 Serial.print("Implementation name: ");
639- Serial.println(WiFi.impl_name());
641+ Serial.println(WiFi.STA. impl_name());
640642
641643 Serial.print("Implementation index: ");
642- Serial.println(WiFi.impl_index());
644+ Serial.println(WiFi.STA. impl_index());
643645
644646 Network Interface Implementations
645647----------------------------------
646648
647649Wi-Fi Station (STA)
648650********************
649651
650- The ``STAClass `` (accessed via ``WiFi `` object) extends ``NetworkInterface `` and provides Wi-Fi Station (client) mode functionality.
652+ The ``STAClass `` (accessed via ``WiFi.STA `` object) extends ``NetworkInterface `` and provides Wi-Fi Station (client) mode functionality.
651653
652654**Key Features: **
653655* Connect to Wi-Fi access points
@@ -664,24 +666,25 @@ The ``STAClass`` (accessed via ``WiFi`` object) extends ``NetworkInterface`` and
664666
665667 void setup() {
666668 Network.begin();
667- WiFi.begin("ssid", "password");
669+ WiFi.STA.begin();
670+ WiFi.STA.connect("ssid", "password");
668671
669- while (WiFi.status() != WL_CONNECTED) {
672+ while (WiFi.STA. status() != WL_CONNECTED) {
670673 delay(500);
671674 Serial.print(".");
672675 }
673676
674677 Serial.println();
675678 Serial.print("Connected! IP: ");
676- Serial.println(WiFi.localIP());
679+ Serial.println(WiFi.STA. localIP());
677680 }
678681
679682 For detailed Wi-Fi Station API documentation, see :doc: `wifi `.
680683
681684Wi-Fi Access Point (AP)
682685***********************
683686
684- The ``APClass `` (accessed via ``WiFiAP `` object) extends ``NetworkInterface `` and provides Wi-Fi Access Point mode functionality.
687+ The ``APClass `` (accessed via ``WiFi.AP `` object) extends ``NetworkInterface `` and provides Wi-Fi Access Point mode functionality.
685688
686689**Key Features: **
687690* Create Wi-Fi access points
@@ -697,11 +700,11 @@ The ``APClass`` (accessed via ``WiFiAP`` object) extends ``NetworkInterface`` an
697700
698701 void setup() {
699702 Network.begin();
700- WiFiAP .begin();
701- WiFiAP .create("MyESP32AP", "password123");
703+ WiFi.AP .begin();
704+ WiFi.AP .create("MyESP32AP", "password123");
702705
703706 Serial.print("AP IP: ");
704- Serial.println(WiFiAP .localIP());
707+ Serial.println(WiFi.AP .localIP());
705708 }
706709
707710 For detailed Wi-Fi AP API documentation, see :doc: `wifi `.
@@ -727,7 +730,7 @@ The ``ETHClass`` (accessed via ``ETH`` object) extends ``NetworkInterface`` and
727730 Network.begin();
728731 ETH.begin(ETH_PHY_TYPE, ETH_PHY_ADDR, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_POWER, ETH_CLK_MODE);
729732
730- while (!ETH.connected ()) {
733+ while (!ETH.hasIP ()) {
731734 delay(500);
732735 }
733736
@@ -759,7 +762,7 @@ The ``PPPClass`` (accessed via ``PPP`` object) extends ``NetworkInterface`` and
759762 PPP.begin(PPP_MODEM_SIM7600, 1, 115200);
760763 PPP.setApn("your.apn.here");
761764
762- while (!PPP.connected ()) {
765+ while (!PPP.hasIP ()) {
763766 delay(500);
764767 }
765768
@@ -797,8 +800,9 @@ The ``NetworkClient`` class provides TCP client functionality that works with an
797800
798801 void setup() {
799802 Network.begin();
800- WiFi.begin("ssid", "password");
801- while (WiFi.status() != WL_CONNECTED) delay(500);
803+ WiFi.STA.begin();
804+ WiFi.STA.connect("ssid", "password");
805+ while (WiFi.STA.status() != WL_CONNECTED) delay(500);
802806
803807 if (client.connect("www.example.com", 80)) {
804808 client.println("GET / HTTP/1.1");
@@ -835,8 +839,9 @@ The ``NetworkServer`` class provides TCP server functionality that works with an
835839
836840 void setup() {
837841 Network.begin();
838- WiFi.begin("ssid", "password");
839- while (WiFi.status() != WL_CONNECTED) delay(500);
842+ WiFi.STA.begin();
843+ WiFi.STA.connect("ssid", "password");
844+ while (WiFi.STA.status() != WL_CONNECTED) delay(500);
840845
841846 server.begin();
842847 Serial.print("Server started on: ");
@@ -873,8 +878,9 @@ The ``NetworkUdp`` class provides UDP communication that works with any network
873878
874879 void setup() {
875880 Network.begin();
876- WiFi.begin("ssid", "password");
877- while (WiFi.status() != WL_CONNECTED) delay(500);
881+ WiFi.STA.begin();
882+ WiFi.STA.connect("ssid", "password");
883+ while (WiFi.STA.status() != WL_CONNECTED) delay(500);
878884
879885 udp.begin(1234);
880886 }
@@ -916,18 +922,19 @@ The Network Manager allows you to manage multiple network interfaces simultaneou
916922 ETH.begin(ETH_PHY_TYPE, ETH_PHY_ADDR, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_POWER, ETH_CLK_MODE);
917923
918924 // Start WiFi as backup
919- WiFi.begin("ssid", "password");
925+ WiFi.STA.begin();
926+ WiFi.STA.connect("ssid", "password");
920927
921928 // Wait for either interface to connect
922- while (!ETH.connected() && WiFi.status() != WL_CONNECTED) {
929+ while (!ETH.connected() && WiFi.STA. status() != WL_CONNECTED) {
923930 delay(500);
924931 }
925932
926933 // Set the connected interface as default
927934 if (ETH.connected()) {
928935 Network.setDefaultInterface(ETH);
929936 Serial.println("Using Ethernet");
930- } else if (WiFi.status() == WL_CONNECTED) {
937+ } else if (WiFi.STA. status() == WL_CONNECTED) {
931938 Network.setDefaultInterface(WiFi);
932939 Serial.println("Using WiFi");
933940 }
@@ -942,12 +949,13 @@ The Network Manager allows you to manage multiple network interfaces simultaneou
942949
943950 // Start both interfaces
944951 ETH.begin(...);
945- WiFi.begin("ssid", "password");
952+ WiFi.STA.begin();
953+ WiFi.STA.connect("ssid", "password");
946954
947955 // Set route priorities (ESP-IDF 5.5+)
948956 #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 5, 0)
949957 ETH.setRoutePrio(100); // Higher priority
950- WiFi.setRoutePrio(50); // Lower priority
958+ WiFi.STA. setRoutePrio(50); // Lower priority
951959 #endif
952960
953961 // Ethernet will be preferred for routing when both are connected
@@ -1013,7 +1021,8 @@ Event Handling Examples
10131021 void setup() {
10141022 Network.begin();
10151023 Network.onEvent(onWiFiEvent, ARDUINO_EVENT_WIFI_STA_GOT_IP);
1016- WiFi.begin("ssid", "password");
1024+ WiFi.STA.begin();
1025+ WiFi.STA.connect("ssid", "password");
10171026 }
10181027
10191028 Troubleshooting
@@ -1047,7 +1056,5 @@ Troubleshooting
10471056Related Documentation
10481057---------------------
10491058
1050- * :doc: `wifi ` - Wi-Fi API documentation
1051- * :doc: `ethernet ` - Ethernet API documentation
10521059* `ESP-IDF Network Interface Documentation <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_netif.html >`_
10531060
0 commit comments