Zephyr API Documentation 4.0.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
23#include <zephyr/kernel.h>
24
25#include <zephyr/net/net_if.h>
26
27#include <openthread/instance.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
39struct pkt_list_elem {
40 struct net_pkt *pkt;
41};
42
46struct openthread_context {
48 otInstance *instance;
49
51 struct net_if *iface;
52
54 uint16_t pkt_list_in_idx;
55
57 uint16_t pkt_list_out_idx;
58
60 uint8_t pkt_list_full;
61
63 struct pkt_list_elem pkt_list[CONFIG_OPENTHREAD_PKT_LIST_SIZE];
64
66 struct k_mutex api_lock;
67
69 struct k_work_q work_q;
70
72 struct k_work api_work;
73
75 sys_slist_t state_change_cbs;
76};
100 void (*state_changed_cb)(otChangedFlags flags, struct openthread_context *ot_context,
101 void *user_data);
102
105
111};
112
120int openthread_state_changed_cb_register(struct openthread_context *ot_context,
121 struct openthread_state_changed_cb *cb);
122
129int openthread_state_changed_cb_unregister(struct openthread_context *ot_context,
130 struct openthread_state_changed_cb *cb);
131
136
143struct openthread_context *openthread_get_default_context(void);
144
151struct otInstance *openthread_get_default_instance(void);
152
162int openthread_start(struct openthread_context *ot_context);
163
173void openthread_api_mutex_lock(struct openthread_context *ot_context);
174
186int openthread_api_mutex_try_lock(struct openthread_context *ot_context);
187
193void openthread_api_mutex_unlock(struct openthread_context *ot_context);
194
197#define OPENTHREAD_L2_CTX_TYPE struct openthread_context
198
201#ifdef __cplusplus
202}
203#endif
204
209#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.
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:2994
Thread Structure.
Definition thread.h:259
A structure used to hold work until it can be processed.
Definition kernel.h:4109
A structure used to submit work.
Definition kernel.h:3957
Network Interface structure.
Definition net_if.h:690
Network packet.
Definition net_pkt.h:91
OpenThread state change callback
Definition openthread.h:91
sys_snode_t node
Internally used field for list handling.
Definition openthread.h:110
void(* state_changed_cb)(otChangedFlags flags, struct openthread_context *ot_context, void *user_data)
Callback for notifying configuration or state changes.
Definition openthread.h:100
void * user_data
User data if required.
Definition openthread.h:104