Preklad bez chyb.

This commit is contained in:
Pavel Brychta 2018-06-26 11:16:09 +02:00
parent 691ecffe39
commit 8f0def0263
3 changed files with 32 additions and 36 deletions

View File

@ -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

View File

@ -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);

View File

@ -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