make bootstraping code from demo part of component
This commit is contained in:
parent
f1ff7079fa
commit
de55a62409
3 changed files with 26 additions and 10 deletions
|
@ -19,4 +19,6 @@ uint8_t wifi_manager_add_ap(char *essid, char *password);
|
||||||
void wifi_manager_connect();
|
void wifi_manager_connect();
|
||||||
EventGroupHandle_t wifi_manager_start();
|
EventGroupHandle_t wifi_manager_start();
|
||||||
|
|
||||||
|
int wifi_manager_bootstrap_config();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -268,3 +268,26 @@ EventGroupHandle_t wifi_manager_start() {
|
||||||
|
|
||||||
return wm_event_group;
|
return wm_event_group;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int wifi_manager_bootstrap_config() {
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "Bootstrapping config from IDF config");
|
||||||
|
|
||||||
|
if(strlen(CONFIG_WIFI_MANAGER_TEST_AP) > 0) {
|
||||||
|
wifi_manager_add_ap(CONFIG_WIFI_MANAGER_TEST_AP, CONFIG_WIFI_MANAGER_TEST_PWD);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strlen(CONFIG_WIFI_MANAGER_TEST_AP1) > 0) {
|
||||||
|
wifi_manager_add_ap(CONFIG_WIFI_MANAGER_TEST_AP1, CONFIG_WIFI_MANAGER_TEST_PWD1);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strlen(CONFIG_WIFI_MANAGER_TEST_AP2) > 0) {
|
||||||
|
wifi_manager_add_ap(CONFIG_WIFI_MANAGER_TEST_AP2, CONFIG_WIFI_MANAGER_TEST_PWD2);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
|
@ -126,16 +126,7 @@ void app_main() {
|
||||||
wifi_manager_reset_store();
|
wifi_manager_reset_store();
|
||||||
|
|
||||||
if(wifi_manager_ap_count() == 0) {
|
if(wifi_manager_ap_count() == 0) {
|
||||||
ESP_LOGI(TAG, "Adding new AP");
|
wifi_manager_bootstrap_config();
|
||||||
|
|
||||||
if(strlen(CONFIG_WIFI_MANAGER_TEST_AP) > 0)
|
|
||||||
wifi_manager_add_ap(CONFIG_WIFI_MANAGER_TEST_AP, CONFIG_WIFI_MANAGER_TEST_PWD);
|
|
||||||
|
|
||||||
if(strlen(CONFIG_WIFI_MANAGER_TEST_AP1) > 0)
|
|
||||||
wifi_manager_add_ap(CONFIG_WIFI_MANAGER_TEST_AP1, CONFIG_WIFI_MANAGER_TEST_PWD1);
|
|
||||||
|
|
||||||
if(strlen(CONFIG_WIFI_MANAGER_TEST_AP2) > 0)
|
|
||||||
wifi_manager_add_ap(CONFIG_WIFI_MANAGER_TEST_AP2, CONFIG_WIFI_MANAGER_TEST_PWD2);
|
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGI(TAG, "Got AP from store, waiting for connection");
|
ESP_LOGI(TAG, "Got AP from store, waiting for connection");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue