#include <zephyr/kernel.h>
#include <openthread/instance.h>
#include <openthread/message.h>
Go to the source code of this file.
|
typedef void(* | openthread_receive_cb) (struct otMessage *message, void *context) |
| The common callback type for receiving IPv4 (translated by NAT64) and IPv6 datagrams.
|
◆ openthread_receive_cb
typedef void(* openthread_receive_cb) (struct otMessage *message, void *context) |
The common callback type for receiving IPv4 (translated by NAT64) and IPv6 datagrams.
This callback is called when a datagram is received.
- Parameters
-
message | The message to receive. |
context | The context to pass to the callback. |
◆ openthread_get_default_instance()
struct otInstance * openthread_get_default_instance |
( |
void | | ) |
|
Get pointer to default OpenThread instance.
- Return values
-
!NULL | On success. |
NULL | On failure. |
◆ openthread_init()
int openthread_init |
( |
void | | ) |
|
Initialize the OpenThread module.
This function:
- Initializes the OpenThread module.
- Creates an OpenThread single instance.
- Starts the shell.
- Enables the UART and NCP HDLC for coprocessor purposes.
- Initializes the NAT64 translator.
- Creates a work queue for the OpenThread module.
- Note
- This function is automatically called by Zephyr's networking layer. If you want to initialize the OpenThread independently, call this function in your application init code.
- Return values
-
0 | On success. |
-EIO | On failure. |
◆ openthread_mutex_lock()
void openthread_mutex_lock |
( |
void | | ) |
|
Lock internal mutex before accessing OpenThread API.
OpenThread API is not thread-safe. Therefore, before accessing any API function, you need to lock the internal mutex, to prevent the OpenThread thread from pre-empting the API call.
◆ openthread_mutex_try_lock()
int openthread_mutex_try_lock |
( |
void | | ) |
|
Try to lock internal mutex before accessing OpenThread API.
This function behaves like openthread_mutex_lock(), provided that the internal mutex is unlocked. Otherwise, it returns a negative value without waiting.
◆ openthread_mutex_unlock()
void openthread_mutex_unlock |
( |
void | | ) |
|
Unlock internal mutex after accessing OpenThread API.
◆ openthread_run()
int openthread_run |
( |
void | | ) |
|
Run the OpenThread network.
Prepares the OpenThread network and enables it. Depends on active settings: it uses the stored network configuration, starts the joining procedure or uses the default network configuration. Additionally, when the device is MTD, it sets the SED mode to properly attach the network.
◆ openthread_set_receive_cb()
Set the additional callback for receiving packets.
This callback is called once a packet is received and can be used to inject packets into the Zephyr networking stack. Setting this callback is optional.
- Parameters
-
cb | Callback to set. |
context | Context to pass to the callback. |
◆ openthread_state_changed_callback_register()
Register callbacks that will be called when a certain configuration or state changes occur within OpenThread.
- Parameters
-
cb | Callback struct to register. |
◆ openthread_state_changed_callback_unregister()
Unregister OpenThread configuration or state changed callbacks.
- Parameters
-
cb | Callback struct to unregister. |
◆ openthread_stop()
int openthread_stop |
( |
void | | ) |
|
Disable the OpenThread network.
◆ openthread_thread_id_get()
k_tid_t openthread_thread_id_get |
( |
void | | ) |
|
Get OpenThread thread identification.