LCOV - code coverage report
Current view: top level - zephyr/net - openthread.h Coverage Total Hit
Test: new.info Lines: 100.0 % 12 12
Test Date: 2025-09-05 22:20:39

            Line data    Source code
       1            1 : /*
       2              :  * Copyright (c) 2017 Nordic Semiconductor ASA
       3              :  *
       4              :  * SPDX-License-Identifier: Apache-2.0
       5              :  */
       6              : 
       7              : /** @file
       8              :  * @brief OpenThread stack public header
       9              :  */
      10              : 
      11              : #ifndef ZEPHYR_INCLUDE_NET_OPENTHREAD_H_
      12              : #define ZEPHYR_INCLUDE_NET_OPENTHREAD_H_
      13              : 
      14              : /**
      15              :  * @brief OpenThread stack public header
      16              :  * @defgroup openthread OpenThread stack
      17              :  * @since 1.11
      18              :  * @version 0.8.0
      19              :  * @ingroup ieee802154
      20              :  * @{
      21              :  */
      22              : 
      23              : #include <zephyr/kernel.h>
      24              : #include <zephyr/net/net_if.h>
      25              : #include <zephyr/kernel/thread.h>
      26              : 
      27              : #include <openthread.h>
      28              : 
      29              : #ifdef __cplusplus
      30              : extern "C" {
      31              : #endif
      32              : 
      33              : /**
      34              :  * @cond INTERNAL_HIDDEN
      35              :  */
      36              : /**
      37              :  * @brief Type of pkt_list
      38              :  */
      39              : struct pkt_list_elem {
      40              :         struct net_pkt *pkt;
      41              : };
      42              : 
      43              : /**
      44              :  * @brief OpenThread l2 private data.
      45              :  */
      46              : struct openthread_context {
      47              :         /** @deprecated Pointer to OpenThread stack instance. This is deprecated and will be removed
      48              :          * in a future release. This field must not be used anymore.
      49              :          */
      50              :         __deprecated otInstance *instance;
      51              : 
      52              :         /** Pointer to OpenThread network interface */
      53              :         struct net_if *iface;
      54              : 
      55              :         /** Index indicates the head of pkt_list ring buffer */
      56              :         uint16_t pkt_list_in_idx;
      57              : 
      58              :         /** Index indicates the tail of pkt_list ring buffer */
      59              :         uint16_t pkt_list_out_idx;
      60              : 
      61              :         /** Flag indicates that pkt_list is full */
      62              :         uint8_t pkt_list_full;
      63              : 
      64              :         /** Array for storing net_pkt for OpenThread internal usage */
      65              :         struct pkt_list_elem pkt_list[CONFIG_OPENTHREAD_PKT_LIST_SIZE];
      66              : 
      67              :         /** @deprecated A mutex to protect API calls from being preempted. This is deprecated and
      68              :          * will be removed in a future release. This field must not be used anymore.
      69              :          */
      70              :         __deprecated struct k_mutex api_lock;
      71              : 
      72              :         /** @deprecated A work queue for all OpenThread activity. This is deprecated and will be
      73              :          * removed in a future release. This field must not be used anymore.
      74              :          */
      75              :         __deprecated struct k_work_q work_q;
      76              : 
      77              :         /** @deprecated Work object for OpenThread internal usage. This is deprecated and will be
      78              :          * removed in a future release. This field must not be used anymore.
      79              :          */
      80              :         __deprecated struct k_work api_work;
      81              : 
      82              :         /** @deprecated A list for state change callbacks. This is deprecated and will be removed in
      83              :          * a future release.
      84              :          */
      85              :         sys_slist_t state_change_cbs;
      86              : };
      87              : /**
      88              :  * INTERNAL_HIDDEN @endcond
      89              :  */
      90              : 
      91              : /** OpenThread state change callback  */
      92              : 
      93              : /**
      94              :  * @deprecated use @ref openthread_state_changed_callback instead.
      95              :  *
      96              :  * @brief OpenThread state change callback structure
      97              :  *
      98              :  * Used to register a callback in the callback list. As many
      99              :  * callbacks as needed can be added as long as each of them
     100              :  * are unique pointers of struct openthread_state_changed_cb.
     101              :  * Beware such structure should not be allocated on stack.
     102              :  */
     103            1 : struct openthread_state_changed_cb {
     104              :         /**
     105              :          * @brief Callback for notifying configuration or state changes.
     106              :          *
     107              :          * @param flags as per OpenThread otStateChangedCallback() aFlags parameter.
     108              :          *        See https://openthread.io/reference/group/api-instance#otstatechangedcallback
     109              :          * @param ot_context the OpenThread context the callback is registered with.
     110              :          * @param user_data Data to pass to the callback.
     111              :          */
     112            1 :         void (*state_changed_cb)(otChangedFlags flags, struct openthread_context *ot_context,
     113              :                                  void *user_data);
     114              : 
     115              :         /** User data if required */
     116            1 :         void *user_data;
     117              : 
     118              :         /**
     119              :          * Internally used field for list handling
     120              :          *  - user must not directly modify
     121              :          */
     122            1 :         sys_snode_t node;
     123              : };
     124              : 
     125              : /**
     126              :  * @deprecated use @ref openthread_state_changed_callback_register instead.
     127              :  *
     128              :  * @brief Registers callbacks which will be called when certain configuration
     129              :  * or state changes occur within OpenThread.
     130              :  *
     131              :  * @param ot_context the OpenThread context to register the callback with.
     132              :  * @param cb callback struct to register.
     133              :  */
     134            1 : __deprecated int openthread_state_changed_cb_register(struct openthread_context *ot_context,
     135              :                                                       struct openthread_state_changed_cb *cb);
     136              : 
     137              : /**
     138              :  * @deprecated use @ref openthread_state_changed_callback_unregister instead.
     139              :  *
     140              :  * @brief Unregisters OpenThread configuration or state changed callbacks.
     141              :  *
     142              :  * @param ot_context the OpenThread context to unregister the callback from.
     143              :  * @param cb callback struct to unregister.
     144              :  */
     145            1 : __deprecated int openthread_state_changed_cb_unregister(struct openthread_context *ot_context,
     146              :                                                         struct openthread_state_changed_cb *cb);
     147              : 
     148              : /**
     149              :  * @brief Get pointer to default OpenThread context.
     150              :  *
     151              :  * @retval !NULL On success.
     152              :  * @retval NULL  On failure.
     153              :  */
     154            1 : struct openthread_context *openthread_get_default_context(void);
     155              : 
     156              : /**
     157              :  * @deprecated use @ref openthread_run instead.
     158              :  *
     159              :  * @brief Starts the OpenThread network.
     160              :  *
     161              :  * @details Depends on active settings: it uses stored network configuration,
     162              :  * start joining procedure or uses default network configuration. Additionally
     163              :  * when the device is MTD, it sets the SED mode to properly attach the network.
     164              :  *
     165              :  * @param ot_context
     166              :  */
     167            1 : __deprecated int openthread_start(struct openthread_context *ot_context);
     168              : 
     169              : /**
     170              :  * @deprecated use @ref openthread_mutex_lock.
     171              :  *
     172              :  * @brief Lock internal mutex before accessing OT API.
     173              :  *
     174              :  * @details OpenThread API is not thread-safe, therefore before accessing any
     175              :  * API function, it's needed to lock the internal mutex, to prevent the
     176              :  * OpenThread thread from preempting the API call.
     177              :  *
     178              :  * @param ot_context Context to lock.
     179              :  */
     180            1 : __deprecated void openthread_api_mutex_lock(struct openthread_context *ot_context);
     181              : 
     182              : /**
     183              :  * @deprecated use @ref openthread_mutex_try_lock instead.
     184              :  *
     185              :  * @brief Try to lock internal mutex before accessing OT API.
     186              :  *
     187              :  * @details This function behaves like openthread_api_mutex_lock() provided that
     188              :  * the internal mutex is unlocked. Otherwise, it exists immediately and returns
     189              :  * a negative value.
     190              :  *
     191              :  * @param ot_context Context to lock.
     192              :  * @retval 0  On success.
     193              :  * @retval <0 On failure.
     194              :  */
     195            1 : __deprecated int openthread_api_mutex_try_lock(struct openthread_context *ot_context);
     196              : 
     197              : /**
     198              :  * @deprecated use @ref openthread_mutex_unlock instead.
     199              :  *
     200              :  * @brief Unlock internal mutex after accessing OT API.
     201              :  *
     202              :  * @param ot_context Context to unlock.
     203              :  */
     204            1 : __deprecated void openthread_api_mutex_unlock(struct openthread_context *ot_context);
     205              : 
     206              : /** @cond INTERNAL_HIDDEN */
     207              : 
     208              : #define OPENTHREAD_L2_CTX_TYPE struct openthread_context
     209              : 
     210              : /** @endcond */
     211              : 
     212              : #ifdef __cplusplus
     213              : }
     214              : #endif
     215              : 
     216              : /**
     217              :  * @}
     218              :  */
     219              : 
     220              : #endif /* ZEPHYR_INCLUDE_NET_OPENTHREAD_H_ */
        

Generated by: LCOV version 2.0-1