diff --git a/include/net/openthread.h b/include/net/openthread.h index 99f1652197c..07f0a40fceb 100644 --- a/include/net/openthread.h +++ b/include/net/openthread.h @@ -4,9 +4,20 @@ * SPDX-License-Identifier: Apache-2.0 */ +/** @file + * @brief OpenThread l2 stack public header + */ + #ifndef ZEPHYR_INCLUDE_NET_OPENTHREAD_H_ #define ZEPHYR_INCLUDE_NET_OPENTHREAD_H_ +/** + * @brief OpenThread l2 stack api + * @defgroup OpenThread l2 layer + * @ingroup networking + * @{ + */ + #include #include @@ -17,27 +28,80 @@ extern "C" { #endif +/** + * @cond INTERNAL_HIDDEN + */ +/** + * @brief Type of pkt_list + */ struct pkt_list_elem { struct net_pkt *pkt; }; +/** + * @brief OpenThread l2 private data. + */ struct openthread_context { + /** Pointer to OpenThread stack instance */ otInstance *instance; + + /** Pointer to OpenThread network interface */ struct net_if *iface; + + /** Index indicates the head of pkt_list ring buffer */ uint16_t pkt_list_in_idx; + + /** Index indicates the tail of pkt_list ring buffer */ uint16_t pkt_list_out_idx; + + /** Flag indicates that pkt_list is full */ uint8_t pkt_list_full; + + /** Array for storing net_pkt for OpenThread internal usage */ struct pkt_list_elem pkt_list[CONFIG_OPENTHREAD_PKT_LIST_SIZE]; }; +/** + * INTERNAL_HIDDEN @endcond + */ +/** + * @brief Sets function which will be called when certain configuration or state + * changes within OpenThread. + * + * @param cb function to call in callback procedure. + */ void openthread_set_state_changed_cb(otStateChangedCallback cb); +/** + * @brief Get OpenThread thread identification. + */ k_tid_t openthread_thread_id_get(void); +/** + * @brief Get pointer to default OpenThread context. + * + * @retval !NULL On success. + * @retval NULL On failure. + */ struct openthread_context *openthread_get_default_context(void); +/** + * @brief Get pointer to default OpenThread instance. + * + * @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, + * start joining procedure or uses default network configuration. Additionally + * when the device is MTD, it sets the SED mode to properly attach the network. + * + * @param ot_context + */ void openthread_start(struct openthread_context *ot_context); #define OPENTHREAD_L2_CTX_TYPE struct openthread_context @@ -46,4 +110,8 @@ void openthread_start(struct openthread_context *ot_context); } #endif +/** + * @} + */ + #endif /* ZEPHYR_INCLUDE_NET_OPENTHREAD_H_ */