]> granicus.if.org Git - esp-idf/blob - components/esp32/include/esp_mesh_internal.h
add mesh feature
[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  *                Function Definitions
54  *******************************************************/
55 /**
56  * @brief     set mesh softAP beacon interval
57  *
58  * @param     interval  beacon interval(ms) (100ms ~ 60000ms)
59  *
60  * @return
61  *    - ESP_OK
62  *    - ESP_FAIL
63  *    - ESP_ERR_WIFI_ARG
64  */
65 esp_err_t esp_mesh_set_beacon_interval(int interval_ms);
66
67 /**
68  * @brief     get mesh softAP beacon interval
69  *
70  * @param     interval  beacon interval(ms)
71  *
72  * @return
73  *    - ESP_OK
74  */
75 esp_err_t esp_mesh_get_beacon_interval(int *interval_ms);
76
77 /**
78  * @brief    set attempts for mesh self-organized networking
79  *
80  * @param    attempts
81  *
82  * @return
83  *    - ESP_OK
84  *    - ESP_FAIL
85  */
86 esp_err_t esp_mesh_set_attempts(mesh_attempts_t *attempts);
87
88 /**
89  * @brief    get attempts for mesh self-organized networking
90  *
91  * @param    attempts
92  *
93  * @return
94  *    - ESP_OK
95  *    - ESP_FAIL
96  */
97 esp_err_t esp_mesh_get_attempts(mesh_attempts_t *attempts);
98
99 /**
100  * @brief     set parameters for parent switch
101  *
102  * @param     paras  parameters for parent switch
103  *
104  * @return
105  *    - ESP_OK
106  *    - ESP_FAIL
107  */
108 esp_err_t esp_mesh_set_switch_parent_paras(mesh_switch_parent_t *paras);
109
110 /**
111  * @brief     get parameters for parent switch
112  *
113  * @param     paras  parameters for parent switch
114  *
115  * @return
116  *    - ESP_OK
117  *    - ESP_FAIL
118  */
119 esp_err_t esp_mesh_get_switch_parent_paras(mesh_switch_parent_t *paras);
120
121 /**
122  * @brief     print the number of txQ waiting
123  *
124  * @return
125  *    - ESP_OK
126  *    - ESP_FAIL
127  */
128 esp_err_t esp_mesh_print_txQ_waiting(void);
129
130 /**
131  * @brief     print the number of rxQ waiting
132  *
133  * @return
134  *    - ESP_OK
135  *    - ESP_FAIL
136  */
137 esp_err_t esp_mesh_print_rxQ_waiting(void);
138
139 /**
140  * @brief     set passive scan time
141  *
142  * @param     interval_ms  passive scan time(ms)
143  *
144  * @return
145  *    - ESP_OK
146  *    - ESP_FAIL
147  *    - ESP_ERR_ARGUMENT
148  */
149 esp_err_t esp_mesh_set_passive_scan_time(int time_ms);
150
151 /**
152  * @brief     get passive scan time
153  *
154  * @return    interval_ms  passive scan time(ms)
155  */
156 int esp_mesh_get_passive_scan_time(void);
157
158
159 #ifdef __cplusplus
160 }
161 #endif
162 #endif /* __ESP_MESH_INTERNAL_H__ */