Zephyr API Documentation 4.1.99
A Scalable Open Source RTOS
 4.1.99
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
23#include <zephyr/kernel.h>
24#include <zephyr/net/net_if.h>
26
27#include <openthread/instance.h>
28#include <openthread/message.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
40struct pkt_list_elem {
41 struct net_pkt *pkt;
42};
43
47struct openthread_context {
51 __deprecated otInstance *instance;
52
54 struct net_if *iface;
55
57 uint16_t pkt_list_in_idx;
58
60 uint16_t pkt_list_out_idx;
61
63 uint8_t pkt_list_full;
64
66 struct pkt_list_elem pkt_list[CONFIG_OPENTHREAD_PKT_LIST_SIZE];
67
71 __deprecated struct k_mutex api_lock;
72
76 __deprecated struct k_work_q work_q;
77
81 __deprecated struct k_work api_work;
82
86 sys_slist_t state_change_cbs;
87};
100typedef void (*openthread_receive_cb)(otMessage *message, void *context);
101
121 otStateChangedCallback otCallback;
122
125
131};
132
152 void (*state_changed_cb)(otChangedFlags flags, struct openthread_context *ot_context,
153 void *user_data);
154
157
163};
164
172
179
189__deprecated int openthread_state_changed_cb_register(struct openthread_context *ot_context,
190 struct openthread_state_changed_cb *cb);
191
200__deprecated int openthread_state_changed_cb_unregister(struct openthread_context *ot_context,
201 struct openthread_state_changed_cb *cb);
202
207
214struct openthread_context *openthread_get_default_context(void);
215
222struct otInstance *openthread_get_default_instance(void);
223
243
254
259
271__deprecated int openthread_start(struct openthread_context *ot_context);
272
284
293
302
307
319__deprecated void openthread_api_mutex_lock(struct openthread_context *ot_context);
320
334__deprecated int openthread_api_mutex_try_lock(struct openthread_context *ot_context);
335
343__deprecated void openthread_api_mutex_unlock(struct openthread_context *ot_context);
344
347#define OPENTHREAD_L2_CTX_TYPE struct openthread_context
348
351#ifdef __cplusplus
352}
353#endif
354
359#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_set_receive_cb(openthread_receive_cb cb, void *context)
Set the additional callback for receiving packets.
void openthread_api_mutex_lock(struct openthread_context *ot_context)
Lock internal mutex before accessing OT API.
int openthread_state_changed_callback_register(struct openthread_state_changed_callback *cb)
Register callbacks that will be called when a certain configuration or state changes occur within Ope...
void openthread_mutex_unlock(void)
Unlock internal mutex after accessing OpenThread API.
void(* openthread_receive_cb)(otMessage *message, void *context)
The common callback type for receiving IPv4 (translated by NAT64) and IPv6 datagrams.
Definition openthread.h:100
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.
int openthread_init(void)
Initialize the OpenThread module.
struct otInstance * openthread_get_default_instance(void)
Get pointer to default OpenThread instance.
int openthread_run(void)
Run the OpenThread network.
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.
int openthread_mutex_try_lock(void)
Try to lock internal mutex before accessing OpenThread API.
struct openthread_context * openthread_get_default_context(void)
Get pointer to default OpenThread context.
void openthread_mutex_lock(void)
Lock internal mutex before accessing OpenThread API.
int openthread_state_changed_callback_unregister(struct openthread_state_changed_callback *cb)
Unregister OpenThread configuration or state changed callbacks.
int openthread_stop(void)
Disable the OpenThread network.
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:97
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Mutex Structure.
Definition kernel.h:3070
Thread Structure.
Definition thread.h:262
A structure used to hold work until it can be processed.
Definition kernel.h:4203
A structure used to submit work.
Definition kernel.h:4051
Network Interface structure.
Definition net_if.h:714
Network packet.
Definition net_pkt.h:91
OpenThread state change callback
Definition openthread.h:113
sys_snode_t node
Internally used field for list handling.
Definition openthread.h:130
otStateChangedCallback otCallback
Callback for notifying configuration or state changes.
Definition openthread.h:121
void * user_data
User data if required.
Definition openthread.h:124
OpenThread state change callback structure.
Definition openthread.h:143
sys_snode_t node
Internally used field for list handling.
Definition openthread.h:162
void(* state_changed_cb)(otChangedFlags flags, struct openthread_context *ot_context, void *user_data)
Callback for notifying configuration or state changes.
Definition openthread.h:152
void * user_data
User data if required.
Definition openthread.h:156