connect to wifi via sdkconfig
Signed-off-by: Peter Siegmund <peter@rdkr.com>
This commit is contained in:
@@ -3,7 +3,9 @@ idf_component_register(SRCS "main.cpp"
|
||||
PRIV_REQUIRES
|
||||
lilygo-epd47
|
||||
smartconfig
|
||||
connectivity
|
||||
mapView
|
||||
nvs_flash
|
||||
json)
|
||||
|
||||
spiffs_create_partition_image(spiffs ../data FLASH_IN_PROJECT)
|
||||
|
@@ -1,13 +1,19 @@
|
||||
menu "WiFi Configuration Options"
|
||||
config WIFI_SSID
|
||||
string "WIFI SSID"
|
||||
default ""
|
||||
default "ssid"
|
||||
help
|
||||
SSID of the WiFi network to connect to.
|
||||
|
||||
config WIFI_PASSWORD
|
||||
string "WIFI Password"
|
||||
default ""
|
||||
default "password"
|
||||
help
|
||||
Password of the WiFi network to connect to.
|
||||
|
||||
config ESP_MAXIMUM_RETRY
|
||||
int "Maximum retry"
|
||||
default 5
|
||||
help
|
||||
Set the Maximum retry to avoid station reconnecting to the AP unlimited when the AP is really inexistent.
|
||||
endmenu
|
||||
|
@@ -1,14 +1,51 @@
|
||||
#include <cJSON.h>
|
||||
#include <esp_task.h>
|
||||
#include <esp_task_wdt.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "connectivity.h"
|
||||
#include "epd_driver.h"
|
||||
#include "esp_task.h"
|
||||
#include "esp_task_wdt.h"
|
||||
#include "fonts/opensans16.h"
|
||||
#include "mapView.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "smartconfig.h"
|
||||
#include "utilities.h"
|
||||
|
||||
void setup(void) {
|
||||
void nvs_init(void) {
|
||||
esp_err_t ret = nvs_flash_init();
|
||||
if (ret == ESP_ERR_NVS_NO_FREE_PAGES ||
|
||||
ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||
ret = nvs_flash_init();
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
}
|
||||
|
||||
void splash_screen(void) {
|
||||
epd_init();
|
||||
nvs_init();
|
||||
epd_poweron();
|
||||
epd_clear();
|
||||
|
||||
int32_t x = 100;
|
||||
int32_t y = 100;
|
||||
char buffer[100];
|
||||
sprintf(buffer, "Connecting to SSDI: %s", CONFIG_WIFI_SSID);
|
||||
writeln(&OpenSans16, buffer, &x, &y, NULL);
|
||||
auto ret = init_wifi();
|
||||
if (ret != 0) {
|
||||
epd_clear();
|
||||
writeln(&OpenSans16, "Failed to connect to WiFi.", &x, &y, NULL);
|
||||
epd_poweroff();
|
||||
while (1) {
|
||||
///
|
||||
};
|
||||
}
|
||||
epd_poweroff();
|
||||
}
|
||||
|
||||
void setup(void) {
|
||||
splash_screen();
|
||||
|
||||
// init_smartconfig();
|
||||
xTaskCreatePinnedToCore(mapView, "mapView", 4096, NULL, 5, NULL, 1);
|
||||
|
Reference in New Issue
Block a user