Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/zephyr.doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,7 @@ INPUT = @ZEPHYR_BASE@/doc/_doxygen/mainpage.md \
@ZEPHYR_BASE@/subsys/testsuite/ztest/include/ \
@ZEPHYR_BASE@/subsys/secure_storage/include/ \
@ZEPHYR_BASE@/subsys/fs/zms/zms_priv.h \
@ZEPHYR_BASE@/modules/openthread/include/openthread.h \

# This tag can be used to specify the character encoding of the source files
# that Doxygen parses. Internally Doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down
1 change: 1 addition & 0 deletions include/zephyr/net/net_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ struct net_if_addr {
uint8_t acd_state;
};
#endif /* CONFIG_NET_IPV4_ACD */
uint8_t _dummy;
};

#if defined(CONFIG_NET_IPV6_DAD) || defined(CONFIG_NET_IPV4_ACD)
Expand Down
79 changes: 45 additions & 34 deletions include/zephyr/net/openthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
*/

/** @file
* @brief OpenThread L2 stack public header
* @brief OpenThread stack public header
*/

#ifndef ZEPHYR_INCLUDE_NET_OPENTHREAD_H_
#define ZEPHYR_INCLUDE_NET_OPENTHREAD_H_

/**
* @brief OpenThread Layer 2 abstraction layer
* @defgroup openthread OpenThread L2 abstraction layer
* @brief OpenThread stack public header
* @defgroup openthread OpenThread stack
* @since 1.11
* @version 0.8.0
* @ingroup ieee802154
* @{
*/

#include <zephyr/kernel.h>

#include <zephyr/net/net_if.h>
#include <zephyr/kernel/thread.h>

