diff --git a/build-flags/build_flags_lighthub21 b/build-flags/build_flags_lighthub21 index 4d7ba51..204565b 100644 --- a/build-flags/build_flags_lighthub21 +++ b/build-flags/build_flags_lighthub21 @@ -25,4 +25,5 @@ #-DSERIAL_BAUD=115200 #-DdebugSerialPort=Serial --DRESTART_LAN_ON_MQTT_ERRORS \ No newline at end of file +-DRESTART_LAN_ON_MQTT_ERRORS +-D CORS=\"http://lazyhome.ru\" \ No newline at end of file diff --git a/lighthub/config.cpp b/lighthub/config.cpp index 5ca8655..0726a19 100644 --- a/lighthub/config.cpp +++ b/lighthub/config.cpp @@ -1,5 +1,12 @@ #include "config.h" +String systemConfig::getMACString() +{ +String res; +for (int i=0; i<6; i++) {res+= (((char)mac[i]>>4)+'0');res+=(((char)mac[i]&0xf)+'0');} +return res; +} + int systemConfig::openStream(char mode) { #if defined(FS_STORAGE) @@ -7,7 +14,7 @@ int systemConfig::openStream(char mode) #else stream->open(FN_CONFIG_BIN,mode); #endif - stream->setSize(SYSCONF_SIZE); + //stream->setSize(SYSCONF_SIZE); }; bool systemConfig::isValidSysConf() diff --git a/lighthub/config.h b/lighthub/config.h index e80997b..20d6d40 100644 --- a/lighthub/config.h +++ b/lighthub/config.h @@ -22,6 +22,7 @@ class systemConfig { bool isValidSysConf(); bool getMAC(); + String getMACString(); bool setMAC(macAddress& mac); char * getMQTTpwd(char * buffer, uint16_t bufLen); diff --git a/lighthub/flashstream.cpp b/lighthub/flashstream.cpp index e87f6db..219e4ee 100644 --- a/lighthub/flashstream.cpp +++ b/lighthub/flashstream.cpp @@ -60,9 +60,10 @@ NRFFlashStorage EEPROM; if (fs = SPIFFS.open(_filename,modestr)) { openedMode=mode; + streamSize = DEFAULT_FILESIZE_LIMIT; - if (_filename.endsWith(".json")) {contentType=HTTP_TEXT_JSON;textMode=true;} - else if (_filename.endsWith(".bin")) {contentType=HTTP_OCTET_STREAM;textMode=false;} + if (_filename.endsWith(".json")) {contentType=HTTP_TEXT_JSON;textMode=true;streamSize = MAX_JSON_CONF_SIZE; } + else if (_filename.endsWith(".bin")) {contentType=HTTP_OCTET_STREAM;textMode=false;streamSize = SYSCONF_SIZE; } else if (_filename.endsWith(".txt")) {contentType=HTTP_TEXT_PLAIN;textMode=true;} else if (_filename.endsWith(".html")) {contentType=HTTP_TEXT_HTML;textMode=true;} else if (_filename.endsWith(".gif")) {contentType=HTTP_IMAGE_GIF;textMode=false;} diff --git a/lighthub/main.cpp b/lighthub/main.cpp index 24fffc6..78fe36b 100644 --- a/lighthub/main.cpp +++ b/lighthub/main.cpp @@ -48,18 +48,7 @@ Streamlog errorSerial(&debugSerialPort,LOG_ERROR, ledRED); Streamlog infoSerial (&debugSerialPort,LOG_INFO); #endif -/* -#if defined(FS_STORAGE) -flashStream sysConfStream("/config.bin"); -flashStream JSONStream("/config.json"); -#else -flashStream sysConfStream(SYSCONF_OFFSET,EEPROM_offsetJSON); -flashStream JSONStream(EEPROM_offsetJSON,MAX_JSON_CONF_SIZE); -#endif -*/ - flashStream sysConfStream; - systemConfig sysConf(&sysConfStream); extern long timer0_overflow_count; @@ -242,15 +231,19 @@ bool isNotRetainingStatus() { // ... same sor other http codes // if response != "" - put response in http answer -uint16_t httpHandler(Client& client, String request, long contentLength, bool authorized, String& response ) +uint16_t httpHandler(Client& client, String request, uint8_t method, long contentLength, bool authorized, String& response ) { //String response = ""; debugSerial< - +#define DEFAULT_FILESIZE_LIMIT 65535 #ifndef MAX_JSON_CONF_SIZE #if defined(__SAM3X8E__) diff --git a/lighthub/seekablestream.h b/lighthub/seekablestream.h index b8b6120..c9f245d 100644 --- a/lighthub/seekablestream.h +++ b/lighthub/seekablestream.h @@ -15,6 +15,7 @@ uint16_t contentType; public: seekableStream(unsigned int size):Stream(),streamSize(size) {}; +virtual bool checkPermissions(char mode) {return true;}; unsigned int getSize() {return streamSize;} void setSize (unsigned int size) {streamSize = size;}; virtual unsigned int seek(unsigned int _pos = 0) = 0; diff --git a/pwc/index.html b/pwc/index.html new file mode 100644 index 0000000..daec03a --- /dev/null +++ b/pwc/index.html @@ -0,0 +1,53 @@ + + +

LazyHome PWA

+
+ + + + +
URL: +
Login: +Password: +
+
+ + + +
+ + + + +
item: +command: + +
+