1 // Copyright 2019 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 #pragma once
16 
17 #include <protocomm.h>
18 #include <protocomm_security.h>
19 
20 #include "wifi_provisioning/manager.h"
21 #include "wifi_provisioning/wifi_config.h"
22 #include "wifi_provisioning/wifi_scan.h"
23 
24 /**
25  * @brief   Notify manager that provisioning is done
26  *
27  * Stops the provisioning. This is called by the get_status_handler()
28  * when the status is connected. This has no effect if main application
29  * has disabled auto stop on completion by calling
30  * wifi_prov_mgr_disable_auto_stop()
31  *
32  * @return
33  *  - ESP_OK      : Provisioning will be stopped
34  *  - ESP_FAIL    : Failed to stop provisioning
35  */
36 esp_err_t wifi_prov_mgr_done(void);
37 
38 /**
39  * @brief   Start Wi-Fi AP Scan
40  *
41  * @param[in] blocking        Set true to return only after scanning is complete
42  * @param[in] passive         Set true to perform passive scan instead of default active scan
43  * @param[in] group_channels  Number of channels to scan in one go
44  *                            (set to 0 for scanning all channels in one go)
45  * @param[in] period_ms       Scan time (in milli-seconds) on each channel
46  *
47  * @return
48  *  - ESP_OK    : Successfully started Wi-Fi scanning
49  *  - ESP_FAIL  : Provisioning app not running
50  */
51 esp_err_t wifi_prov_mgr_wifi_scan_start(bool blocking, bool passive,
52                                         uint8_t group_channels,
53                                         uint32_t period_ms);
54 
55 /**
56  * @brief   Use to query the state of Wi-Fi scan
57  *
58  * @return
59  *  - true   : Scan finished
60  *  - false  : Scan running
61  */
62 bool wifi_prov_mgr_wifi_scan_finished(void);
63 
64 /**
65  * @brief   Get the count of results in the scan list
66  *
67  * @return
68  *  - count  : Number of Wi-Fi Access Points detected while scanning
69  */
70 uint16_t wifi_prov_mgr_wifi_scan_result_count(void);
71 
72 /**
73  * @brief   Get AP record for a particular index in the scan list result
74  *
75  * @param[out] index  Index of the result to fetch
76  *
77  * @return
78  *  - result : Pointer to Access Point record
79  */
80 const wifi_ap_record_t *wifi_prov_mgr_wifi_scan_result(uint16_t index);
81 
82 /**
83  * @brief   Get protocomm handlers for wifi_config provisioning endpoint
84  *
85  * @param[out] ptr   pointer to structure to be set
86  *
87  * @return
88  *  - ESP_OK   : success
89  *  - ESP_ERR_INVALID_ARG : null argument
90  */
91 esp_err_t get_wifi_prov_handlers(wifi_prov_config_handlers_t *ptr);
92 
93 /**
94  * @brief   Get protocomm handlers for wifi_scan provisioning endpoint
95  *
96  * @param[out] ptr   pointer to structure to be set
97  *
98  * @return
99  *  - ESP_OK   : success
100  *  - ESP_ERR_INVALID_ARG : null argument
101  */
102 esp_err_t get_wifi_scan_handlers(wifi_prov_scan_handlers_t *ptr);
103