123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- #ifndef ZEPHYR_INCLUDE_NET_OPENTHREAD_H_
- #define ZEPHYR_INCLUDE_NET_OPENTHREAD_H_
- #include <kernel.h>
- #include <net/net_if.h>
- #include <openthread/instance.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- struct pkt_list_elem {
- struct net_pkt *pkt;
- };
- struct openthread_context {
-
- otInstance *instance;
-
- struct net_if *iface;
-
- uint16_t pkt_list_in_idx;
-
- uint16_t pkt_list_out_idx;
-
- uint8_t pkt_list_full;
-
- struct pkt_list_elem pkt_list[CONFIG_OPENTHREAD_PKT_LIST_SIZE];
-
- struct k_mutex api_lock;
-
- struct k_work_q work_q;
-
- struct k_work api_work;
- };
- void openthread_set_state_changed_cb(otStateChangedCallback cb);
- k_tid_t openthread_thread_id_get(void);
- struct openthread_context *openthread_get_default_context(void);
- struct otInstance *openthread_get_default_instance(void);
- int openthread_start(struct openthread_context *ot_context);
- void openthread_api_mutex_lock(struct openthread_context *ot_context);
- int openthread_api_mutex_try_lock(struct openthread_context *ot_context);
- void openthread_api_mutex_unlock(struct openthread_context *ot_context);
- #define OPENTHREAD_L2_CTX_TYPE struct openthread_context
- #ifdef __cplusplus
- }
- #endif
- #endif
|