Skip to content
Merged
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: 6 additions & 6 deletions doc/esp8266wifi/station-class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ 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) (discouraged, dns is not set but it is useful)
WiFi.config(local_ip, gateway, subnet, dns1)
WiFi.config(local_ip, gateway, subnet, dns1, dns2)

Expand All @@ -122,16 +122,16 @@ 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.
For Arduino networking API compatibility, the ESP8266WiFi library supports IPv4-only 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) (discouraged, for retro compatibility: dns=gateway=···.1)
WiFi.config(local_ip, dns) (discouraged, for retro compatibility: gateway=···.1)
WiFi.config(local_ip, dns, gateway) (discouraged, for retro compatibility: subnet/netmask quite unavoidable)
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);``.
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 (discouraged). 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.

Expand Down
1 change: 1 addition & 0 deletions libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class ESP8266WiFiSTAClass: public LwipIntf {

// two and one parameter version. 2nd parameter is DNS like in Arduino
// IPv4 only
[[deprecated("It is discouraged to use this 1 or 2 parameters network configuration legacy function config(ip[,dns]) because it sets the router (and ommited dns) to an arbitrary address")]]
bool config(IPAddress local_ip, IPAddress dns = INADDR_ANY);

bool setDNS(IPAddress dns1, IPAddress dns2 = INADDR_ANY);
Expand Down