mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
WiFi config(): warning for legacy idioms (#9050)
This commit is contained in:
parent
cb9734c97d
commit
d5eb265f78
@ -69,7 +69,10 @@ public:
|
|||||||
const IPAddress& arg3 = IPADDR_NONE, const IPAddress& dns2 = IPADDR_NONE);
|
const IPAddress& arg3 = IPADDR_NONE, const IPAddress& dns2 = IPADDR_NONE);
|
||||||
|
|
||||||
// two and one parameter version. 2nd parameter is DNS like in Arduino. IPv4 only
|
// two and one parameter version. 2nd parameter is DNS like in Arduino. IPv4 only
|
||||||
boolean config(IPAddress local_ip, IPAddress dns = INADDR_ANY);
|
[[deprecated("It is discouraged to use this 1 or 2 parameters network configuration legacy "
|
||||||
|
"function config(ip[,dns]) as chosen defaults may not match the local network "
|
||||||
|
"configuration")]] boolean
|
||||||
|
config(IPAddress local_ip, IPAddress dns = INADDR_ANY);
|
||||||
|
|
||||||
// default mac-address is inferred from esp8266's STA interface
|
// default mac-address is inferred from esp8266's STA interface
|
||||||
boolean begin(const uint8_t* macAddress = nullptr, const uint16_t mtu = DEFAULT_MTU);
|
boolean begin(const uint8_t* macAddress = nullptr, const uint16_t mtu = DEFAULT_MTU);
|
||||||
|
@ -99,11 +99,11 @@ config
|
|||||||
|
|
||||||
Disable `DHCP <https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol>`__ client (Dynamic Host Configuration Protocol) and set the IP configuration of station interface to user defined arbitrary values. The interface will be a static IP configuration instead of values provided by DHCP.
|
Disable `DHCP <https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol>`__ client (Dynamic Host Configuration Protocol) and set the IP configuration of station interface to user defined arbitrary values. The interface will be a static IP configuration instead of values provided by DHCP.
|
||||||
|
|
||||||
Note that to reenable DHCP, all three parameters as 0.0.0.0 (local_ip, gateway and subnet as ``INADDR_ANY``) must be passed back to config() and re-connecting is needed.
|
Note that to reenable DHCP, all three parameters (local_ip, gateway and subnet) as IPv4 ``0U`` (= 0.0.0.0) must be passed back to config() and re-connecting is needed.
|
||||||
|
|
||||||
.. code:: cpp
|
.. code:: cpp
|
||||||
|
|
||||||
WiFi.config(local_ip, gateway, subnet)
|
WiFi.config(local_ip, gateway, subnet) (for Arduino API portability, discouraged as chosen defaults may not match the local network configuration)
|
||||||
WiFi.config(local_ip, gateway, subnet, dns1)
|
WiFi.config(local_ip, gateway, subnet, dns1)
|
||||||
WiFi.config(local_ip, gateway, subnet, dns1, dns2)
|
WiFi.config(local_ip, gateway, subnet, dns1, dns2)
|
||||||
|
|
||||||
@ -122,16 +122,18 @@ The following IP configuration may be provided:
|
|||||||
(like e.g. *www.google.co.uk*) and translate them for us to IP
|
(like e.g. *www.google.co.uk*) and translate them for us to IP
|
||||||
addresses
|
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
|
.. code:: cpp
|
||||||
|
|
||||||
WiFi.config(local_ip)
|
WiFi.config(local_ip) (for Arduino API portability, discouraged as chosen defaults may not match the local network configuration)
|
||||||
WiFi.config(local_ip, dns)
|
WiFi.config(local_ip, dns) (for Arduino API portability, discouraged as chosen defaults may not match the local network configuration)
|
||||||
WiFi.config(local_ip, dns, gateway)
|
WiFi.config(local_ip, dns, gateway) (for Arduino API portability, discouraged as chosen defaults may not match the local network configuration)
|
||||||
WiFi.config(local_ip, dns, gateway, subnet)
|
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. It is discouraged to use these default values as they may not apply to every network configuration.
|
||||||
|
|
||||||
|
Reminder : To reenable DHCP you can use ``WiFi.config(0U, 0U, 0U);``.
|
||||||
|
|
||||||
**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.
|
**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.
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ class ESP8266WiFiSTAClass: public LwipIntf {
|
|||||||
|
|
||||||
// two and one parameter version. 2nd parameter is DNS like in Arduino
|
// two and one parameter version. 2nd parameter is DNS like in Arduino
|
||||||
// IPv4 only
|
// IPv4 only
|
||||||
|
[[deprecated("It is discouraged to use this 1 or 2 parameters network configuration legacy function config(ip[,dns]) as chosen defaults may not match the local network configuration")]]
|
||||||
bool config(IPAddress local_ip, IPAddress dns = INADDR_ANY);
|
bool config(IPAddress local_ip, IPAddress dns = INADDR_ANY);
|
||||||
|
|
||||||
bool setDNS(IPAddress dns1, IPAddress dns2 = INADDR_ANY);
|
bool setDNS(IPAddress dns1, IPAddress dns2 = INADDR_ANY);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user