Chapter 2. API Reference
A) User code, boiler plate
configured TCP/IP network stack is abstracted using ESP-NETIF APIs and outlined as below:
A) Initialization code
1) Initializes IO driver
2) Creates a new instance of ESP-NETIF and configure with
• ESP-NETIF specific options (flags, behaviour, name)
• Network stack options (netif init and input functions, not publicly available)
• IO driver specific options (transmit, free rx buffer functions, IO driver handle)
3) Attaches the IO driver handle to the ESP-NETIF instance created in the above steps
4) Configures event handlers
• use default handlers for common interfaces defined in IO drivers; or define a specific handlers for
customised behaviour/new interfaces
• register handlers for app related events (such as IP lost/acquired)
B) Interaction with network interfaces using ESP-NETIF API
• Getting and setting TCP/IP related parameters (DHCP, IP, etc)
• Receiving IP events (connect/disconnect)
• Controlling application lifecycle (set interface up/down)
B) Communication driver, IO driver, media driver
relation with ESP-NETIF:
1) Event handlers: Define behaviour patterns of interaction with ESP-NETIF (for example: ethernet link-up ->
turn netif on)
2) Glue IO layer: Adapts the input/output functions to use ESP-NETIF transmit, receive and free receive buffer
• Installs driver_transmit to appropriate ESP-NETIF object, so that outgoing packets from network stack are
passed to the IO driver
• Calls
esp_netif_receive()
C) ESP-NETIF, former tcpip_adapter
connecting packet data path between these two. As that it provides a set of interfaces for attaching a driver to ESP-
NETIF object (runtime) and configuring a network stack (compile time). In addition to that a set of API is provided
to control network interface lifecycle and its TCP/IP properties. As an overview, the ESP-NETIF public interface
could be divided into these 6 groups:
1) Initialization APIs (to create and configure ESP-NETIF instance)
2) Input/Output API (for passing data between IO driver and network stack)
3) Event or Action API
• Used for network interface lifecycle management
• ESP-NETIF provides building blocks for designing event handlers
4) Setters and Getters for basic network interface properties
5) Network stack abstraction: enabling user interaction with TCP/IP stack
• Set interface up or down
• DHCP server and client API
• DNS API
6) Driver conversion utilities
D) Network stack
Network stack has no public interaction with application code with regard to public interfaces
and shall be fully abstracted by ESP-NETIF API.
Espressif Systems
Overall application interaction with a specific IO driver for communication media and
to pass incoming data to network stack
ESP-NETIF is an intermediary between an IO driver and a network stack,
198
Submit Document Feedback
Communication driver plays these two important roles in
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?