diff options
Diffstat (limited to 'main/wifi_setup.h')
| -rw-r--r-- | main/wifi_setup.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/main/wifi_setup.h b/main/wifi_setup.h new file mode 100644 index 0000000..17712d5 --- /dev/null +++ b/main/wifi_setup.h | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | #ifndef WIFI_SETUP_H | ||
| 2 | #define WIFI_SETUP_H | ||
| 3 | |||
| 4 | #include "esp_err.h" | ||
| 5 | #include <stdint.h> | ||
| 6 | #include <stdbool.h> | ||
| 7 | |||
| 8 | #define WIFI_SETUP_MAX_APS 20 | ||
| 9 | #define WIFI_SETUP_MAX_VISIBLE 8 | ||
| 10 | #define WIFI_SETUP_SSID_LEN 33 | ||
| 11 | #define WIFI_SETUP_PASS_LEN 64 | ||
| 12 | |||
| 13 | typedef enum { | ||
| 14 | SETUP_SCAN, | ||
| 15 | SETUP_LIST, | ||
| 16 | SETUP_PASSWORD, | ||
| 17 | SETUP_CONNECTING, | ||
| 18 | SETUP_SUCCESS, | ||
| 19 | SETUP_FAILED, | ||
| 20 | SETUP_CANCELLED | ||
| 21 | } setup_state_t; | ||
| 22 | |||
| 23 | typedef struct { | ||
| 24 | char ssid[WIFI_SETUP_SSID_LEN]; | ||
| 25 | int rssi; | ||
| 26 | bool secured; | ||
| 27 | } wifi_ap_info_t; | ||
| 28 | |||
| 29 | typedef struct { | ||
| 30 | setup_state_t state; | ||
| 31 | wifi_ap_info_t aps[WIFI_SETUP_MAX_APS]; | ||
| 32 | int ap_count; | ||
| 33 | int list_scroll; | ||
| 34 | int selected_ap; | ||
| 35 | char selected_ssid[WIFI_SETUP_SSID_LEN]; | ||
| 36 | char connect_ip[16]; | ||
| 37 | bool connect_failed_auth; | ||
| 38 | } wifi_setup_t; | ||
| 39 | |||
| 40 | void wifi_setup_init(wifi_setup_t *setup); | ||
| 41 | void wifi_setup_set_aps(wifi_setup_t *setup, const wifi_ap_info_t *aps, int count); | ||
| 42 | int wifi_setup_visible_count(const wifi_setup_t *setup); | ||
| 43 | const wifi_ap_info_t *wifi_setup_get_visible(const wifi_setup_t *setup, int idx); | ||
| 44 | setup_state_t wifi_setup_handle_select(wifi_setup_t *setup, int list_idx); | ||
| 45 | setup_state_t wifi_setup_handle_connect(wifi_setup_t *setup); | ||
| 46 | setup_state_t wifi_setup_handle_connect_result(wifi_setup_t *setup, bool success, const char *ip); | ||
| 47 | setup_state_t wifi_setup_handle_cancel(wifi_setup_t *setup); | ||
| 48 | setup_state_t wifi_setup_handle_retry(wifi_setup_t *setup); | ||
| 49 | setup_state_t wifi_setup_handle_change_network(wifi_setup_t *setup); | ||
| 50 | |||
| 51 | #endif | ||