1 // Copyright 2017-2018 Espressif Systems (Shanghai) PTE LTD
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
15 #ifndef __ESP_MESH_INTERNAL_H__
16 #define __ESP_MESH_INTERNAL_H__
20 #include "esp_wifi_types.h"
21 #include "esp_wifi_internal.h"
22 #include "esp_wifi_crypto_types.h"
28 /*******************************************************
30 *******************************************************/
32 /*******************************************************
34 *******************************************************/
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 */
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;
53 * @brief mesh networking IE
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 */
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;
92 /*******************************************************
93 * Function Definitions
94 *******************************************************/
96 * @brief set mesh softAP beacon interval
98 * @param interval beacon interval(ms) (100ms ~ 60000ms)
105 esp_err_t esp_mesh_set_beacon_interval(int interval_ms);
108 * @brief get mesh softAP beacon interval
110 * @param interval beacon interval(ms)
115 esp_err_t esp_mesh_get_beacon_interval(int *interval_ms);
118 * @brief set attempts for mesh self-organized networking
126 esp_err_t esp_mesh_set_attempts(mesh_attempts_t *attempts);
129 * @brief get attempts for mesh self-organized networking
137 esp_err_t esp_mesh_get_attempts(mesh_attempts_t *attempts);
140 * @brief set parameters for parent switch
142 * @param paras parameters for parent switch
148 esp_err_t esp_mesh_set_switch_parent_paras(mesh_switch_parent_t *paras);
151 * @brief get parameters for parent switch
153 * @param paras parameters for parent switch
159 esp_err_t esp_mesh_get_switch_parent_paras(mesh_switch_parent_t *paras);
162 * @brief print the number of txQ waiting
168 esp_err_t esp_mesh_print_txQ_waiting(void);
171 * @brief print the number of rxQ waiting
177 esp_err_t esp_mesh_print_rxQ_waiting(void);
180 * @brief set passive scan time
182 * @param interval_ms passive scan time(ms)
189 esp_err_t esp_mesh_set_passive_scan_time(int time_ms);
192 * @brief get passive scan time
194 * @return interval_ms passive scan time(ms)
196 int esp_mesh_get_passive_scan_time(void);
202 #endif /* __ESP_MESH_INTERNAL_H__ */