Skip to content

Commit 25d0d9c

Browse files
Shen7436david-cermak
authored andcommitted
docs: Update CN translation for ESP-NETIF docs
1 parent 9b550d7 commit 25d0d9c

File tree

5 files changed

+255
-370
lines changed

5 files changed

+255
-370
lines changed

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

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -33,44 +33,45 @@ It is usually just enough to create a default network interface after startup an
3333
Initialization
3434
--------------
3535

36-
Since the ESP-NETIF component uses system events, the typical network startup code looks like this (note, that error handling is omitted for clarity, see :example_file:`ethernet/basic/main/ethernet_example_main.c` for complete startup code):
36+
Since the ESP-NETIF component uses system events, the typical network startup code looks like this (note that error handling is omitted for clarity, see :example_file:`ethernet/basic/main/ethernet_example_main.c` for complete startup code):
3737

3838
.. code-block:: c
3939
40-
// 1) Initialize the TCP/IP stack and the event loop
41-
esp_netif_init();
42-
esp_event_loop_create_default();
40+
// 1) Initialize the TCP/IP stack and the event loop
41+
esp_netif_init();
42+
esp_event_loop_create_default();
4343
44-
// 2) Create the network interface handle
45-
esp_netif = esp_netif_new(&config);
44+
// 2) Create the network interface handle
45+
esp_netif = esp_netif_new(&config);
4646
47-
// 3) Create the network interface driver (e.g. Ethernet) and it's network layer glue
48-
// and register the ESP-NETIF event (e.g. to bring the interface up upon link-up event)
49-
esp_netif_glue_t glue = driver_glue(driver);
47+
// 3) Create the network interface driver (e.g., Ethernet) and it's network layer glue
48+
// and register the ESP-NETIF event (e.g., to bring the interface up upon link-up event)
49+
esp_netif_glue_t glue = driver_glue(driver);
5050
51-
// 4) Attach the driver's glue layer to the network interface handle
52-
esp_netif_attach(esp_netif, glue);
51+
// 4) Attach the driver's glue layer to the network interface handle
52+
esp_netif_attach(esp_netif, glue);
5353
54-
// 5) Register user-side event handlers
55-
esp_event_handler_register(DRIVER_EVENT, ...); // to observe driver states, e.g. link-up
56-
esp_event_handler_register(IP_EVENT, ...); // to observe ESP-NETIF states, e.g. get an IP
54+
// 5) Register user-side event handlers
55+
esp_event_handler_register(DRIVER_EVENT, ...); // to observe driver states, e.g., link-up
56+
esp_event_handler_register(IP_EVENT, ...); // to observe ESP-NETIF states, e.g., get an IP
5757
5858
5959
.. note::
6060

61-
These steps must be performed in the exact order shown above, primarily due to the default event loop used by network interface drivers to register system events.
61+
These steps must be performed in the exact order shown above, as the network interface drivers use the default event loop when registering system events.
6262

63-
- The default event loop needs to be created **before** initializing an interface driver, as the driver typically needs to register system event handlers.
64-
- Registering application event handlers must occur **after** calling :cpp:func:`esp_netif_attach`, because event handlers are called in the order they were registered. To ensure that system handlers are called first, you should register application handlers afterward.
63+
- The default event loop needs to be created **before** initializing an interface driver, as the driver typically needs to register system event handlers.
64+
- Registering application event handlers must occur **after** calling :cpp:func:`esp_netif_attach`, because event handlers are called in the order they were registered. To ensure that system handlers are called first, you should register application handlers afterward.
6565

66-
Steps ``2)``, ``3)`` and ``4)`` are quite complex for most common use-cases, so ESP-NETIF provides some pre-configured interfaces and convenience functions that create the most common network interfaces in their most common configurations.
66+
Steps ``2)``, ``3)`` and ``4)`` are quite complex for most common use-cases, so ESP-NETIF provides some pre-configured interfaces and convenience functions that create the most common network interfaces in their most common configurations.
6767

6868
.. note::
6969

7070
Each network interface needs to be initialized separately, so if you would like to use multiple interfaces, you would have to run steps ``2)`` to ``5)`` for every interface. Set ``1)`` should be performed only once.
7171

7272

7373
Creating and configuring the interface and attaching the network interface driver to it (steps ``2)``, ``3)`` and ``4)``) is described in :ref:`create_esp_netif`.
74+
7475
Using the ESP-NETIF event handlers (step ``5)``) is described in :ref:`esp-netif-ip-events`.
7576

7677

@@ -120,7 +121,7 @@ The initialization code as well as registering event handlers for default interf
120121

121122
.. only:: CONFIG_ESP_WIFI_SOFTAP_SUPPORT
122123

123-
* When using Wi-Fi in ``AP+STA`` mode, both these interfaces have to be created. Please refer to the example :example_file:`wifi/softap_sta/main/softap_sta.c`
124+
* When using Wi-Fi in ``AP+STA`` mode, both these interfaces have to be created. Please refer to the example :example_file:`wifi/softap_sta/main/softap_sta.c`.
124125

125126
.. _esp-netif-ip-events:
126127

@@ -137,7 +138,7 @@ Registering event handlers is crucial due to the asynchronous nature of networki
137138

138139
.. note::
139140

140-
Lost IP events are triggered by a timer configurable by :ref:`CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL`. The timer is started upon losing the IP address and the event will be raised after the configured interval, which is 120s by default. The event could be disabled when setting the interval to 0.
141+
Lost IP events are triggered by a timer configurable by :ref:`CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL`. The timer is started upon losing the IP address and the event will be raised after the configured interval, which is 120 s by default. The event could be disabled when setting the interval to 0.
141142

142143
.. _esp-netif structure:
143144

@@ -207,24 +208,24 @@ Overall application interaction with a specific IO driver for the communication
207208

208209
A) Initialization code
209210

210-
1) Initializes IO driver
211-
2) Creates a new instance of ESP-NETIF and configure it with
211+
1) Initializes IO driver
212+
2) Creates a new instance of ESP-NETIF and configure it with
212213

213-
* ESP-NETIF specific options (flags, behavior, name)
214-
* Network stack options (netif init and input functions, not publicly available)
215-
* IO driver specific options (transmit, free rx buffer functions, IO driver handle)
214+
* ESP-NETIF specific options (flags, behavior, name)
215+
* Network stack options (netif init and input functions, not publicly available)
216+
* IO driver specific options (transmit, free rx buffer functions, IO driver handle)
216217

217-
3) Attaches the IO driver handle to the ESP-NETIF instance created in the above steps
218-
4) Configures event handlers
218+
3) Attaches the IO driver handle to the ESP-NETIF instance created in the above steps
219+
4) Configures event handlers
219220

220-
* Use default handlers for common interfaces defined in IO drivers; or define a specific handler for customized behavior or new interfaces
221-
* Register handlers for app-related events (such as IP lost or acquired)
221+
* Use default handlers for common interfaces defined in IO drivers; or define a specific handler for customized behavior or new interfaces
222+
* Register handlers for app-related events (such as IP lost or acquired)
222223

223224
B) Interaction with network interfaces using ESP-NETIF API
224225

225-
1) Gets and sets TCP/IP-related parameters (DHCP, IP, etc)
226-
2) Receives IP events (connect or disconnect)
227-
3) Controls application lifecycle (set interface up or down)
226+
1) Gets and sets TCP/IP-related parameters (DHCP, IP, etc)
227+
2) Receives IP events (connect or disconnect)
228+
3) Controls application lifecycle (set interface up or down)
228229

229230

230231
B) Network Interface Driver
@@ -236,8 +237,8 @@ Network interface driver (also called I/O Driver, or Media Driver) plays these t
236237

237238
2) Glue IO layer: Adapts the input or output functions to use ESP-NETIF transmit, receive, and free receive buffer
238239

239-
* Installs driver_transmit to the appropriate ESP-NETIF object so that outgoing packets from the network stack are passed to the IO driver
240-
* Calls :cpp:func:`esp_netif_receive()` to pass incoming data to the network stack
240+
* Installs driver_transmit to the appropriate ESP-NETIF object so that outgoing packets from the network stack are passed to the IO driver
241+
* Calls :cpp:func:`esp_netif_receive()` to pass incoming data to the network stack
241242

242243

243244
C) ESP-NETIF
@@ -249,16 +250,16 @@ ESP-NETIF serves as an intermediary between an IO driver and a network stack, co
249250
2) Input or Output API (for passing data between IO driver and network stack)
250251
3) Event or Action API
251252

252-
* Used for network interface lifecycle management
253-
* ESP-NETIF provides building blocks for designing event handlers
253+
* Used for network interface lifecycle management
254+
* ESP-NETIF provides building blocks for designing event handlers
254255

255256
4) Setters and Getters API for basic network interface properties
256257
5) Network stack abstraction API: enabling user interaction with TCP/IP stack
257258

258-
* Set interface up or down
259-
* DHCP server and client API
260-
* DNS API
261-
* :ref:`esp_netif-sntp-api`
259+
* Set interface up or down
260+
* DHCP server and client API
261+
* DNS API
262+
* :ref:`esp_netif-sntp-api`
262263

263264
6) Driver conversion utilities API
264265

@@ -271,6 +272,7 @@ The network stack has no public interaction with application code with regard to
271272

272273
E) ESP-NETIF L2 TAP Interface
273274
'''''''''''''''''''''''''''''
275+
274276
The ESP-NETIF L2 TAP interface is a mechanism in ESP-IDF used to access Data Link Layer (L2 per OSI/ISO) for frame reception and transmission from the user application. Its typical usage in the embedded world might be the implementation of non-IP-related protocols, e.g., PTP, Wake on LAN. Note that only Ethernet (IEEE 802.3) is currently supported. Please read more about L2 TAP in :ref:`esp_netif_l2tap`.
275277

276278
.. _esp_netif_programmer:

0 commit comments

Comments
 (0)