You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: doc/esp8266wifi/station-class.rst
+21-19
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ By default, ESP will attempt to reconnect to Wi-Fi network whenever it is discon
62
62
begin
63
63
^^^^^
64
64
65
-
There are several versions (called *`function overloads <https://en.wikipedia.org/wiki/Function_overloading>`__* in C++) of ``begin`` function. One was presented just above:
65
+
There are several versions (called `function overloads <https://en.wikipedia.org/wiki/Function_overloading>`__ in C++) of ``begin`` function. One was presented just above:
66
66
``WiFi.begin(ssid, password)``. Overloads provide flexibility in number or type of accepted parameters.
67
67
68
68
The simplest overload of ``begin`` is as follows:
@@ -71,7 +71,9 @@ The simplest overload of ``begin`` is as follows:
71
71
72
72
WiFi.begin()
73
73
74
-
Calling it will instruct module to switch to the station mode and connect to the last used access point basing on configuration saved in flash memory.
74
+
Calling it will enable station mode and connect to the last used access point based on configuration saved in flash memory.
75
+
76
+
Notes: \* It is possible that calling ``begin`` will result in the module being in STA + softAP mode if the module was previously placed into AP mode. \* If you notice strange behavior with DNS or other network functionality, check which mode your module is in (see ``WiFi.mode()`` in the `Generic Class Documentation <generic-class.rst#mode>`__).
75
77
76
78
Below is the syntax of another overload of ``begin`` with the all possible parameters:
Function will return ``true`` if configuration change is applied successfully. If configuration can not be applied, because e.g. module is not in station or station + soft access point mode, then ``false`` will be returned.
95
97
@@ -160,7 +162,7 @@ Reconnect the station. This is done by disconnecting from the access point an th
160
162
161
163
.. code:: cpp
162
164
163
-
WiFi.reconnect()
165
+
WiFi.reconnect()
164
166
165
167
Notes: 1. Station should be already connected to an access point. If this is not the case, then function will return ``false`` not performing any action. 2. If ``true`` is returned it means that connection sequence has been successfully started. User should still check for connection status, waiting until ``WL_CONNECTED`` is reported:
166
168
@@ -180,7 +182,7 @@ Sets currently configured SSID and password to ``null`` values and disconnects t
180
182
181
183
.. code:: cpp
182
184
183
-
WiFi.disconnect(wifioff)
185
+
WiFi.disconnect(wifioff)
184
186
185
187
The ``wifioff`` is an optional ``boolean`` parameter. If set to ``true``, then the station mode will be turned off.
186
188
@@ -191,7 +193,7 @@ Returns ``true`` if Station is connected to an access point or ``false`` if not.
191
193
192
194
.. code:: cpp
193
195
194
-
WiFi.isConnected()
196
+
WiFi.isConnected()
195
197
196
198
setAutoConnect
197
199
^^^^^^^^^^^^^^
@@ -200,7 +202,7 @@ Configure module to automatically connect on power on to the last used access po
200
202
201
203
.. code:: cpp
202
204
203
-
WiFi.setAutoConnect(autoConnect)
205
+
WiFi.setAutoConnect(autoConnect)
204
206
205
207
The ``autoConnect`` is an optional parameter. If set to ``false`` then auto connection functionality up will be disabled. If omitted or set to ``true``, then auto connection will be enabled.
206
208
@@ -222,7 +224,7 @@ Set whether module will attempt to reconnect to an access point in case it is di
222
224
223
225
.. code:: cpp
224
226
225
-
WiFi.setAutoReconnect(autoReconnect)
227
+
WiFi.setAutoReconnect(autoReconnect)
226
228
227
229
If parameter ``autoReconnect`` is set to ``true``, then module will try to reestablish lost connection to the AP. If set to ``false`` then module will stay disconnected.
228
230
@@ -235,7 +237,7 @@ Wait until module connects to the access point. This function is intended for mo
235
237
236
238
.. code:: cpp
237
239
238
-
WiFi.waitForConnectResult()
240
+
WiFi.waitForConnectResult()
239
241
240
242
Function returns one of the following connection statuses: \* ``WL_CONNECTED`` after successful connection is established \* ``WL_NO_SSID_AVAIL``\ in case configured SSID cannot be reached \* ``WL_CONNECT_FAILED`` if password is incorrect \* ``WL_IDLE_STATUS`` when Wi-Fi is in process of changing between statuses \* ``WL_DISCONNECTED`` if module is not configured in station mode
241
243
@@ -249,7 +251,7 @@ Get the MAC address of the ESP station's interface.
249
251
250
252
.. code:: cpp
251
253
252
-
WiFi.macAddress(mac)
254
+
WiFi.macAddress(mac)
253
255
254
256
Function should be provided with ``mac`` that is a pointer to memory location (an ``uint8_t`` array the size of 6 elements) to save the mac address. The same pointer value is returned by the function itself.
255
257
@@ -274,7 +276,7 @@ If you do not feel comfortable with pointers, then there is optional version of
274
276
275
277
.. code:: cpp
276
278
277
-
WiFi.macAddress()
279
+
WiFi.macAddress()
278
280
279
281
*Example code:*
280
282
@@ -292,7 +294,7 @@ Function used to obtain IP address of ESP station's interface.
292
294
293
295
.. code:: cpp
294
296
295
-
WiFi.localIP()
297
+
WiFi.localIP()
296
298
297
299
The type of returned value is `IPAddress <https://github.com/esp8266/Arduino/blob/master/cores/esp8266/IPAddress.h>`__. There is a couple of methods available to display this type of data. They are presented in examples below that cover description of ``subnetMask``, ``gatewayIP`` and ``dnsIP`` that return the IPAdress as well.
298
300
@@ -399,7 +401,7 @@ The hostname may be changed using the following function:
399
401
400
402
.. code:: cpp
401
403
402
-
WiFi.hostname(aHostname)
404
+
WiFi.hostname(aHostname)
403
405
404
406
Input parameter ``aHostname`` may be a type of ``char*``, ``const char*`` or ``String``. Maximum length of assigned hostname is 32 characters. Function returns either ``true`` or ``false`` depending on result. For instance, if the limit of 32 characters is exceeded, function will return ``false`` without assigning the new hostname.
405
407
@@ -427,7 +429,7 @@ Return the status of Wi-Fi connection.
427
429
428
430
WiFi.status()
429
431
430
-
Function returns one of the following connection statuses:
432
+
Function returns one of the following connection statuses:
431
433
432
434
- ``WL_CONNECTED`` after successful connection is established
433
435
- ``WL_NO_SSID_AVAIL`` in case configured SSID cannot be reached
@@ -531,7 +533,7 @@ Below is similar function, but returning BSSID but as a ``String`` type.
531
533
532
534
.. code:: cpp
533
535
534
-
WiFi.BSSIDstr()
536
+
WiFi.BSSIDstr()
535
537
536
538
*Example code:*
537
539
@@ -552,7 +554,7 @@ Return the signal strength of Wi-Fi network, that is formally called `Received S
552
554
553
555
.. code:: cpp
554
556
555
-
WiFi.RSSI()
557
+
WiFi.RSSI()
556
558
557
559
Signal strength value is provided in dBm. The type of returned value is ``int32_t``.
558
560
@@ -615,7 +617,7 @@ Depending on connection result function returns either ``true`` or ``false`` (``
615
617
616
618
::
617
619
618
-
Wi-Fi mode set to WIFI_STA
620
+
Wi-Fi mode set to WIFI_STA
619
621
Begin WPS (press WPS button on your router) ... Success
620
622
.........
621
623
Connected, IP address: 192.168.1.102
@@ -631,7 +633,7 @@ Start smart configuration mode by sniffing for special packets that contain SSID
631
633
632
634
.. code:: cpp
633
635
634
-
beginSmartConfig()
636
+
beginSmartConfig()
635
637
636
638
Query Smart Config status, to decide when stop configuration. Function returns either ``true`` or ``false of``\ boolean\` type.
637
639
@@ -643,6 +645,6 @@ Stop smart config, free the buffer taken by ``beginSmartConfig()``. Depending on
643
645
644
646
.. code:: cpp
645
647
646
-
stopSmartConfig()
648
+
stopSmartConfig()
647
649
648
650
For additional details regarding Smart Config please refer to `ESP8266 API User Guide <http://bbs.espressif.com/viewtopic.php?f=51&t=1023>`__.
0 commit comments