From 8f0def0263c75ae55737cf6289ef85e5844bc857 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 26 Jun 2018 11:16:09 +0200 Subject: [PATCH] Preklad bez chyb. --- src/configuration.h | 4 ++-- src/web.ino | 41 +++++++++++++++++++++-------------------- src/xpvsp.ino | 23 +++++++++-------------- 3 files changed, 32 insertions(+), 36 deletions(-) diff --git a/src/configuration.h b/src/configuration.h index f61d2d4..a748b7f 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -9,11 +9,11 @@ #define DEBUG_BUILD // **** ladici varianta s Arduino OTA -#define HTTP_UPDATE // **** moznost aktualizace firmware pres www server pomoci http://%s.local/update +// #define HTTP_UPDATE // **** moznost aktualizace firmware pres www server pomoci http://%s.local/update #define HTTP_UPDATE_USERNAME "admin" // **** uzivatelske jmeno pro update firmware (zapoznamkovanim teto definice vypneme nutnost prihlasovani) #define HTTP_UPDATE_PASSWORD "nimda" // **** uzivatelske heslo pro update firmware -//#define USE_SPIFFS // **** podpora pro praci s SPIFFS souborovym systemem (webovy server dokaze servirovat stranky z SPIFFS) +#define USE_SPIFFS // **** podpora pro praci s SPIFFS souborovym systemem (webovy server dokaze servirovat stranky z SPIFFS) #define FORCE_CONFIG_BUTTON_PIN NO_PIN // **** I/O pin, pouzity pro vynuceni konfigurace diff --git a/src/web.ino b/src/web.ino index 6f45e75..df8c097 100644 --- a/src/web.ino +++ b/src/web.ino @@ -65,28 +65,30 @@ void handleNotFound(AsyncWebServerRequest *request) } else #endif - String message; - - message.reserve(1024); - - message = F("Page Not Found\r\n\r\nURI:"); - message.concat(request->url()); - message.concat(F("\r\nMethod: ")); - message.concat((request->method() == HTTP_GET) ? F("GET") : F("POST")); - message.concat(F("\r\nParams: ")); - message.concat(request->params()); - message.concat(F("\r\n")); - - for (unsigned int i = 0; i < request->params(); i++ ) { - AsyncWebParameter *p = request->getParam(i); - message.concat(F(" ")); - message.concat(p->name()); - message.concat(F(": ")); - message.concat(p->value()); + String message; + + message.reserve(1024); + + message = F("Page Not Found\r\n\r\nURI:"); + message.concat(request->url()); + message.concat(F("\r\nMethod: ")); + message.concat((request->method() == HTTP_GET) ? F("GET") : F("POST")); + message.concat(F("\r\nParams: ")); + message.concat(request->params()); message.concat(F("\r\n")); + + for (unsigned int i = 0; i < request->params(); i++ ) + { + AsyncWebParameter *p = request->getParam(i); + message.concat(F(" ")); + message.concat(p->name()); + message.concat(F(": ")); + message.concat(p->value()); + message.concat(F("\r\n")); + } + request->send(404, FPSTR(TEXTPLAIN), message); } - request->send(404, FPSTR(TEXTPLAIN), message); } void www_onUpgrade(AsyncWebServerRequest *request) @@ -189,7 +191,6 @@ void webserver_init(void) #ifdef HTTP_UPDATE httpUpdater.setup(&www); #endif -// TRACE_ADDWEB(&www); // ladici stranka #ifdef USE_CRASHDUMP www.on("/crash", handleCrash); www.on("/crashclear", handleCrashClear); diff --git a/src/xpvsp.ino b/src/xpvsp.ino index f9232d2..4272d1d 100644 --- a/src/xpvsp.ino +++ b/src/xpvsp.ino @@ -52,12 +52,16 @@ // Definice obsazeni EEPROM #define elementSize(type, element) sizeof(((type *)0)->element) +#define countof(a) (sizeof(a) / sizeof(a[0])) + typedef struct { wificonfigarea_t wc; // oblast, vyhrazena pro konfiguraci WiFi -// **** sem pokracuji dalsi polozky, ukladane do EEPROM - -} eepromdata_t; +#ifdef USE_CRASHDUMP + #warning CRASHDUMP save memory allocated! + uint8_t sc[SAVE_CRASH_SPACE_SIZE]; // misto pro uschovani padu aplikace +#endif +}eepromconfig_t; #if (LED_PIN != NO_PIN) LED led(LED_PIN, LOW, HIGH); @@ -146,7 +150,7 @@ void ICACHE_FLASH_ATTR setup() int _fc; TRACE_INIT; // inicializace ladeni - EEPROM.begin(sizeof(eepromdata_t) + 10); // zahajujeme praci s EEPROM (10 bytu je jen rezerva) + EEPROM.begin(sizeof(eepromconfig_t) + 10); // zahajujeme praci s EEPROM (10 bytu je jen rezerva) #if (LED_PIN != NO_PIN) led.begin(); // inicializace signalizace #endif @@ -161,7 +165,7 @@ void ICACHE_FLASH_ATTR setup() { WiFiConfig wifi; // konfigurace WiFi casti ESP modulu - if (WCR_OK != wifi.begin(offsetof(eepromdata_t, wc), _fc, 60, wificfgcb)) // startujeme pripojeni + if (WCR_OK != wifi.begin(offsetof(eepromconfig_t, wc), _fc, 60, wificfgcb)) // startujeme pripojeni ESP.restart(); } if (ESP.getFlashChipRealSize() > 1000000) @@ -188,15 +192,6 @@ void ICACHE_FLASH_ATTR setup() TRACE(TRACE_ERROR, F("SPIFFS neni pripojeny!")); #endif // Start weboveho serveru - sem je mozno pridavat odkazy na dalsi stranky - -#ifdef HTTP_UPDATE - #ifndef HTTP_UPDATE_USERNAME - httpUpdater.setup(&www); - #else - httpUpdater.setup(&www, _huuser.decrypt(), _hupass.decrypt()); - #endif -#endif - webserver_init(); // startujeme webovy server vsp_init(); // **** dalsi uzivatelska inicializace