Skip to content

Commit ea76db7

Browse files
committed
docs(esp_netif): Update ESP-NETIF programming manual
1 parent 91f04d7 commit ea76db7

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

docs/en/api-reference/network/esp_netif.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,12 @@ In same cases, it is not enough to simply initialize a network interface by defa
291291

292292
You would typically need to use specific sets of ESP-NETIF APIs in the following use-cases:
293293

294-
* Set or get IP and DNS information
295-
* Configure DHCP client or server
296-
* Start SNTP service
297-
* Use L2 TAP interface
298-
* Use other IP events
299-
* Use multiple network interfaces
294+
* :ref:`esp_netif_set_ip`
295+
* :ref:`esp_netif_set_dhcp`
296+
* :ref:`esp_netif-sntp-api`
297+
* :ref:`esp_netif_l2tap`
298+
* :ref:`esp_netif_other_events`
299+
* :ref:`esp_netif_api_reference`
300300

301301
.. _esp_netif_developer:
302302

docs/en/api-reference/network/esp_netif_programming.rst

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,26 @@ ESP-NETIF Programmers Manual
33

44
:link_to_translation:`zh_CN:[中文]`
55

6+
.. _esp_netif_set_ip:
67

7-
Configure DNS servers
8-
---------------------
8+
Configure IP, GW and DNS
9+
------------------------
910

11+
We typically obtain IP addresses (including gateway, network mask, and DNS servers) automatically from DHCP or Router Advertisement services and receive notifications by means of ``IP_EVENT`` with IP address information. It is also possible to read the current address information using :cpp:func:`esp_netif_get_ip_info()`, which returns this address structure :cpp:type:`esp_netif_ip_info_t` containing IPv4 address of the network interface with the network mask and gateway address. Similarly, you can use :cpp:func:`esp_netif_get_all_ip6()` to obtain all IPv6 addresses of the interface.
1012

13+
In order to configure static IP addresses and DNS servers, it's necessary to disable or stop DHCP client (which is enabled by default on some network interfaces, such as the default Ethernet, or the default WiFi station). Please refer to the example :example:`/protocols/static_ip` for more details.
1114

15+
To set IPv4 address, you can use :cpp:func:`esp_netif_set_ip_info()`. For IPv6, these two functions can be used for adding or removing addresses: :cpp:func:`esp_netif_add_ip6_address()`, :cpp:func:`esp_netif_remove_ip6_address()`.
16+
To configure DNS servers, please use :cpp:func:`esp_netif_set_dns_info()` API.
17+
18+
.. _esp_netif_set_dhcp:
1219

1320
Configure DHCP options
1421
----------------------
1522

23+
Some network interfaces are pre-configured to use either a DHCP client (typically the Ethernet interface) or a DHCP server (typically a WiFi software access point). When creating a custom network interface manually, these configuration flags :cpp:type:`esp_netif_flags_t` are used to specify the behavioral options of this interface, so adding :cpp:enumerator:`ESP_NETIF_DHCP_CLIENT` or :cpp:enumerator:`ESP_NETIF_DHCP_SERVER` will enable DHCP client or server respectively. Note that these two options are mutually exclusive and cannot be altered runtime, so an interface configured with the DHCP server on creating cannot be used to start a DHCP server.
1624

25+
In order to set or get a specific DHCP option, we use this common type :cpp:type:`esp_netif_dhcp_option_id_t` for both DHCP server and DHCP client, but not all options are supported for both server and client. Please refer to the API documentation of :cpp:func:`esp_netif_dhcpc_option()` to see which options are available for the DHCP client. Conversely, consult the API documentation of :cpp:func:`esp_netif_dhcps_option()` on the options available for the DHCP server.
1726

1827
.. _esp_netif-sntp-api:
1928

@@ -88,6 +97,7 @@ The typical configuration now looks as per below, providing the specific ``IP_EV
8897
Then we start the service normally with :cpp:func:`esp_netif_sntp_start()`.
8998

9099

100+
.. _esp_netif_l2tap:
91101

92102
L2 TAP Interface Usage Manual
93103
-----------------------------
@@ -188,6 +198,8 @@ Opened ESP-NETIF L2 TAP file descriptor can be closed by the ``close()`` to free
188198
Select is used in a standard way, just :ref:`CONFIG_VFS_SUPPORT_SELECT` needs to be enabled to make the ``select()`` function available.
189199

190200

201+
.. _esp_netif_other_events:
202+
191203
IP Event: Transmit/Receive Packet
192204
---------------------------------
193205

@@ -240,6 +252,8 @@ The event data structure, :cpp:class:`ip_event_tx_rx_t`, contains the following
240252
- :cpp:member:`ip_event_tx_rx_t::esp_netif`: The network interface on which the packet was sent or received.
241253

242254

255+
.. _esp_netif_api_reference:
256+
243257
API Reference
244258
-------------
245259

0 commit comments

Comments
 (0)