From 1641bd2be40603117c0b1ab77011c5cae2c31f91 Mon Sep 17 00:00:00 2001 From: Morgan Allen Date: Mon, 3 Sep 2018 15:35:55 -0700 Subject: [PATCH] sync up test project --- test/wm-test-project/Makefile | 1 + test/wm-test-project/main/main.c | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/test/wm-test-project/Makefile b/test/wm-test-project/Makefile index bfa7e93..f3e1d6e 100644 --- a/test/wm-test-project/Makefile +++ b/test/wm-test-project/Makefile @@ -4,5 +4,6 @@ # PROJECT_NAME := wm-test-project +COMPONENT_ADD_INCLUDEDIRS := main include include $(IDF_PATH)/make/project.mk diff --git a/test/wm-test-project/main/main.c b/test/wm-test-project/main/main.c index 71293a1..aa1b7e1 100644 --- a/test/wm-test-project/main/main.c +++ b/test/wm-test-project/main/main.c @@ -10,6 +10,8 @@ #include "nvs_flash.h" #include "sdkconfig.h" +#include "esp32-wifi-manager.h" + #define TAG "WM-TEST" #define BUF_SIZE (1024) #define RD_BUF_SIZE (BUF_SIZE) @@ -65,9 +67,13 @@ void loop(void *p) { ESP_LOGI(TAG, "starting main loop"); while(true) { - vTaskDelay(1000 / portTICK_PERIOD_MS); + vTaskDelay(5000 / portTICK_PERIOD_MS); - ESP_LOGI(TAG, "main loop"); + ESP_LOGI(TAG, "resetting store"); + + wifi_manager_reset_store(); + + while(true) {}; } } @@ -77,6 +83,7 @@ void app_main() { // Initialize NVS. ret = nvs_flash_init(); if (ret == ESP_ERR_NVS_NO_FREE_PAGES) { + ESP_LOGI(TAG, "Erasing flash memory"); ESP_ERROR_CHECK(nvs_flash_erase()); ret = nvs_flash_init(); } @@ -105,5 +112,15 @@ void app_main() { ESP_LOGI(TAG, "MAC: %X:%X:%X:%X:%X:%X\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + wifi_manager_load_config(); + + if(wifi_manager_ap_count() == 0) { + ESP_LOGI(TAG, "Adding new AP"); + + wifi_manager_add_ap(CONFIG_WIFI_MANAGER_TEST_AP, CONFIG_WIFI_MANAGER_TEST_PWD); + } else { + ESP_LOGI(TAG, "Got AP from store, waiting for connection"); + } + xTaskCreate(&loop, "loop", 2048, NULL, 6, NULL); };