]> granicus.if.org Git - esp-idf/blob - components/esp32/include/esp_mesh_internal.h
Merge branch 'bugfix/disable_vfs_select' into 'master'
[esp-idf] / components / esp32 / include / esp_mesh_internal.h
1 // Copyright 2017-2018 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #ifndef __ESP_MESH_INTERNAL_H__
16 #define __ESP_MESH_INTERNAL_H__
17
18 #include "esp_err.h"
19 #include "esp_wifi.h"
20 #include "esp_wifi_types.h"
21 #include "esp_wifi_internal.h"
22 #include "esp_wifi_crypto_types.h"
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 /*******************************************************
29  *                Constants
30  *******************************************************/
31
32 /*******************************************************
33  *                Structures
34  *******************************************************/
35 typedef struct {
36     int scan;          /**< minimum scan times before being a root, default:10 */
37     int vote;          /**< max vote times in self-healing, default:10000 */
38     int fail;          /**< parent selection fail times, if the scan times reach this value,
39                             will disconnect with associated children and join self-healing. default:60 */
40     int monitor_ie;    /**< acceptable times of parent ie change before update self ie, default:3 */
41 } mesh_attempts_t;
42
43 typedef struct {
44     int duration_ms;   /* parent weak RSSI monitor duration, if the RSSI continues to be weak during this duration_ms,
45                           will switch to a better parent */
46     int cnx_rssi;      /* RSSI threshold for keeping a good connection with parent */
47     int select_rssi;   /* RSSI threshold for parent selection, should be a value greater than switch_rssi */
48     int switch_rssi;   /* RSSI threshold for action to reselect a better parent */
49     int backoff_rssi;  /* RSSI threshold for connecting to the root */
50 } mesh_switch_parent_t;
51
52 /**
53  * @brief mesh networking IE
54  */
55 typedef struct {
56     /**< mesh networking IE head */
57     uint8_t eid;             /**< element ID */
58     uint8_t len;             /**< element length */
59     uint8_t oui[3];          /**< organization identifier */
60     /**< mesh networking IE content */
61     uint8_t type;            /** mesh networking IE type */
62     uint8_t encryped : 1;    /**< if mesh networking IE is encrypted */
63     uint8_t version : 7;     /**< mesh networking IE version */
64     /**< content */
65     uint8_t mesh_type;       /**< mesh device type */
66     uint8_t mesh_id[6];      /**< mesh ID */
67     uint8_t layer_cap;       /**< max layer */
68     uint8_t layer;           /**< current layer */
69     uint8_t assoc_cap;       /**< max connections of mesh AP */
70     uint8_t assoc;           /**< current connections */
71     uint8_t leaf_cap;        /**< leaf capacity */
72     uint8_t leaf_assoc;      /**< the number of current connected leaf */
73     uint16_t root_cap;       /**< root capacity */
74     uint16_t self_cap;       /**< self capacity */
75     uint16_t layer2_cap;     /**< layer2 capacity */
76     uint16_t scan_ap_num;    /**< the number of scanned APs */
77     int8_t rssi;             /**< rssi of the parent */
78     int8_t router_rssi;      /**< rssi of the router */
79     uint8_t flag;            /**< flag of networking */
80     uint8_t rc_addr[6];      /**< root address */
81     int8_t rc_rssi;          /**< root rssi */
82     uint8_t vote_addr[6];    /**< voter address */
83     int8_t vote_rssi;        /**< vote rssi of the router */
84     uint8_t vote_ttl;        /**< vote ttl */
85     uint16_t votes;          /**< votes */
86     uint16_t my_votes;       /**< my votes */
87     uint8_t reason;          /**< reason */
88     uint8_t child[6];        /**< child address */
89     uint8_t toDS;            /**< toDS state */
90 } __attribute__((packed)) mesh_assoc_t;
91
92 /*******************************************************
93  *                Function Definitions
94  *******************************************************/
95 /**
96  * @brief     set mesh softAP beacon interval
97  *
98  * @param     interval  beacon interval(ms) (100ms ~ 60000ms)
99  *
100  * @return
101  *    - ESP_OK
102  *    - ESP_FAIL
103  *    - ESP_ERR_WIFI_ARG
104  */
105 esp_err_t esp_mesh_set_beacon_interval(int interval_ms);
106
107 /**
108  * @brief     get mesh softAP beacon interval
109  *
110  * @param     interval  beacon interval(ms)
111  *
112  * @return
113  *    - ESP_OK
114  */
115 esp_err_t esp_mesh_get_beacon_interval(int *interval_ms);
116
117 /**
118  * @brief    set attempts for mesh self-organized networking
119  *
120  * @param    attempts
121  *
122  * @return
123  *    - ESP_OK
124  *    - ESP_FAIL
125  */
126 esp_err_t esp_mesh_set_attempts(mesh_attempts_t *attempts);
127
128 /**
129  * @brief    get attempts for mesh self-organized networking
130  *
131  * @param    attempts
132  *
133  * @return
134  *    - ESP_OK
135  *    - ESP_FAIL
136  */
137 esp_err_t esp_mesh_get_attempts(mesh_attempts_t *attempts);
138
139 /**
140  * @brief     set parameters for parent switch
141  *
142  * @param     paras  parameters for parent switch
143  *
144  * @return
145  *    - ESP_OK
146  *    - ESP_FAIL
147  */
148 esp_err_t esp_mesh_set_switch_parent_paras(mesh_switch_parent_t *paras);
149
150 /**
151  * @brief     get parameters for parent switch
152  *
153  * @param     paras  parameters for parent switch
154  *
155  * @return
156  *    - ESP_OK
157  *    - ESP_FAIL
158  */
159 esp_err_t esp_mesh_get_switch_parent_paras(mesh_switch_parent_t *paras);
160
161 /**
162  * @brief     print the number of txQ waiting
163  *
164  * @return
165  *    - ESP_OK
166  *    - ESP_FAIL
167  */
168 esp_err_t esp_mesh_print_txQ_waiting(void);
169
170 /**
171  * @brief     print the number of rxQ waiting
172  *
173  * @return
174  *    - ESP_OK
175  *    - ESP_FAIL
176  */
177 esp_err_t esp_mesh_print_rxQ_waiting(void);
178
179 /**
180  * @brief     set passive scan time
181  *
182  * @param     interval_ms  passive scan time(ms)
183  *
184  * @return
185  *    - ESP_OK
186  *    - ESP_FAIL
187  *    - ESP_ERR_ARGUMENT
188  */
189 esp_err_t esp_mesh_set_passive_scan_time(int time_ms);
190
191 /**
192  * @brief     get passive scan time
193  *
194  * @return    interval_ms  passive scan time(ms)
195  */
196 int esp_mesh_get_passive_scan_time(void);
197
198
199 #ifdef __cplusplus
200 }
201 #endif
202 #endif /* __ESP_MESH_INTERNAL_H__ */