Espressif ESP32-S2 Programming Manual page 222

Table of Contents

Advertisement

Chapter 2. API Reference
Network interface creation
• WiFi Station
• WiFi Access Point
• Ethernet
Network interface instance shall be explicitly constructed for the
nection to the TCP/IP stack.
esp_netif_create_default_wifi_sta(); or esp_netif_create_default_wifi_ap();
after the TCP/IP stack and the event loop have been initialized. Please consult an example initialization code for
these three interfaces:
• WiFi Station:
wifi/getting_started/station/main/station_example_main.c
• WiFi Access Point:
• Ethernet:
ethernet/basic/main/ethernet_example_main.c
Replacing other tcpip_adapter API
refer to the esp_netif.h grouped into these sections:
Setters/Getters
DHCP
DNS
IP address
Default event handlers
change from application code perspective, all events shall be handled in the same way. Please note that within IP
related event handlers, application code usually receives IP addresses in a form of esp-netif specific struct (not the
LwIP structs, but binary compatible). This is the preferred way of printing the address:
ESP_LOGI(TAG,
"got ip:"
Instead of
ESP_LOGI(TAG,
"got
ip:%s\n", ip4addr_ntoa(&event->ip_info.ip));
Since ip4addr_ntoa() is a LwIP API, the esp-netif provides esp_ip4addr_ntoa() as a replacement, but
the above method is generally preferred.
IP addresses
It is preferred to use esp-netif defined IP structures. Please note that the LwIP structs will still work
when default compatibility enabled. *
Next steps
Additional step in porting an application to fully benefit from the
tcpip_adapter compatibility layer in the component configuration: ESP NETIF Adapter -> Enable back-
ward compatible tcpip_adapter interface and check if the project compiles. TCP/IP adapter brings
many include dependencies and this step might help in decoupling the application from using specific TCP/IP stack
API directly.
ESP-NETIF Custom I/O Driver
This section outlines implementing a new I/O driver with esp-netif connection capabilities. By convention the I/O
driver has to register itself as an esp-netif driver and thus holds a dependency on esp-netif component and is responsible
for providing data path functions, post-attach callback and in most cases also default event handlers to define network
interface actions based on driver's lifecycle transitions.
Espressif Systems
TCP/IP Adapter defined these three interfaces statically:
For example initialization code for WiFi has to explicitly call
wifi/getting_started/softAP/main/softap_example_main.c
All the tcpip_adapter functions have their esp-netif counter-part. Please
Event handlers are moved from tcpip_adapter to appropriate driver code. There is no
IPSTR "\n", IP2STR(&event->ip_info.ip));
esp-netif IP address definitions
Submit Document Feedback
ESP-NETIF
211
to enable its con-
ESP-NETIF
is to disable the
Release v4.4

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32-S2 and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents

Save PDF