#include <openthread/instance.h>
#include <openthread.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -44,8 +44,10 @@ struct pkt_list_elem {
* @brief OpenThread l2 private data.
*/
struct openthread_context {
/** Pointer to OpenThread stack instance */
otInstance *instance;
/** @deprecated Pointer to OpenThread stack instance. This is deprecated and will be removed
* in a future release. This field must not be used anymore.
*/
__deprecated otInstance *instance;

/** Pointer to OpenThread network interface */
struct net_if *iface;
Expand All @@ -62,16 +64,24 @@ struct openthread_context {
/** Array for storing net_pkt for OpenThread internal usage */
struct pkt_list_elem pkt_list[CONFIG_OPENTHREAD_PKT_LIST_SIZE];

/** A mutex to protect API calls from being preempted. */
struct k_mutex api_lock;
/** @deprecated A mutex to protect API calls from being preempted. This is deprecated and
* will be removed in a future release. This field must not be used anymore.
*/
__deprecated struct k_mutex api_lock;

/** A work queue for all OpenThread activity */
struct k_work_q work_q;
/** @deprecated A work queue for all OpenThread activity. This is deprecated and will be
* removed in a future release. This field must not be used anymore.
*/
__deprecated struct k_work_q work_q;

/** Work object for OpenThread internal usage */
struct k_work api_work;
/** @deprecated Work object for OpenThread internal usage. This is deprecated and will be
* removed in a future release. This field must not be used anymore.
*/
__deprecated struct k_work api_work;

/** A list for state change callbacks */
/** @deprecated A list for state change callbacks. This is deprecated and will be removed in
* a future release.
*/
sys_slist_t state_change_cbs;
};
/**
Expand All @@ -81,6 +91,8 @@ struct openthread_context {
/** OpenThread state change callback */

/**
* @deprecated use @ref openthread_state_changed_callback instead.
*
* @brief OpenThread state change callback structure
*
* Used to register a callback in the callback list. As many
Expand Down Expand Up @@ -111,28 +123,27 @@ struct openthread_state_changed_cb {
};

/**
* @deprecated use @ref openthread_state_changed_callback_register instead.
*
* @brief Registers callbacks which will be called when certain configuration
* or state changes occur within OpenThread.
*
* @param ot_context the OpenThread context to register the callback with.
* @param cb callback struct to register.
*/
int openthread_state_changed_cb_register(struct openthread_context *ot_context,
struct openthread_state_changed_cb *cb);
__deprecated int openthread_state_changed_cb_register(struct openthread_context *ot_context,
struct openthread_state_changed_cb *cb);

/**
* @deprecated use @ref openthread_state_changed_callback_unregister instead.
*
* @brief Unregisters OpenThread configuration or state changed callbacks.
*
* @param ot_context the OpenThread context to unregister the callback from.
* @param cb callback struct to unregister.
*/
int openthread_state_changed_cb_unregister(struct openthread_context *ot_context,
struct openthread_state_changed_cb *cb);

/**
* @brief Get OpenThread thread identification.
*/
k_tid_t openthread_thread_id_get(void);
__deprecated int openthread_state_changed_cb_unregister(struct openthread_context *ot_context,
struct openthread_state_changed_cb *cb);

/**
* @brief Get pointer to default OpenThread context.
Expand All @@ -143,14 +154,8 @@ k_tid_t openthread_thread_id_get(void);
struct openthread_context *openthread_get_default_context(void);

/**
* @brief Get pointer to default OpenThread instance.
* @deprecated use @ref openthread_run instead.
*
* @retval !NULL On success.
* @retval NULL On failure.
*/
struct otInstance *openthread_get_default_instance(void);

/**
* @brief Starts the OpenThread network.
*
* @details Depends on active settings: it uses stored network configuration,
Expand All @@ -159,9 +164,11 @@ struct otInstance *openthread_get_default_instance(void);
*
* @param ot_context
*/
int openthread_start(struct openthread_context *ot_context);
__deprecated int openthread_start(struct openthread_context *ot_context);

/**
* @deprecated use @ref openthread_mutex_lock.
*
* @brief Lock internal mutex before accessing OT API.
*
* @details OpenThread API is not thread-safe, therefore before accessing any
Expand All @@ -170,9 +177,11 @@ int openthread_start(struct openthread_context *ot_context);
*
* @param ot_context Context to lock.
*/
void openthread_api_mutex_lock(struct openthread_context *ot_context);
__deprecated void openthread_api_mutex_lock(struct openthread_context *ot_context);

/**
* @deprecated use @ref openthread_mutex_try_lock instead.
*
* @brief Try to lock internal mutex before accessing OT API.
*
* @details This function behaves like openthread_api_mutex_lock() provided that
Expand All @@ -183,14 +192,16 @@ void openthread_api_mutex_lock(struct openthread_context *ot_context);
* @retval 0 On success.
* @retval <0 On failure.
*/
int openthread_api_mutex_try_lock(struct openthread_context *ot_context);
__deprecated int openthread_api_mutex_try_lock(struct openthread_context *ot_context);

/**
* @deprecated use @ref openthread_mutex_unlock instead.
*
* @brief Unlock internal mutex after accessing OT API.
*
* @param ot_context Context to unlock.
*/
void openthread_api_mutex_unlock(struct openthread_context *ot_context);
__deprecated void openthread_api_mutex_unlock(struct openthread_context *ot_context);

/** @cond INTERNAL_HIDDEN */

Expand Down
9 changes: 9 additions & 0 deletions modules/openthread/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,15 @@ zephyr_link_libraries(${ot_libs})

endif()

# Create a library for the OpenThread Zephyr utils
zephyr_library_named(openthread_utils)
zephyr_library_sources(
openthread.c
openthread_utils.c
)
zephyr_library_sources_ifdef(CONFIG_OPENTHREAD_SHELL shell.c)
zephyr_include_directories(include)

add_subdirectory(platform)

endif()
29 changes: 29 additions & 0 deletions modules/openthread/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ config OPENTHREAD

if OPENTHREAD

config OPENTHREAD_SYS_INIT
bool "Initialize OpenThread stack during system initialization"
default y
depends on !NET_L2_OPENTHREAD
help
This option initializes the OpenThread automatically by calling the openthread_init()
function during system initialization.

config OPENTHREAD_SYS_INIT_PRIORITY
int "OpenThread system initialization priority"
default 40
depends on OPENTHREAD_SYS_INIT
help
This option sets the priority of the OpenThread system initialization.


choice OPENTHREAD_IMPLEMENTATION
prompt "OpenThread origin selection"
help
Expand Down Expand Up @@ -320,6 +336,19 @@ config OPENTHREAD_INTERFACE_EARLY_UP
Otherwise, OpenThread interface will be marked operational UP only
after the device joins a Thread network.

config OPENTHREAD_PLATFORM_PKT_TXTIME
bool
default y if NET_PKT_TXTIME
help
Enable packet TX time support. This is needed for when the application
wants to set the exact time when the packet should be sent.

config OPENTHREAD_PLATFORM_CARRIER_FUNCTIONS
bool
default y if OPENTHREAD_DIAG && IEEE802154_CARRIER_FUNCTIONS
help
Enable support for functions such as modulated carrier and continuous carrier.

menu "OpenThread stack features"
rsource "Kconfig.features"
endmenu
Expand Down
Loading
Loading