Compare commits
No commits in common. "development" and "8286b2e3ce4d9140247155bd55c642bb69060984" have entirely different histories.
developmen
...
8286b2e3ce
3 changed files with 4 additions and 22 deletions
|
@ -1,6 +0,0 @@
|
||||||
idf_component_register(SRCS
|
|
||||||
"main/esp32-wifi-manager.c"
|
|
||||||
|
|
||||||
INCLUDE_DIRS "include"
|
|
||||||
REQUIRES nvs_flash
|
|
||||||
)
|
|
|
@ -12,14 +12,12 @@ void wifi_manager_reset_store();
|
||||||
#define AP_AVAILABLE (BIT2)
|
#define AP_AVAILABLE (BIT2)
|
||||||
#define WIFI_IDLE (BIT3)
|
#define WIFI_IDLE (BIT3)
|
||||||
#define WIFI_SCANNING (BIT4)
|
#define WIFI_SCANNING (BIT4)
|
||||||
#define WM_GOT_IP (BIT7)
|
|
||||||
|
|
||||||
uint8_t wifi_manager_ap_count();
|
uint8_t wifi_manager_ap_count();
|
||||||
uint8_t wifi_manager_add_ap(char *essid, char *password);
|
uint8_t wifi_manager_add_ap(char *essid, char *password);
|
||||||
|
|
||||||
void wifi_manager_connect();
|
void wifi_manager_connect();
|
||||||
EventGroupHandle_t wifi_manager_start(char *hostname);
|
EventGroupHandle_t wifi_manager_start();
|
||||||
EventGroupHandle_t wifi_manager_get_event_group();
|
|
||||||
|
|
||||||
int wifi_manager_bootstrap_config();
|
int wifi_manager_bootstrap_config();
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#define MAX_PASSWORD (64)
|
#define MAX_PASSWORD (64)
|
||||||
|
|
||||||
static const char *TAG = "WM";
|
static const char *TAG = "WM";
|
||||||
static EventGroupHandle_t wm_event_group;
|
|
||||||
nvs_handle nvs;
|
nvs_handle nvs;
|
||||||
|
|
||||||
typedef struct wifi_manager_ap_info {
|
typedef struct wifi_manager_ap_info {
|
||||||
|
@ -41,10 +40,7 @@ typedef struct ap_store_base {
|
||||||
} ap_store_t;
|
} ap_store_t;
|
||||||
|
|
||||||
ap_store_t ap_store;
|
ap_store_t ap_store;
|
||||||
|
static EventGroupHandle_t wm_event_group;
|
||||||
EventGroupHandle_t wifi_manager_get_event_group() {
|
|
||||||
return wm_event_group;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t wifi_manager_ap_count() {
|
uint8_t wifi_manager_ap_count() {
|
||||||
return ap_store.count;
|
return ap_store.count;
|
||||||
|
@ -65,8 +61,6 @@ static esp_err_t wifi_event_handler(void* arg, esp_event_base_t event_base, int3
|
||||||
ESP_LOGI(TAG, "SYSTEM_EVENT_STA_GOT_IP");
|
ESP_LOGI(TAG, "SYSTEM_EVENT_STA_GOT_IP");
|
||||||
ESP_LOGI(TAG, "Got IP: %s\n",
|
ESP_LOGI(TAG, "Got IP: %s\n",
|
||||||
ip4addr_ntoa(&event->ip_info.ip));
|
ip4addr_ntoa(&event->ip_info.ip));
|
||||||
|
|
||||||
xEventGroupSetBits(wm_event_group, WM_GOT_IP);
|
|
||||||
} else if(event_id == SYSTEM_EVENT_STA_DISCONNECTED) {
|
} else if(event_id == SYSTEM_EVENT_STA_DISCONNECTED) {
|
||||||
wifi_event_sta_disconnected_t *event = ( wifi_event_sta_disconnected_t*)event_data;
|
wifi_event_sta_disconnected_t *event = ( wifi_event_sta_disconnected_t*)event_data;
|
||||||
|
|
||||||
|
@ -263,7 +257,7 @@ void wifi_manager_load_config() {
|
||||||
ESP_LOGI(TAG, "AP: %s", ap_store.aps[i].ssid);
|
ESP_LOGI(TAG, "AP: %s", ap_store.aps[i].ssid);
|
||||||
};
|
};
|
||||||
|
|
||||||
EventGroupHandle_t wifi_manager_start(char *hostname) {
|
EventGroupHandle_t wifi_manager_start() {
|
||||||
ESP_ERROR_CHECK(nvs_open("wm-config", NVS_READWRITE, &nvs));
|
ESP_ERROR_CHECK(nvs_open("wm-config", NVS_READWRITE, &nvs));
|
||||||
|
|
||||||
wm_event_group = xEventGroupCreate();
|
wm_event_group = xEventGroupCreate();
|
||||||
|
@ -272,11 +266,7 @@ EventGroupHandle_t wifi_manager_start(char *hostname) {
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_netif_init());
|
ESP_ERROR_CHECK(esp_netif_init());
|
||||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||||
esp_netif_t *netif = esp_netif_create_default_wifi_sta();
|
esp_netif_create_default_wifi_sta();
|
||||||
|
|
||||||
if(hostname != NULL) {
|
|
||||||
esp_netif_set_hostname(netif, hostname);
|
|
||||||
}
|
|
||||||
|
|
||||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue