EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #1444 background imageLoading...
Page #1444 background image
Chapter 4. API Guides
4.21.2 How To Write an OpenThread Application
The OpenThread openthread/ot_cli example will be a good place to start at. It demonstrates basic OpenThread
initialization and simple socket-based server and client.
Before OpenThread initialization
s1.1 The main task calls esp_vfs_eventfd_register() to initialize the eventfd virtual filesystem. The
eventfd file system is used for task notification in the OpenThread driver.
s1.2 The main task calls nvs_flash_init() to initialize the NVS where the Thread network data is stored.
s1.3 Optional, The main task calls esp_netif_init() only when it wants to create the network interface
for Thread.
s1.4: The main task calls esp_event_loop_create() to create the system Event task and initialize an
application events callback function.
OpenThread stack initialization
s2.1: Call esp_openthread_init() to initialize the OpenThread stack.
OpenThread network interface initialization
The whole stage is optional and only required if the application wants to create the network interface for Thread.
- s3.1: Call esp_netif_new() with ESP_NETIF_DEFAULT_OPENTHREAD to create the interface. - s3.2:
Call esp_openthread_netif_glue_init() to create the OpenThread interface handlers. - s3.3: Call
esp_netif_attach() to attach the handlers to the interface.
The OpenThread main loop
s4.3: Call esp_openthread_launch_mainloop() to launch the OpenThread main loop. Note that
this is a busy loop and will not return until the OpenThread stack is terminated.
Calling OpenThread APIs
The OpenThread APIs are not thread-safe. When calling OpenThread APIs from other tasks, make
sure to hold the lock with esp_openthread_lock_acquire() and release the lock with
esp_openthread_lock_release() afterwards.
Deinitialization
The following steps are required to deintialize the OpenThread stack: - Call esp_netif_destroy() and
esp_openthread_netif_glue_deinit() to deintialize the OpenThread network interface if you have cre-
ated one. - Call esp_openthread_deinit() to deintialize the OpenThread stack.
4.21.3 The OpenThread border router
The OpenThread border router connects the Thread network with other IP networks. It will provide IPv6 connectivity,
service registration and commission functionality. To launch an OpenThread border router on a ESP chip, you need to
connect an RCP to a Wi-Fi capable chip such as ESP32. Call esp_openthread_border_router_init()
during the initialization will launch all the border routing functionalities.
You may refer to the openthread/ot_br example and the README for further border router details.
Espressif Systems 1433
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

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

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish