diff --git a/WEBFiles/adc.htm b/WEBFiles/adc.htm deleted file mode 100644 index a4e492c..0000000 --- a/WEBFiles/adc.htm +++ /dev/null @@ -1,10 +0,0 @@ -~inc:grfx1.inc~ -ADC: ? - -~inc:grfx2.inc~ \ No newline at end of file diff --git a/WEBFiles/menu.inc b/WEBFiles/menu.inc index a409e6c..d950af5 100644 --- a/WEBFiles/menu.inc +++ b/WEBFiles/menu.inc @@ -5,16 +5,16 @@ WebSocket WiFi settings WiFi Scan - WebFS Upload + WebFS Upload System Setup
GPIO - HexDump Bytes - HexDump DWord - Download Bin - Deep Sleep - Debug and Test + HexDump Bytes + HexDump DWord + Download Bin + Deep Sleep + Debug and Test
\ No newline at end of file diff --git a/WEBFiles/protect/hexdmpb.txt b/WEBFiles/protect2/hexdmpb.txt similarity index 100% rename from WEBFiles/protect/hexdmpb.txt rename to WEBFiles/protect2/hexdmpb.txt diff --git a/WEBFiles/protect/hexdmpd.htm b/WEBFiles/protect2/hexdmpd.htm similarity index 87% rename from WEBFiles/protect/hexdmpd.htm rename to WEBFiles/protect2/hexdmpd.htm index f754d8f..3b30c46 100644 --- a/WEBFiles/protect/hexdmpd.htm +++ b/WEBFiles/protect2/hexdmpd.htm @@ -17,7 +17,7 @@ - + @@ -35,7 +35,7 @@ \ No newline at end of file diff --git a/WEBFiles/protect/hexdmpd.txt b/WEBFiles/protect2/hexdmpd.txt similarity index 100% rename from WEBFiles/protect/hexdmpd.txt rename to WEBFiles/protect2/hexdmpd.txt diff --git a/WEBFiles/protect/ram.bin b/WEBFiles/protect2/ram.bin similarity index 100% rename from WEBFiles/protect/ram.bin rename to WEBFiles/protect2/ram.bin diff --git a/WEBFiles/protect2/setup.htm b/WEBFiles/protect2/setup.htm new file mode 100644 index 0000000..61b93ae --- /dev/null +++ b/WEBFiles/protect2/setup.htm @@ -0,0 +1,97 @@ + + + + RTL871X Setup + + + + +~inc:menu.inc~ +
+

System Setup

+
+
Write addr, value:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
WEB (HTTP) port:
WEB recved timeout:
WEB close timeout:
PowerSave Enable: + + +
LogUART Printf() enable: + + +
Web pcb close enable: + + +
Checking pin WiFi cfg reset: + + +
NetBIOS enable: + + +
SNTP enable: + + +
Captive Portal AP: + + +
+

+ + + +

+ + +~inc:footer.inc~ + + \ No newline at end of file diff --git a/WEBFiles/protect/tstfuncs.htm b/WEBFiles/protect2/tstfuncs.htm similarity index 100% rename from WEBFiles/protect/tstfuncs.htm rename to WEBFiles/protect2/tstfuncs.htm diff --git a/WEBFiles/protect/upload.htm b/WEBFiles/protect3/upload.htm similarity index 90% rename from WEBFiles/protect/upload.htm rename to WEBFiles/protect3/upload.htm index d8e355d..5ac8ef5 100644 --- a/WEBFiles/protect/upload.htm +++ b/WEBFiles/protect3/upload.htm @@ -17,7 +17,7 @@ Curent Disk has ~wfs_files~ files, Disk Size: ~wfs_size~ bytes.
Disk Addres: ~wfs_addr~, Max Disk Size: ~wfs_max_size~ bytes, Max 250 files.

Flash ID: ~sys_fid~, Size: ~sys_fsize~ bytes.
-Download fullflash.bin

+Download fullflash.bin

~inc:footer.inc~ \ No newline at end of file diff --git a/WEBFiles/ws2.css b/WEBFiles/ws2.css index 688bba6..2ef69d9 100644 --- a/WEBFiles/ws2.css +++ b/WEBFiles/ws2.css @@ -1,7 +1,7 @@ #consoleLog { overflow-y: scroll; width: 480px; - height: 800px; + height: 200px; border: solid 1px #aaaaaa; background-color: #ffffff; padding-left: 5px; } diff --git a/flasher/file_info.jlink b/flasher/file_info.jlink index 0e13589..f528700 100644 --- a/flasher/file_info.jlink +++ b/flasher/file_info.jlink @@ -1,5 +1,5 @@ define call1 -set $ImageSize = 0xF6E0 +set $ImageSize = 0x10340 set $ImageAddr = 0x0D0000 end define call2 diff --git a/project/inc/web/web_srv.h b/project/inc/web/web_srv.h index 10c4c6c..f58c81e 100644 --- a/project/inc/web/web_srv.h +++ b/project/inc/web/web_srv.h @@ -101,8 +101,8 @@ typedef struct WS_FRSTAT ws; // параметры websoc #endif #if USE_WEB_AUTH_LEVEL - uint8 auth_level; // Уровень авторизации по паролю - uint8 auth_realm; // Требуемый уровень авторизации (минимальный уровень) + uint8 auth_level; // Уровень авторизации пользователя по паролю WEB_AUTH_LEVEL_TYPE + uint8 auth_realm; // Требуемый уровень авторизации (минимальный уровень) WEB_AUTH_LEVEL_TYPE #endif uint8 fileType; // File type to return with Content-Type (if SCB_FCALBACK) } WEB_SRV_CONN; diff --git a/project/src/user/user_start.c b/project/src/user/user_start.c index 0c3c95d..8b1450d 100644 --- a/project/src/user/user_start.c +++ b/project/src/user/user_start.c @@ -14,11 +14,13 @@ #include "netbios/netbios.h" #include "sntp/sntp.h" #include "user/sys_cfg.h" +#include "wifi_api.h" #include "web/web_srv.h" #include "webfs/webfs.h" struct SystemCfg syscfg = { .cfg.w = SYS_CFG_DEBUG_ENA + | SYS_CFG_PIN_CLR_ENA #if defined(USE_NETBIOS) && USE_NETBIOS | SYS_CFG_NETBIOS_ENA #endif @@ -59,7 +61,11 @@ void sys_write_cfg(void) void user_init_thrd(void) { - flash_read_cfg(&syscfg, FEEP_ID_SYS_CFG, sizeof(syscfg)); + if(syscfg.cfg.b.pin_clear_cfg_enable + && 0) { // user_test_clear_pin() + wifi_cfg.load_flg = 0; + } + else flash_read_cfg(&syscfg, FEEP_ID_SYS_CFG, sizeof(syscfg)); if(!syscfg.cfg.b.debug_print_enable) print_off = 1; diff --git a/project/src/web/web_int_callbacks.c b/project/src/web/web_int_callbacks.c index dde1377..7eac473 100644 --- a/project/src/web/web_int_callbacks.c +++ b/project/src/web/web_int_callbacks.c @@ -358,15 +358,24 @@ void ICACHE_FLASH_ATTR web_int_callback(TCP_SERV_CONN *ts_conn, uint8 *cstr) #endif ifcmp("start") tcp_puts("0x%08x", web_conn->udata_start); else ifcmp("stop") tcp_puts("0x%08x", web_conn->udata_stop); +#if USE_WEB_AUTH_LEVEL + else ifcmp("realm") tcp_puts("%u", web_conn->auth_realm); + else ifcmp("auth") tcp_puts("%u", web_conn->auth_level); +#endif else ifcmp("xml_") { cstr+=4; ifcmp("scan") web_wscan_xml(ts_conn); +#if WEB_DEBUG_FUNCTIONS +#if USE_WEB_AUTH_LEVEL + if(web_conn->auth_level < WEB_AUTH_LEVEL_USER) return; +#endif else { web_conn->udata_start&=~3; ifcmp("ram") tcp_puts("0x%08x", *((uint32*)web_conn->udata_start)); else tcp_put('?'); web_conn->udata_start += 4; } +#endif } else ifcmp("sys_") { cstr+=4; @@ -394,7 +403,12 @@ void ICACHE_FLASH_ATTR web_int_callback(TCP_SERV_CONN *ts_conn, uint8 *cstr) else ifcmp("clkcpu") tcp_puts("%u", HalGetCpuClk()); else ifcmp("debug") tcp_put('1' - (print_off & 1)); // rtl_print on/off #if WEB_DEBUG_FUNCTIONS - else ifcmp("restart") web_conn->web_disc_cb = (web_func_disc_cb)sys_reset; + else ifcmp("restart") { +#if USE_WEB_AUTH_LEVEL + if(web_conn->auth_level < WEB_AUTH_LEVEL_USER) return; +#endif + web_conn->web_disc_cb = (web_func_disc_cb)sys_reset; + } else ifcmp("ram") tcp_puts("0x%08x", *((uint32 *)(ahextoul(cstr+3)&(~3)))); else ifcmp("rdec") tcp_puts("%d", *((uint32 *)(ahextoul(cstr+4)&(~3)))); #endif // #if WEB_DEBUG_FUNCTIONS @@ -519,6 +533,9 @@ void ICACHE_FLASH_ATTR web_int_callback(TCP_SERV_CONN *ts_conn, uint8 *cstr) #endif } else ifcmp("bin_") { +#if USE_WEB_AUTH_LEVEL + if(web_conn->auth_level < WEB_AUTH_LEVEL_USER) return; +#endif cstr+=4; ifcmp("flash") { cstr+=5; @@ -553,6 +570,9 @@ void ICACHE_FLASH_ATTR web_int_callback(TCP_SERV_CONN *ts_conn, uint8 *cstr) } #if WEB_DEBUG_FUNCTIONS else ifcmp("hexdmp") { +#if USE_WEB_AUTH_LEVEL + if(web_conn->auth_level < WEB_AUTH_LEVEL_USER) return; +#endif if(cstr[6]=='d') ts_conn->flag.user_option1 = 1; else ts_conn->flag.user_option1 = 0; web_hexdump(ts_conn); diff --git a/project/src/web/web_int_vars.c b/project/src/web/web_int_vars.c index ad85fd2..0a775b1 100644 --- a/project/src/web/web_int_vars.c +++ b/project/src/web/web_int_vars.c @@ -83,6 +83,14 @@ void ICACHE_FLASH_ATTR web_int_vars(TCP_SERV_CONN *ts_conn, uint8 *pcmd, uint8 * #endif ifcmp("start") web_conn->udata_start = val; else ifcmp("stop") web_conn->udata_stop = val; +#if USE_WEB_AUTH_LEVEL + else ifcmp("user") web_conn->auth_level = UserAuthorization(pvar, strlen(pvar)); + else if(web_conn->auth_level < WEB_AUTH_LEVEL_USER) { + if(!web_conn->auth_realm) web_conn->auth_realm = WEB_AUTH_LEVEL_USER; + SetSCB(SCB_AUTH); + return; + } +#endif #if WEB_DEBUG_FUNCTIONS else ifcmp("sys_") { cstr+=4; @@ -236,6 +244,12 @@ void ICACHE_FLASH_ATTR web_int_vars(TCP_SERV_CONN *ts_conn, uint8 *pcmd, uint8 * os_memcpy(lwip_host_name[1], pvar, len); } netbios_set_name(WLAN_AP_NETIF_NUM, lwip_host_name[1]); + if(wifi_cfg.save_flg & BID_AP_HOSTNAME) { + WEB_SRV_QFNK x; + x.fnk = write_wifi_cfg; + x.param = BID_AP_HOSTNAME; + xQueueSendToBack(xQueueWebSrv, &x, 0); + } } #endif else ifcmp("dhcp") wifi_ap_dhcp.mode = val; @@ -287,6 +301,12 @@ void ICACHE_FLASH_ATTR web_int_vars(TCP_SERV_CONN *ts_conn, uint8 *pcmd, uint8 * os_memcpy(lwip_host_name[0], pvar, len); netbios_set_name(WLAN_ST_NETIF_NUM, lwip_host_name[0]); } + if(wifi_cfg.save_flg & BID_ST_HOSTNAME) { + WEB_SRV_QFNK x; + x.fnk = write_wifi_cfg; + x.param = BID_ST_HOSTNAME; + xQueueSendToBack(xQueueWebSrv, &x, 0); + } } #endif else ifcmp("dhcp") wifi_st_dhcp.mode = val; diff --git a/project/src/web/web_srv.c b/project/src/web/web_srv.c index 373cbac..53b8ca9 100644 --- a/project/src/web/web_srv.c +++ b/project/src/web/web_srv.c @@ -442,7 +442,10 @@ web_parse_fname(HTTP_CONN *CurHTTP, TCP_SERV_CONN *ts_conn) if(pcmp != NULL) { WEB_SRV_CONN *web_conn = (WEB_SRV_CONN *)ts_conn->linkd; #if USE_WEB_AUTH_LEVEL - web_conn->auth_realm = WEB_AUTH_LEVEL_USER; + pcmp += sizeof(ProtectedFilesName) - 1; + web_conn->auth_realm = atoi(pcmp) + 1; + printf("[%s] ar%d ", pcmp, web_conn->auth_realm); +// web_conn->auth_realm = WEB_AUTH_LEVEL_USER; #endif SetSCB(SCB_AUTH); } @@ -846,6 +849,10 @@ LOCAL bool ICACHE_FLASH_ATTR webserver_open_file(HTTP_CONN *CurHTTP, TCP_SERV_CO if(rom_xstrcmp(pstr, web_cgi_fname)) { web_inc_fp(web_conn, WEBFS_WEBCGI_HANDLE); web_conn->content_len = sizeHTTPdefault; +#if USE_WEB_AUTH_LEVEL +// web_conn->auth_realm = WEB_AUTH_LEVEL_USER; +// SetSCB(SCB_AUTH); +#endif CurHTTP->fileType = HTTP_HTML; #if DEBUGSOO > 1 os_printf("of%d[%s] ", web_conn->webfile, CurHTTP->pFilename);