Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
openthread.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
11#ifndef ZEPHYR_INCLUDE_NET_OPENTHREAD_H_
12#define ZEPHYR_INCLUDE_NET_OPENTHREAD_H_
13
21#include <zephyr/kernel.h>
22
23#include <zephyr/net/net_if.h>
24
25#include <openthread/instance.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
37struct pkt_list_elem {
38 struct net_pkt *pkt;
39};
40
44struct openthread_context {
46 otInstance *instance;
47
49 struct net_if *iface;
50
52 uint16_t pkt_list_in_idx;
53
55 uint16_t pkt_list_out_idx;
56
58 uint8_t pkt_list_full;
59
61 struct pkt_list_elem pkt_list[CONFIG_OPENTHREAD_PKT_LIST_SIZE];
62
64 struct k_mutex api_lock;
65
67 struct k_work_q work_q;
68
70 struct k_work api_work;
71
73 sys_slist_t state_change_cbs;
74};
98 void (*state_changed_cb)(otChangedFlags flags, struct openthread_context *ot_context,
99 void *user_data);
100
103
109};
110
118int openthread_state_changed_cb_register(struct openthread_context *ot_context,
119 struct openthread_state_changed_cb *cb);
120
127int openthread_state_changed_cb_unregister(struct openthread_context *ot_context,
128 struct openthread_state_changed_cb *cb);
129
137__deprecated void openthread_set_state_changed_cb(otStateChangedCallback cb);
138
143
150struct openthread_context *openthread_get_default_context(void);
151
158struct otInstance *openthread_get_default_instance(void);
159
169int openthread_start(struct openthread_context *ot_context);
170
180void openthread_api_mutex_lock(struct openthread_context *ot_context);
181
193int openthread_api_mutex_try_lock(struct openthread_context *ot_context);
194
200void openthread_api_mutex_unlock(struct openthread_context *ot_context);
201
204#define OPENTHREAD_L2_CTX_TYPE struct openthread_context
205
208#ifdef __cplusplus
209}
210#endif
211
216#endif /* ZEPHYR_INCLUDE_NET_OPENTHREAD_H_ */
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.
void openthread_api_mutex_lock(struct openthread_context *ot_context)
Lock internal mutex before accessing OT API.
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 Ope...
int openthread_start(struct openthread_context *ot_context)
Starts the OpenThread network.
struct otInstance * openthread_get_default_instance(void)
Get pointer to default OpenThread instance.
int openthread_state_changed_cb_unregister(struct openthread_context *ot_context, struct openthread_state_changed_cb *cb)
Unregisters OpenThread configuration or state changed callbacks.
k_tid_t openthread_thread_id_get(void)
Get OpenThread thread identification.
void openthread_set_state_changed_cb(otStateChangedCallback cb)
Sets function which will be called when certain configuration or state changes within OpenThread.
struct openthread_context * openthread_get_default_context(void)
Get pointer to default OpenThread context.
struct _slist sys_slist_t
Single-linked list structure.
Definition: slist.h:49
struct _snode sys_snode_t
Single-linked list node structure.
Definition: slist.h:39
Public kernel APIs.
Public API for network interface.
flags
Definition: parser.h:96
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
Mutex Structure.
Definition: kernel.h:2914
Thread Structure.
Definition: thread.h:259
A structure used to hold work until it can be processed.
Definition: kernel.h:4027
A structure used to submit work.
Definition: kernel.h:3875
Network Interface structure.
Definition: net_if.h:675
Network packet.
Definition: net_pkt.h:67
OpenThread state change callback
Definition: openthread.h:89
sys_snode_t node
Internally used field for list handling.
Definition: openthread.h:108
void(* state_changed_cb)(otChangedFlags flags, struct openthread_context *ot_context, void *user_data)
Callback for notifying configuration or state changes.
Definition: openthread.h:98
void * user_data
User data if required.
Definition: openthread.h:102