Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
OpenThread L2 abstraction layer

OpenThread Layer 2 abstraction layer. More...

Data Structures

struct  openthread_state_changed_cb
 OpenThread state change callback
More...
 

Macros

#define OPENTHREAD_L2_CTX_TYPE   struct openthread_context
 

Functions

int openthread_state_changed_cb_register (struct openthread_context *ot_context, struct openthread_state_changed_cb *cb)
 Registers callbacks which will be called when certain configuration or state changes occur within OpenThread.
 
int openthread_state_changed_cb_unregister (struct openthread_context *ot_context, struct openthread_state_changed_cb *cb)
 Unregisters OpenThread configuration or state changed callbacks.
 
void openthread_set_state_changed_cb (otStateChangedCallback cb)
 Sets function which will be called when certain configuration or state changes within OpenThread.
 
k_tid_t openthread_thread_id_get (void)
 Get OpenThread thread identification.
 
struct openthread_context * openthread_get_default_context (void)
 Get pointer to default OpenThread context.
 
struct otInstance * openthread_get_default_instance (void)
 Get pointer to default OpenThread instance.
 
int openthread_start (struct openthread_context *ot_context)
 Starts the OpenThread network.
 
void openthread_api_mutex_lock (struct openthread_context *ot_context)
 Lock internal mutex before accessing OT API.
 
int openthread_api_mutex_try_lock (struct openthread_context *ot_context)
 Try to lock internal mutex before accessing OT API.
 
void openthread_api_mutex_unlock (struct openthread_context *ot_context)
 Unlock internal mutex after accessing OT API.
 

Detailed Description

OpenThread Layer 2 abstraction layer.

Macro Definition Documentation

◆ OPENTHREAD_L2_CTX_TYPE

#define OPENTHREAD_L2_CTX_TYPE   struct openthread_context

Function Documentation

◆ openthread_api_mutex_lock()

void openthread_api_mutex_lock ( struct openthread_context *  ot_context)

#include <zephyr/net/openthread.h>

Lock internal mutex before accessing OT API.

OpenThread API is not thread-safe, therefore before accessing any API function, it's needed to lock the internal mutex, to prevent the OpenThread thread from preempting the API call.

Parameters
ot_contextContext to lock.

◆ openthread_api_mutex_try_lock()

int openthread_api_mutex_try_lock ( struct openthread_context *  ot_context)

#include <zephyr/net/openthread.h>

Try to lock internal mutex before accessing OT API.

This function behaves like openthread_api_mutex_lock() provided that the internal mutex is unlocked. Otherwise, it exists immediately and returns a negative value.

Parameters
ot_contextContext to lock.
Return values
0On success.
<0On failure.

◆ openthread_api_mutex_unlock()

void openthread_api_mutex_unlock ( struct openthread_context *  ot_context)

#include <zephyr/net/openthread.h>

Unlock internal mutex after accessing OT API.

Parameters
ot_contextContext to unlock.

◆ openthread_get_default_context()

struct openthread_context * openthread_get_default_context ( void  )

#include <zephyr/net/openthread.h>

Get pointer to default OpenThread context.

Return values
!NULLOn success.
NULLOn failure.

◆ openthread_get_default_instance()

struct otInstance * openthread_get_default_instance ( void  )

#include <zephyr/net/openthread.h>

Get pointer to default OpenThread instance.

Return values
!NULLOn success.
NULLOn failure.

◆ openthread_set_state_changed_cb()

void openthread_set_state_changed_cb ( otStateChangedCallback  cb)

#include <zephyr/net/openthread.h>

Sets function which will be called when certain configuration or state changes within OpenThread.

Parameters
cbfunction to call in callback procedure.
Deprecated:
Use openthread_state_changed_cb_register() instead.

◆ openthread_start()

int openthread_start ( struct openthread_context *  ot_context)

#include <zephyr/net/openthread.h>

Starts the OpenThread network.

Depends on active settings: it uses stored network configuration, start joining procedure or uses default network configuration. Additionally when the device is MTD, it sets the SED mode to properly attach the network.

Parameters
ot_context

◆ openthread_state_changed_cb_register()

int openthread_state_changed_cb_register ( struct openthread_context *  ot_context,
struct openthread_state_changed_cb cb 
)

#include <zephyr/net/openthread.h>

Registers callbacks which will be called when certain configuration or state changes occur within OpenThread.

Parameters
ot_contextthe OpenThread context to register the callback with.
cbcallback struct to register.

◆ openthread_state_changed_cb_unregister()

int openthread_state_changed_cb_unregister ( struct openthread_context *  ot_context,
struct openthread_state_changed_cb cb 
)

#include <zephyr/net/openthread.h>

Unregisters OpenThread configuration or state changed callbacks.

Parameters
ot_contextthe OpenThread context to unregister the callback from.
cbcallback struct to unregister.

◆ openthread_thread_id_get()

k_tid_t openthread_thread_id_get ( void  )

#include <zephyr/net/openthread.h>

Get OpenThread thread identification.