fixed many bugs

work
Ondřej Hruška 7 years ago
parent 1ab4101ac0
commit 9700465927
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 2
      front-end
  2. 7
      user/cgi_term_cfg.c
  3. 6
      user/config_xmacros.c
  4. 14
      user/config_xmacros.h
  5. 22
      user/screen.c
  6. 26
      user/screen.h
  7. 2
      user/syscfg.c
  8. 6
      user/syscfg.h
  9. 12
      user/wifimgr.c
  10. 12
      user/wifimgr.h

@ -1 +1 @@
Subproject commit 560f5783bc0eb5bf845a55cc30a3928f1d01b85f
Subproject commit 8327ff010893935c0c517c729727464f66badd89

@ -123,6 +123,13 @@ tplTermCfg(HttpdConnData *connData, char *token, void **arg)
#define X XGET_CGI_FUNC
XTABLE_TERMCONF
#undef X
#undef XSTRUCT
// for uart
#define XSTRUCT sysconf
#define X XGET_CGI_FUNC
XTABLE_SYSCONF
#undef X
#undef XSTRUCT
tplSend(connData, buff, -1);

@ -107,7 +107,7 @@ xset_u16(const char *name, u16 *field, const char *buff, const void *arg)
}
enum xset_result ICACHE_FLASH_ATTR
xset_string(const char *name, s8 **field, const char *buff, const void *arg)
xset_string(const char *name, char *field, const char *buff, const void *arg)
{
cgi_dbg("Setting %s = %s", name, buff);
u32 maxlen = (u32) arg;
@ -126,7 +126,7 @@ xset_string(const char *name, s8 **field, const char *buff, const void *arg)
enum xset_result ICACHE_FLASH_ATTR
xset_ustring(const char *name, u8 **field, const char *buff, const void *arg)
xset_ustring(const char *name, uchar *field, const char *buff, const void *arg)
{
cgi_dbg("Setting %s = %s", name, buff);
u32 maxlen = (u32) arg;
@ -136,7 +136,7 @@ xset_ustring(const char *name, u8 **field, const char *buff, const void *arg)
return XSET_FAIL;
}
if (!streq((char *)field, buff)) {
if (!streq(field, buff)) {
strncpy_safe(field, buff, (u32)arg);
return XSET_SET;
}

@ -8,6 +8,8 @@
#include <esp8266.h>
#include <helpers.h>
typedef unsigned char uchar;
#define XJOIN(a, b) a##b
/**Do nothing xnotify */
@ -63,11 +65,10 @@ enum xset_result xset_u8(const char *name, u8 *field, const char *buff, const vo
enum xset_result xset_u32(const char *name, u32 *field, const char *buff, const void *arg);
enum xset_result xset_u16(const char *name, u16 *field, const char *buff, const void *arg);
/**
* @param arg - max string length
*/
enum xset_result xset_string(const char *name, s8 **field, const char *buff, const void *arg);
enum xset_result xset_ustring(const char *name, u8 **field, const char *buff, const void *arg);
// static string arrays are not &'d, so we don't get **
/** @param arg - max string length */
enum xset_result xset_string(const char *name, char *field, const char *buff, const void *arg);
enum xset_result xset_ustring(const char *name, u8 *field, const char *buff, const void *arg);
/**
* Helper template macro for CGI functions that load GET args to structs using XTABLE
@ -77,7 +78,8 @@ enum xset_result xset_ustring(const char *name, u8 **field, const char *buff, co
*/
#define XSET_CGI_FUNC(type, name, suffix, deref, xget, cast, xset, xsarg, xnotify, allow) \
if ((allow) && GET_ARG(#name)) { \
enum xset_result res = xset(#name, cast &XSTRUCT->name, buff, (const void*) (xsarg)); \
type *_p = (type *) &XSTRUCT->name; \
enum xset_result res = xset(#name, cast _p, buff, (const void*) (xsarg)); \
if (res == XSET_SET) { xnotify; } \
else if (res == XSET_FAIL) { redir_url += sprintf(redir_url, #name","); } \
}

@ -214,22 +214,22 @@ xget_term_color(char *buff, u32 value)
void ICACHE_FLASH_ATTR
xget_term_bm(char *buff, char *value)
{
u8 c;
char c;
char *bp = buff;
char *cp = value;
int n = 0;
while((c = (u8) *cp++) != 0) {
while((c = *cp++) != 0) {
if(n>0) {
*bp = ',';
bp++;
}
bp += sprintf(bp, "%d", c);
bp += sprintf(bp, "%d", (u8)c);
n++;
}
}
enum xset_result ICACHE_FLASH_ATTR
xset_term_bm(const char *name, s8 **field, const char *buff, const void *arg)
xset_term_bm(const char *name, char *field, const char *buff, const void *arg)
{
cgi_dbg("Setting %s = %s", name, buff);
@ -279,8 +279,8 @@ xset_term_bm(const char *name, s8 **field, const char *buff, const void *arg)
buff_bm[char_i] = 0;
cgi_dbg("%s, chari = %d", buff_bm, char_i);
if (!streq(*field, buff_bm)) {
strncpy((char*)*field, buff_bm, TERM_BTN_MSG_LEN);
if (!streq(field, buff_bm)) {
strncpy(field, buff_bm, TERM_BTN_MSG_LEN);
return XSET_SET;
}
return XSET_UNCHANGED;
@ -361,11 +361,11 @@ terminal_restore_defaults(void)
strcpy(termconf->btn4, "4");
strcpy(termconf->btn5, "5");
strcpy(termconf->bm1, "\x01");
strcpy(termconf->bm2, "\x02");
strcpy(termconf->bm3, "\x03");
strcpy(termconf->bm4, "\x04");
strcpy(termconf->bm5, "\x05");
strcpy((char*)termconf->bm1, "\x01");
strcpy((char*)termconf->bm2, "\x02");
strcpy((char*)termconf->bm3, "\x03");
strcpy((char*)termconf->bm4, "\x04");
strcpy((char*)termconf->bm5, "\x05");
termconf->theme = 0;
termconf->parser_tout_ms = SCR_DEF_PARSER_TOUT_MS;

@ -86,12 +86,12 @@ enum CursorShape {
X(u32, height, /**/, /**/, xget_dec, /**/, xset_u32, NULL, /**/, 1) \
X(u32, default_bg, /**/, /**/, xget_term_color, /**/, xset_term_color, NULL, /**/, 1) \
X(u32, default_fg, /**/, /**/, xget_term_color, /**/, xset_term_color, NULL, /**/, 1) \
X(char, title, [TERM_TITLE_LEN], /**/, xget_string, (s8**), xset_string, TERM_TITLE_LEN, /**/, 1) \
X(char, btn1, [TERM_BTN_LEN], /**/, xget_string, (s8**), xset_string, TERM_BTN_LEN, /**/, 1) \
X(char, btn2, [TERM_BTN_LEN], /**/, xget_string, (s8**), xset_string, TERM_BTN_LEN, /**/, 1) \
X(char, btn3, [TERM_BTN_LEN], /**/, xget_string, (s8**), xset_string, TERM_BTN_LEN, /**/, 1) \
X(char, btn4, [TERM_BTN_LEN], /**/, xget_string, (s8**), xset_string, TERM_BTN_LEN, /**/, 1) \
X(char, btn5, [TERM_BTN_LEN], /**/, xget_string, (s8**), xset_string, TERM_BTN_LEN, /**/, 1) \
X(char, title, [TERM_TITLE_LEN], /**/, xget_string, /**/, xset_string, TERM_TITLE_LEN, /**/, 1) \
X(char, btn1, [TERM_BTN_LEN], /**/, xget_string, /**/, xset_string, TERM_BTN_LEN, /**/, 1) \
X(char, btn2, [TERM_BTN_LEN], /**/, xget_string, /**/, xset_string, TERM_BTN_LEN, /**/, 1) \
X(char, btn3, [TERM_BTN_LEN], /**/, xget_string, /**/, xset_string, TERM_BTN_LEN, /**/, 1) \
X(char, btn4, [TERM_BTN_LEN], /**/, xget_string, /**/, xset_string, TERM_BTN_LEN, /**/, 1) \
X(char, btn5, [TERM_BTN_LEN], /**/, xget_string, /**/, xset_string, TERM_BTN_LEN, /**/, 1) \
X(u8, theme, /**/, /**/, xget_dec, /**/, xset_u8, NULL, /**/, 1) \
X(u32, parser_tout_ms, /**/, /**/, xget_dec, /**/, xset_u32, NULL, /**/, 1) \
X(u32, display_tout_ms, /**/, /**/, xget_dec, /**/, xset_u32, NULL, /**/, 1) \
@ -101,18 +101,18 @@ enum CursorShape {
X(bool, loopback, /**/, /**/, xget_bool, /**/, xset_bool, NULL, /**/, 1) \
X(bool, show_buttons, /**/, /**/, xget_bool, /**/, xset_bool, NULL, /**/, 1) \
X(bool, show_config_links, /**/, /**/, xget_bool, /**/, xset_bool, NULL, /**/, 1) \
X(char, bm1, [TERM_BTN_MSG_LEN], /**/, xget_term_bm, (s8**), xset_term_bm, NULL, /**/, 1) \
X(char, bm2, [TERM_BTN_MSG_LEN], /**/, xget_term_bm, (s8**), xset_term_bm, NULL, /**/, 1) \
X(char, bm3, [TERM_BTN_MSG_LEN], /**/, xget_term_bm, (s8**), xset_term_bm, NULL, /**/, 1) \
X(char, bm4, [TERM_BTN_MSG_LEN], /**/, xget_term_bm, (s8**), xset_term_bm, NULL, /**/, 1) \
X(char, bm5, [TERM_BTN_MSG_LEN], /**/, xget_term_bm, (s8**), xset_term_bm, NULL, /**/, 1) \
X(char, bm1, [TERM_BTN_MSG_LEN], /**/, xget_term_bm, /**/, xset_term_bm, NULL, /**/, 1) \
X(char, bm2, [TERM_BTN_MSG_LEN], /**/, xget_term_bm, /**/, xset_term_bm, NULL, /**/, 1) \
X(char, bm3, [TERM_BTN_MSG_LEN], /**/, xget_term_bm, /**/, xset_term_bm, NULL, /**/, 1) \
X(char, bm4, [TERM_BTN_MSG_LEN], /**/, xget_term_bm, /**/, xset_term_bm, NULL, /**/, 1) \
X(char, bm5, [TERM_BTN_MSG_LEN], /**/, xget_term_bm, /**/, xset_term_bm, NULL, /**/, 1) \
X(u32, cursor_shape, /**/, /**/, xget_dec, /**/, xset_term_cursorshape, NULL, /**/, 1) \
X(bool, crlf_mode, /**/, /**/, xget_bool, /**/, xset_bool, NULL, /**/, 1) \
X(bool, want_all_fn, /**/, /**/, xget_bool, /**/, xset_bool, NULL, /**/, 1) \
X(bool, debugbar, /**/, /**/, xget_bool, /**/, xset_bool, NULL, /**/, 1) \
X(bool, allow_decopt_12, /**/, /**/, xget_bool, /**/, xset_bool, NULL, /**/, 1) \
X(bool, ascii_debug, /**/, /**/, xget_bool, /**/, xset_bool, NULL, /**/, 1) \
X(char, backdrop, [TERM_BACKDROP_LEN], /**/, xget_string, (s8**), xset_string, TERM_BACKDROP_LEN, /**/, 1)
X(char, backdrop, [TERM_BACKDROP_LEN], /**/, xget_string, /**/, xset_string, TERM_BACKDROP_LEN, /**/, 1)
#define TERM_BM_N(tc, n) ((tc)->bm1+(TERM_BTN_MSG_LEN*n))
#define TERM_BTN_N(tc, n) ((tc)->btn1+(TERM_BTN_LEN*n))
@ -122,7 +122,7 @@ void xget_term_color(char *buff, u32 value);
/** Export button message as stirng for config */
void xget_term_bm(char *buff, char *value);
/** Set button message */
enum xset_result xset_term_bm(const char *name, s8 **field, const char *buff, const void *arg);
enum xset_result xset_term_bm(const char *name, char *field, const char *buff, const void *arg);
/** Set color */
enum xset_result xset_term_color(const char *name, u32 *field, const char *buff, const void *arg);
/** Set cursor shape */

@ -95,7 +95,7 @@ xset_sys_pwlock(const char *name, u8 *field, const char *buff, const void *arg)
}
enum xset_result ICACHE_FLASH_ATTR
xset_sys_accesspw(const char *name, u8 **field, const char *buff, const void *arg)
xset_sys_accesspw(const char *name, uchar *field, const char *buff, const void *arg)
{
// Do not overwrite pw if empty
if (strlen(buff) == 0) return XSET_UNCHANGED;

@ -35,8 +35,8 @@ enum pwlock {
X(u8, config_version, /**/, /**/, xget_dec, /**/, xset_u8, NULL, /**/, 1) \
\
X(u8, pwlock, /**/, /**/, xget_dec, /**/, xset_sys_pwlock, NULL, /**/, admin|tpl) \
X(u8, access_pw, [64], /**/, xget_ustring, (u8**), xset_sys_accesspw, NULL, /**/, admin) \
X(u8, access_name, [32], /**/, xget_ustring, (u8**), xset_ustring, NULL, /**/, admin|tpl) \
X(uchar, access_pw, [64], /**/, xget_ustring, /**/, xset_sys_accesspw, NULL, /**/, admin) \
X(uchar, access_name, [32], /**/, xget_ustring, /**/, xset_ustring, NULL, /**/, admin|tpl) \
\
X(bool, overclock, /**/, /**/, xget_bool, /**/, xset_bool, NULL, /**/, 1) \
@ -66,6 +66,6 @@ enum xset_result xset_sys_baudrate(const char *name, u32 *field, const char *buf
enum xset_result xset_sys_parity(const char *name, u8 *field, const char *buff, const void *arg);
enum xset_result xset_sys_stopbits(const char *name, u8 *field, const char *buff, const void *arg);
enum xset_result xset_sys_pwlock(const char *name, u8 *field, const char *buff, const void *arg);
enum xset_result xset_sys_accesspw(const char *name, u8 **field, const char *buff, const void *arg);
enum xset_result xset_sys_accesspw(const char *name, uchar *field, const char *buff, const void *arg);
#endif //ESP_VT100_FIRMWARE_SYSCFG_H

@ -79,7 +79,7 @@ xset_wifi_ap_channel(const char *name, u8 *field, const char *buff, const void *
}
enum xset_result ICACHE_FLASH_ATTR
xset_wifi_ssid(const char *name, u8 **field, const char *buff, const void *arg)
xset_wifi_ssid(const char *name, uchar *field, const char *buff, const void *arg)
{
u8 buff2[SSID_LEN];
@ -96,8 +96,8 @@ xset_wifi_ssid(const char *name, u8 **field, const char *buff, const void *arg)
cgi_dbg("Setting %s = %s", name, buff);
if (strlen((char *)buff2) > 0) {
if (!streq(*field, buff2)) {
strncpy_safe(*field, buff2, SSID_LEN);
if (!streq(field, buff2)) {
strncpy_safe(field, buff2, SSID_LEN);
return XSET_SET;
}
return XSET_UNCHANGED;
@ -109,12 +109,12 @@ xset_wifi_ssid(const char *name, u8 **field, const char *buff, const void *arg)
/** Set PW - allow len 0 or 8-64 */
enum xset_result ICACHE_FLASH_ATTR
xset_wifi_pwd(const char *name, u8 **field, const char *buff, const void *arg)
xset_wifi_pwd(const char *name, uchar *field, const char *buff, const void *arg)
{
cgi_dbg("Setting %s = %s", name, buff);
if (strlen(buff) == 0 || (strlen(buff) >= 8 && strlen(buff) < PASSWORD_LEN-1)) {
if (!streq(*field, buff)) {
strncpy_safe(*field, buff, PASSWORD_LEN);
if (!streq(field, buff)) {
strncpy_safe(field, buff, PASSWORD_LEN);
return XSET_SET;
}
return XSET_UNCHANGED;

@ -30,8 +30,8 @@
\
X(u8, tpw, /**/, /**/, xget_dec, /**/, xset_wifi_tpw, NULL, wifimgr_notify_ap(), 1) \
X(u8, ap_channel, /**/, /**/, xget_dec, /**/, xset_wifi_ap_channel, NULL, wifimgr_notify_ap(), 1) \
X(u8, ap_ssid, [SSID_LEN], /**/, xget_ustring, (u8**), xset_wifi_ssid, 1, wifimgr_notify_ap(), 1) \
X(u8, ap_password, [PASSWORD_LEN], /**/, xget_ustring, (u8**), xset_wifi_pwd, NULL, wifimgr_notify_ap(), 1) \
X(u8, ap_ssid, [SSID_LEN], /**/, xget_ustring, /**/, xset_wifi_ssid, 1, wifimgr_notify_ap(), 1) \
X(u8, ap_password, [PASSWORD_LEN], /**/, xget_ustring, /**/, xset_wifi_pwd, NULL, wifimgr_notify_ap(), 1) \
X(bool, ap_hidden, /**/, /**/, xget_bool, /**/, xset_bool, NULL, wifimgr_notify_ap(), 1) \
\
X(u16, ap_dhcp_time, /**/, /**/, xget_dec, /**/, xset_wifi_lease_time, NULL, wifimgr_notify_ap(), 1) \
@ -44,8 +44,8 @@
\
\
X(u32, unused2, /**/, /**/, xget_dummy, /**/, xset_dummy, NULL, /**/, 0) \
X(u8, sta_ssid, [SSID_LEN], /**/, xget_ustring, (u8**), xset_wifi_ssid, 0, wifimgr_notify_sta(), 1) \
X(u8, sta_password, [PASSWORD_LEN], /**/, xget_ustring, (u8**), xset_wifi_pwd, NULL, wifimgr_notify_sta(), 1) \
X(u8, sta_ssid, [SSID_LEN], /**/, xget_ustring, /**/, xset_wifi_ssid, 0, wifimgr_notify_sta(), 1) \
X(u8, sta_password, [PASSWORD_LEN], /**/, xget_ustring, /**/, xset_wifi_pwd, NULL, wifimgr_notify_sta(), 1) \
X(bool, sta_dhcp_enable, /**/, /**/, xget_bool, /**/, xset_bool, NULL, wifimgr_notify_sta(), 1) \
\
X(struct ip_addr, sta_addr_ip, /**/, &, xget_ip, /**/, xset_ip, NULL, wifimgr_notify_sta(), 1) \
@ -89,8 +89,8 @@ enum xset_result xset_wifi_lease_time(const char *name, u16 *field, const char *
enum xset_result xset_wifi_opmode(const char *name, u8 *field, const char *buff, const void *arg);
enum xset_result xset_wifi_tpw(const char *name, u8 *field, const char *buff, const void *arg);
enum xset_result xset_wifi_ap_channel(const char *name, u8 *field, const char *buff, const void *arg);
enum xset_result xset_wifi_ssid(const char *name, u8 **field, const char *buff, const void *arg);
enum xset_result xset_wifi_pwd(const char *name, u8 **field, const char *buff, const void *arg);
enum xset_result xset_wifi_ssid(const char *name, uchar *field, const char *buff, const void *arg);
enum xset_result xset_wifi_pwd(const char *name, uchar *field, const char *buff, const void *arg);
#if DEBUG_WIFI
#define wifi_warn warn

Loading…
Cancel
Save