HTTP Form auth
This commit is contained in:
33
src/main.cpp
33
src/main.cpp
@@ -10,6 +10,10 @@
|
||||
#include "esp32-hal-log.h"
|
||||
#include "hal/wdt_hal.h"
|
||||
#include "esp_chip_info.h"
|
||||
#include <time.h>
|
||||
#include <esp_sntp.h>
|
||||
#include "esp_netif.h"
|
||||
#include "esp_netif_sntp.h"
|
||||
#ifdef CONFIG_SOC_SPIRAM_SUPPORTED
|
||||
#include "esp_psram.h"
|
||||
#include "FS.h"
|
||||
@@ -29,7 +33,6 @@
|
||||
#include "RestartReason.h"
|
||||
#include "EspMillis.h"
|
||||
#include "NimBLEDevice.h"
|
||||
#include "esp_netif_sntp.h"
|
||||
|
||||
/*
|
||||
#ifdef DEBUG_NUKIHUB
|
||||
@@ -38,8 +41,6 @@
|
||||
#endif
|
||||
*/
|
||||
|
||||
char log_print_buffer[1024];
|
||||
|
||||
NukiNetworkLock* networkLock = nullptr;
|
||||
NukiNetworkOpener* networkOpener = nullptr;
|
||||
BleScanner::Scanner* bleScanner = nullptr;
|
||||
@@ -71,6 +72,8 @@ int64_t restartTs = 10 * 60 * 1000;
|
||||
|
||||
#endif
|
||||
|
||||
char log_print_buffer[1024];
|
||||
|
||||
PsychicHttpServer* psychicServer = nullptr;
|
||||
PsychicHttpsServer* psychicSSLServer = nullptr;
|
||||
NukiNetwork* network = nullptr;
|
||||
@@ -97,7 +100,6 @@ RestartReason currentRestartReason = RestartReason::NotApplicable;
|
||||
TaskHandle_t otaTaskHandle = nullptr;
|
||||
TaskHandle_t networkTaskHandle = nullptr;
|
||||
|
||||
#ifndef NUKI_HUB_UPDATER
|
||||
ssize_t write_fn(void* cookie, const char* buf, ssize_t size)
|
||||
{
|
||||
Log->write((uint8_t *)buf, (size_t)size);
|
||||
@@ -157,7 +159,6 @@ void setReroute()
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t checkPartition()
|
||||
{
|
||||
@@ -181,6 +182,10 @@ uint8_t checkPartition()
|
||||
}
|
||||
}
|
||||
|
||||
void cbSyncTime(struct timeval *tv) {
|
||||
Log->println("NTP time synched");
|
||||
}
|
||||
|
||||
void networkTask(void *pvParameters)
|
||||
{
|
||||
int64_t networkLoopTs = 0;
|
||||
@@ -204,13 +209,15 @@ void networkTask(void *pvParameters)
|
||||
network->update();
|
||||
bool connected = network->isConnected();
|
||||
|
||||
#ifndef NUKI_HUB_UPDATER
|
||||
if(connected && reroute)
|
||||
{
|
||||
if(preferences->getBool(preference_update_time, false))
|
||||
{
|
||||
esp_netif_sntp_start();
|
||||
}
|
||||
reroute = false;
|
||||
setReroute();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NUKI_HUB_UPDATER
|
||||
wifiConnected = network->wifiConnected();
|
||||
@@ -503,10 +510,6 @@ void setupTasks(bool ota)
|
||||
}
|
||||
}
|
||||
|
||||
void cbSyncTime(struct timeval *tv) {
|
||||
Log->println(("NTP time synched"));
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
//Set Log level to error for all TAGS
|
||||
@@ -822,16 +825,14 @@ void setup()
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
}
|
||||
|
||||
if(preferences->getBool(preference_update_time, false))
|
||||
{
|
||||
esp_sntp_config_t config = ESP_NETIF_SNTP_DEFAULT_CONFIG(preferences->getString(preference_time_server, "pool.ntp.org").c_str());
|
||||
String timeserver = preferences->getString(preference_time_server, "pool.ntp.org");
|
||||
esp_sntp_config_t config = ESP_NETIF_SNTP_DEFAULT_CONFIG(timeserver.c_str());
|
||||
config.start = false;
|
||||
config.server_from_dhcp = true;
|
||||
config.renew_servers_after_new_IP = true;
|
||||
config.index_of_first_server = 1;
|
||||
|
||||
|
||||
if (network->networkDeviceType() == NetworkDeviceType::WiFi)
|
||||
{
|
||||
config.ip_event_to_renew = IP_EVENT_STA_GOT_IP;
|
||||
|
||||
Reference in New Issue
Block a user