1 /* BLE based Provisioning Example
2 
3    This example code is in the Public Domain (or CC0 licensed, at your option.)
4 
5    Unless required by applicable law or agreed to in writing, this
6    software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
7    CONDITIONS OF ANY KIND, either express or implied.
8 */
9 
10 #pragma once
11 
12 #include <protocomm_security.h>
13 #include <wifi_provisioning/wifi_config.h>
14 
15 /**
16  * @brief   Get state of WiFi Station during provisioning
17  *
18  * @note    WiFi is initially configured as AP, when
19  *          provisioning starts. After provisioning data
20  *          is provided by user, the WiFi is reconfigured
21  *          to run as both AP and Station.
22  *
23  * @param[out] state    Pointer to wifi_prov_sta_state_t variable to be filled
24  *
25  * @return
26  *  - ESP_OK    : Successfully retrieved wifi state
27  *  - ESP_FAIL  : Provisioning app not running
28  */
29 esp_err_t app_prov_get_wifi_state(wifi_prov_sta_state_t* state);
30 
31 /**
32  * @brief   Get reason code in case of WiFi station
33  *          disconnection during provisioning
34  *
35 * @param[out] reason    Pointer to wifi_prov_sta_fail_reason_t variable to be filled
36  *
37  * @return
38  *  - ESP_OK    : Successfully retrieved wifi disconnect reason
39  *  - ESP_FAIL  : Provisioning app not running
40  */
41 esp_err_t app_prov_get_wifi_disconnect_reason(wifi_prov_sta_fail_reason_t* reason);
42 
43 /**
44  * @brief   Checks if device is provisioned
45  * *
46  * @param[out] provisioned  True if provisioned, else false
47  *
48  * @return
49  *  - ESP_OK      : Retrieved provision state successfully
50  *  - ESP_FAIL    : Failed to retrieve provision state
51  */
52 esp_err_t app_prov_is_provisioned(bool *provisioned);
53 
54 /**
55  * @brief   Runs WiFi as Station
56  *
57  * Configures the WiFi station mode to connect to the
58  * SSID and password specified in config structure,
59  * and starts WiFi to run as station
60  *
61  * @param[in] wifi_cfg  Pointer to WiFi cofiguration structure
62  *
63  * @return
64  *  - ESP_OK      : WiFi configured and started successfully
65  *  - ESP_FAIL    : Failed to set configuration
66  */
67 esp_err_t app_prov_configure_sta(wifi_config_t *wifi_cfg);
68 
69 /**
70  * @brief   Start provisioning via Bluetooth
71  *
72  * @param[in] security  Security mode
73  * @param[in] pop       Pointer to proof of possession (NULL if not present)
74  *
75  * @return
76  *  - ESP_OK      : Provisioning started successfully
77  *  - ESP_FAIL    : Failed to start
78  */
79 esp_err_t app_prov_start_ble_provisioning(int security, const protocomm_security_pop_t *pop);
80