-
Notifications
You must be signed in to change notification settings - Fork 7k
/
esp_openthread_types.h
130 lines (115 loc) · 4.5 KB
/
esp_openthread_types.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Copyright 2021 Espressif Systems (Shanghai) CO LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License
#pragma once
#include "hal/uart_types.h"
#include "sys/_stdint.h"
#include "sys/select.h"
#include "esp_event_base.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief OpenThread event declarations
*
*/
typedef enum {
OPENTHREAD_EVENT_START, /*!< OpenThread stack start */
OPENTHREAD_EVENT_STOP, /*!< OpenThread stack stop */
OPENTHREAD_EVENT_IF_UP, /*!< OpenThread network interface up */
OPENTHREAD_EVENT_IF_DOWN, /*!< OpenThread network interface down */
OPENTHREAD_EVENT_GOT_IP6, /*!< OpenThread stack added IPv6 address */
OPENTHREAD_EVENT_LOST_IP6, /*!< OpenThread stack removed IPv6 address */
OPENTHREAD_EVENT_MULTICAST_GROUP_JOIN, /*!< OpenThread stack joined IPv6 multicast group */
OPENTHREAD_EVENT_MULTICAST_GROUP_LEAVE, /*!< OpenThread stack left IPv6 multicast group */
} esp_openthread_event_t;
/**
* @brief OpenThread event base declaration
*
*/
ESP_EVENT_DECLARE_BASE(OPENTHREAD_EVENT);
/**
* This structure represents a context for a select() based mainloop.
*
*/
typedef struct {
fd_set read_fds; /*!< The read file descriptors */
fd_set write_fds; /*!< The write file descriptors */
fd_set error_fds; /*!< The error file descriptors */
int max_fd; /*!< The max file descriptor */
struct timeval timeout; /*!< The timeout */
} esp_openthread_mainloop_context_t;
/**
* @brief The uart port config for OpenThread.
*
*/
typedef struct {
uart_port_t port; /*!< UART port number */
uart_config_t uart_config; /*!< UART configuration, see uart_config_t docs */
int rx_pin; /*!< UART RX pin */
int tx_pin; /*!< UART TX pin */
} esp_openthread_uart_config_t;
/**
* @brief The radio mode of OpenThread.
*
*/
typedef enum {
RADIO_MODE_NATIVE = 0x0, /*!< Use the native 15.4 radio */
RADIO_MODE_UART_RCP = 0x1, /*!< UART connection to a 15.4 capable radio co-processor (RCP) */
RADIO_MODE_SPI_RCP = 0x2, /*!< SPI connection to a 15.4 capable radio co-processor (RCP) */
} esp_openthread_radio_mode_t;
/**
* @brief How OpenThread connects to the host.
*
*/
typedef enum {
HOST_CONNECTION_MODE_NONE = 0x0, /*!< Disable host connection */
HOST_CONNECTION_MODE_CLI_UART = 0x1, /*!< CLI UART connection to the host */
HOST_CONNECTION_MODE_RCP_UART = 0x2, /*!< RCP UART connection to the host */
} esp_openthread_host_connection_mode_t;
/**
* @brief The OpenThread radio configuration
*
*/
typedef struct {
esp_openthread_radio_mode_t radio_mode; /*!< The radio mode */
esp_openthread_uart_config_t radio_uart_config; /*!< The uart configuration to RCP */
} esp_openthread_radio_config_t;
/**
* @brief The OpenThread host connection configuration
*
*/
typedef struct {
esp_openthread_host_connection_mode_t host_connection_mode; /*!< The host connection mode */
esp_openthread_uart_config_t host_uart_config; /*!< The uart configuration to host */
} esp_openthread_host_connection_config_t;
/**
* @brief The OpenThread port specific configuration
*
*/
typedef struct {
const char *storage_partition_name; /*!< The partition for storing OpenThread dataset */
uint8_t netif_queue_size; /*!< The packet queue size for the network interface */
uint8_t task_queue_size; /*!< The task queue size */
} esp_openthread_port_config_t;
/**
* @brief The OpenThread platform configuration
*
*/
typedef struct {
esp_openthread_radio_config_t radio_config; /*!< The radio configuration */
esp_openthread_host_connection_config_t host_config; /*!< The host connection configuration */
esp_openthread_port_config_t port_config; /*!< The port configuration */
} esp_openthread_platform_config_t;
#ifdef __cplusplus
}
#endif