Skip to content

document WiFi.config Arduino parameters versions #9045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Changes from all 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
15 changes: 15 additions & 0 deletions doc/esp8266wifi/station-class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ Note that to reenable DHCP, all three parameters as 0.0.0.0 (local_ip, gateway a

.. code:: cpp

WiFi.config(local_ip, gateway, subnet)
WiFi.config(local_ip, gateway, subnet, dns1)
WiFi.config(local_ip, gateway, subnet, dns1, dns2)

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.
Expand All @@ -120,6 +122,19 @@ The following IP configuration may be provided:
(like e.g. *www.google.co.uk*) and translate them for us to IP
addresses

For Arduino networking API compatibilty the ESP8266WiFi library supports for IPv4 additional versions of the ``config`` function.

.. code:: cpp

WiFi.config(local_ip)
WiFi.config(local_ip, dns)
WiFi.config(local_ip, dns, gateway)
WiFi.config(local_ip, dns, gateway, subnet)

Versions where some of ``dns``, ``gateway`` and ``subnet`` parameters are not specified use a default value. Default ``subnet`` is 255.255.255.0. Default ``gateway`` and ``dns`` are derived from ``local_ip`` by changing the last number to 1. To return to DHCP you can use ``WiFi.config(INADDR_NONE);``.

**Warning: The default values for dns, gateway and subnet may not match your router's settings.** Also please note, that ``config(local_ip, gateway)`` is not supported and ``WiFi.config(local_ip, gateway, subnet)`` doesn't set the DNS server IP.

*Example code:*

.. code:: cpp
Expand Down