Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12385b7a5f | ||
|
|
5564147f67 | ||
|
|
32ba7dc0d7 | ||
|
|
80721c1715 | ||
|
|
e22d3f26d9 |
@@ -65,7 +65,7 @@ LIBS += esphttpd
|
|||||||
# compiler flags using during compilation of source files
|
# compiler flags using during compilation of source files
|
||||||
CFLAGS = -Os -ggdb -std=gnu99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \
|
CFLAGS = -Os -ggdb -std=gnu99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \
|
||||||
-nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH \
|
-nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH \
|
||||||
-Wno-address -Wno-unused -DHTTPD_MAX_BACKLOG_SIZE=4096 -DADMIN_PASSWORD=$(ADMIN_PASSWORD) \
|
-Wno-address -Wno-unused -DHTTPD_MAX_BACKLOG_SIZE=8192 -DADMIN_PASSWORD=$(ADMIN_PASSWORD) \
|
||||||
-DGIT_HASH='"$(shell git rev-parse --short HEAD)"'
|
-DGIT_HASH='"$(shell git rev-parse --short HEAD)"'
|
||||||
|
|
||||||
# linker flags used to generate the main object file
|
# linker flags used to generate the main object file
|
||||||
|
|||||||
+17
-2
@@ -16,6 +16,11 @@ return [
|
|||||||
|
|
||||||
'title.term' => 'Terminal',
|
'title.term' => 'Terminal',
|
||||||
|
|
||||||
|
'term_nav.config' => 'Config',
|
||||||
|
'term_nav.wifi' => 'WiFi',
|
||||||
|
'term_nav.help' => 'Help',
|
||||||
|
'term_nav.about' => 'About',
|
||||||
|
|
||||||
'net.ap' => 'DHCP Server (AP)',
|
'net.ap' => 'DHCP Server (AP)',
|
||||||
'net.sta' => 'DHCP Client (Station)',
|
'net.sta' => 'DHCP Client (Station)',
|
||||||
'net.sta_mac' => 'Station MAC',
|
'net.sta_mac' => 'Station MAC',
|
||||||
@@ -100,10 +105,20 @@ return [
|
|||||||
|
|
||||||
'wifi.conn.status' => 'Status:',
|
'wifi.conn.status' => 'Status:',
|
||||||
'wifi.conn.back_to_config' => 'Back to WiFi config',
|
'wifi.conn.back_to_config' => 'Back to WiFi config',
|
||||||
'wifi.conn.telemetry_lost' => 'Telemetry lost, something went wrong. Try again...',
|
'wifi.conn.telemetry_lost' => 'Telemetry lost; something went wrong, or your device disconnected.',
|
||||||
|
'wifi.conn.explain_android_sucks' => '
|
||||||
|
If you\'re configuring ESPTerm via a smartphone, or were connected
|
||||||
|
from another external network, your device may lose connection and this
|
||||||
|
progress indicator won\'t work. Please wait a while (~ 15 seconds),
|
||||||
|
then check if the connection succeeded.',
|
||||||
|
|
||||||
|
'wifi.conn.explain_reset' => '
|
||||||
|
To force enable the built-in AP, hold the BOOT
|
||||||
|
button until the blue LED starts flashing. Hold the button longer (until the LED
|
||||||
|
flashes rapidly) for a "factory reset".',
|
||||||
|
|
||||||
'wifi.conn.disabled' =>"Station mode is disabled.",
|
'wifi.conn.disabled' =>"Station mode is disabled.",
|
||||||
'wifi.conn.idle' =>"Idle, not connected and with no IP.",
|
'wifi.conn.idle' =>"Idle, not connected and has no IP.",
|
||||||
'wifi.conn.success' => "Connected! Received IP ",
|
'wifi.conn.success' => "Connected! Received IP ",
|
||||||
'wifi.conn.working' => "Connecting to selected AP",
|
'wifi.conn.working' => "Connecting to selected AP",
|
||||||
'wifi.conn.fail' => "Connection failed, check settings & try again. Cause: ",
|
'wifi.conn.fail' => "Connection failed, check settings & try again. Cause: ",
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form class="Box str mobcol" action="<?= e(url('wifi_set')) ?>" method="GET" id="form-2">
|
<form class="Box str mobcol expanded" action="<?= e(url('wifi_set')) ?>" method="GET" id="form-2">
|
||||||
<h2 tabindex=0><?= tr('wifi.sta') ?></h2>
|
<h2 tabindex=0><?= tr('wifi.sta') ?></h2>
|
||||||
|
|
||||||
<div class="Row checkbox x-sta-toggle">
|
<div class="Row checkbox x-sta-toggle">
|
||||||
|
|||||||
@@ -5,9 +5,15 @@
|
|||||||
<a href="<?= e(url('cfg_wifi')) ?>" id="backbtn" class="button"><?= tr('wifi.conn.back_to_config') ?></a>
|
<a href="<?= e(url('cfg_wifi')) ?>" id="backbtn" class="button"><?= tr('wifi.conn.back_to_config') ?></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="Box">
|
||||||
|
<p><?= tr('wifi.conn.explain_android_sucks') ?></p>
|
||||||
|
<p><?= tr('wifi.conn.explain_reset') ?></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
var abortTmeo;
|
var abortTmeo;
|
||||||
|
var failCounter = 0;
|
||||||
|
|
||||||
var messages = <?= json_encode([
|
var messages = <?= json_encode([
|
||||||
'disabled' => tr('wifi.conn.disabled'),
|
'disabled' => tr('wifi.conn.disabled'),
|
||||||
@@ -17,33 +23,63 @@
|
|||||||
'fail' => tr('wifi.conn.fail'),
|
'fail' => tr('wifi.conn.fail'),
|
||||||
]) ?>;
|
]) ?>;
|
||||||
|
|
||||||
|
function onFail() {
|
||||||
|
$("#status").html(<?= json_encode(tr('wifi.conn.telemetry_lost')) ?>);
|
||||||
|
$('.anim-dots').addClass('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
function getStatus() {
|
function getStatus() {
|
||||||
xhr.open("GET", 'http://'+_root+'<?= url('wifi_connstatus', true) ?>');
|
xhr.open("GET", 'http://'+_root+'<?= url('wifi_connstatus', true) ?>');
|
||||||
xhr.onreadystatechange = function () {
|
xhr.onreadystatechange = function () {
|
||||||
if (xhr.readyState == 4 && xhr.status >= 200 && xhr.status < 300) {
|
if (xhr.readyState == 4) {
|
||||||
clearTimeout(abortTmeo);
|
if (xhr.status == 200) {
|
||||||
var data = JSON.parse(xhr.responseText);
|
clearTimeout(abortTmeo);
|
||||||
var done = false;
|
|
||||||
var msg = messages[data.status] || '...';
|
|
||||||
if (data.status == 'success') msg += data.ip;
|
|
||||||
if (data.status == 'fail') msg += data.cause;
|
|
||||||
|
|
||||||
$("#status").html(msg);
|
try {
|
||||||
|
var data = JSON.parse(xhr.responseText);
|
||||||
|
var done = false;
|
||||||
|
var msg = messages[data.status] || '...';
|
||||||
|
|
||||||
if (done) {
|
if (data.status == 'success') {
|
||||||
// $('#backbtn').removeClass('hidden');
|
msg += data.ip;
|
||||||
$('.anim-dots').addClass('hidden');
|
done = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.status == 'fail') {
|
||||||
|
msg += data.cause;
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#status").html(msg);
|
||||||
|
|
||||||
|
if (done) {
|
||||||
|
// $('#backbtn').removeClass('hidden');
|
||||||
|
$('.anim-dots').addClass('hidden');
|
||||||
|
} else {
|
||||||
|
// ask again after a short delay
|
||||||
|
window.setTimeout(getStatus, 1000);
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
failCounter++;
|
||||||
|
console.log(e);
|
||||||
|
// repeat
|
||||||
|
if (failCounter > 5) {
|
||||||
|
onFail();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
window.setTimeout(getStatus, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
window.setTimeout(getStatus, 1000);
|
onFail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// XHR timeout
|
||||||
abortTmeo = setTimeout(function () {
|
abortTmeo = setTimeout(function () {
|
||||||
xhr.abort();
|
xhr.abort();
|
||||||
$("#status").html(<?= json_encode(tr('wifi.conn.telemetry_lost')) ?>);
|
onFail();
|
||||||
// $('#backbtn').removeClass('hidden');
|
|
||||||
$('.anim-dots').addClass('hidden');
|
|
||||||
}, 4000);
|
}, 4000);
|
||||||
|
|
||||||
xhr.send();
|
xhr.send();
|
||||||
|
|||||||
@@ -26,9 +26,10 @@
|
|||||||
|
|
||||||
<nav id="botnav">
|
<nav id="botnav">
|
||||||
<a href="#" onclick="toggleSoftKb(true); return false" class="icn-keyboard mq-tablet-max"></a><!--
|
<a href="#" onclick="toggleSoftKb(true); return false" class="icn-keyboard mq-tablet-max"></a><!--
|
||||||
--><a href="<?= url('cfg_term') ?>"><?= tr('menu.settings') ?></a><!--
|
--><a href="<?= url('cfg_term') ?>"><?= tr('term_nav.config') ?></a><!--
|
||||||
--><a href="<?= url('help') ?>">Help</a><!--
|
--><a href="<?= url('cfg_wifi') ?>"><?= tr('term_nav.wifi') ?></a><!--
|
||||||
--><a href="<?= url('about') ?>">About</a>
|
--><a href="<?= url('help') ?>"><?= tr('term_nav.help') ?></a><!--
|
||||||
|
--><a href="<?= url('about') ?>"><?= tr('term_nav.about') ?></a>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@
|
|||||||
/**
|
/**
|
||||||
* Helper that retrieves an arg from `connData->getArgs` and stores it in `buff`. Returns 1 on success
|
* Helper that retrieves an arg from `connData->getArgs` and stores it in `buff`. Returns 1 on success
|
||||||
*/
|
*/
|
||||||
#define GET_ARG(key) (httpdFindArg(connData->getArgs, key, buff, sizeof(buff)) > 0)
|
#define GET_ARG(key) (httpdFindArg(connData->getArgs, key, buff, sizeof(buff)) >= 0)
|
||||||
|
|
||||||
#define STR_HELPER(x) #x
|
#define STR_HELPER(x) #x
|
||||||
#define STR(x) STR_HELPER(x)
|
#define STR(x) STR_HELPER(x)
|
||||||
|
|||||||
+65
-73
@@ -19,11 +19,11 @@ static const char _ansi_eof_actions[] = {
|
|||||||
0, 13, 13, 13, 13, 13, 13, 13,
|
0, 13, 13, 13, 13, 13, 13, 13,
|
||||||
13, 13, 13, 13, 13, 13, 13, 13,
|
13, 13, 13, 13, 13, 13, 13, 13,
|
||||||
13, 13, 13, 13, 13, 13, 13, 13,
|
13, 13, 13, 13, 13, 13, 13, 13,
|
||||||
13, 13, 0, 0, 0, 0, 0
|
0, 0, 0, 0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int ansi_start = 1;
|
static const int ansi_start = 1;
|
||||||
static const int ansi_first_final = 26;
|
static const int ansi_first_final = 24;
|
||||||
static const int ansi_error = 0;
|
static const int ansi_error = 0;
|
||||||
|
|
||||||
static const int ansi_en_CSI_body = 3;
|
static const int ansi_en_CSI_body = 3;
|
||||||
@@ -123,7 +123,7 @@ case 2:
|
|||||||
goto tr2;
|
goto tr2;
|
||||||
case 0:
|
case 0:
|
||||||
goto _out;
|
goto _out;
|
||||||
case 26:
|
case 24:
|
||||||
if ( (*p) == 27 )
|
if ( (*p) == 27 )
|
||||||
goto tr1;
|
goto tr1;
|
||||||
goto tr0;
|
goto tr0;
|
||||||
@@ -157,7 +157,7 @@ case 4:
|
|||||||
} else
|
} else
|
||||||
goto tr11;
|
goto tr11;
|
||||||
goto tr2;
|
goto tr2;
|
||||||
case 27:
|
case 25:
|
||||||
goto tr2;
|
goto tr2;
|
||||||
case 5:
|
case 5:
|
||||||
switch( (*p) ) {
|
switch( (*p) ) {
|
||||||
@@ -183,82 +183,74 @@ case 9:
|
|||||||
goto tr18;
|
goto tr18;
|
||||||
goto tr2;
|
goto tr2;
|
||||||
case 10:
|
case 10:
|
||||||
if ( (*p) == 27 )
|
switch( (*p) ) {
|
||||||
goto tr2;
|
case 7: goto tr20;
|
||||||
|
case 27: goto tr21;
|
||||||
|
}
|
||||||
|
goto tr19;
|
||||||
|
case 26:
|
||||||
|
switch( (*p) ) {
|
||||||
|
case 7: goto tr20;
|
||||||
|
case 27: goto tr21;
|
||||||
|
}
|
||||||
goto tr19;
|
goto tr19;
|
||||||
case 11:
|
case 11:
|
||||||
switch( (*p) ) {
|
|
||||||
case 7: goto tr20;
|
|
||||||
case 27: goto tr21;
|
|
||||||
}
|
|
||||||
goto tr19;
|
|
||||||
case 28:
|
|
||||||
switch( (*p) ) {
|
|
||||||
case 7: goto tr20;
|
|
||||||
case 27: goto tr21;
|
|
||||||
}
|
|
||||||
goto tr19;
|
|
||||||
case 12:
|
|
||||||
if ( (*p) == 92 )
|
if ( (*p) == 92 )
|
||||||
goto tr22;
|
goto tr22;
|
||||||
goto tr2;
|
goto tr2;
|
||||||
case 29:
|
case 27:
|
||||||
goto tr2;
|
goto tr2;
|
||||||
case 13:
|
case 12:
|
||||||
if ( (*p) == 73 )
|
if ( (*p) == 73 )
|
||||||
goto tr23;
|
goto tr23;
|
||||||
goto tr2;
|
goto tr2;
|
||||||
case 14:
|
case 13:
|
||||||
if ( (*p) == 84 )
|
if ( (*p) == 84 )
|
||||||
goto tr24;
|
goto tr24;
|
||||||
goto tr2;
|
goto tr2;
|
||||||
case 15:
|
case 14:
|
||||||
if ( (*p) == 76 )
|
if ( (*p) == 76 )
|
||||||
goto tr25;
|
goto tr25;
|
||||||
goto tr2;
|
goto tr2;
|
||||||
case 16:
|
case 15:
|
||||||
if ( (*p) == 69 )
|
if ( (*p) == 69 )
|
||||||
goto tr26;
|
goto tr26;
|
||||||
goto tr2;
|
goto tr2;
|
||||||
case 17:
|
case 16:
|
||||||
if ( (*p) == 61 )
|
if ( (*p) == 61 )
|
||||||
goto tr27;
|
goto tr27;
|
||||||
goto tr2;
|
goto tr2;
|
||||||
|
case 17:
|
||||||
|
switch( (*p) ) {
|
||||||
|
case 7: goto tr29;
|
||||||
|
case 27: goto tr30;
|
||||||
|
}
|
||||||
|
goto tr28;
|
||||||
|
case 28:
|
||||||
|
switch( (*p) ) {
|
||||||
|
case 7: goto tr29;
|
||||||
|
case 27: goto tr30;
|
||||||
|
}
|
||||||
|
goto tr28;
|
||||||
case 18:
|
case 18:
|
||||||
if ( (*p) == 27 )
|
|
||||||
goto tr2;
|
|
||||||
goto tr28;
|
|
||||||
case 19:
|
|
||||||
switch( (*p) ) {
|
|
||||||
case 7: goto tr29;
|
|
||||||
case 27: goto tr30;
|
|
||||||
}
|
|
||||||
goto tr28;
|
|
||||||
case 30:
|
|
||||||
switch( (*p) ) {
|
|
||||||
case 7: goto tr29;
|
|
||||||
case 27: goto tr30;
|
|
||||||
}
|
|
||||||
goto tr28;
|
|
||||||
case 20:
|
|
||||||
if ( (*p) == 92 )
|
if ( (*p) == 92 )
|
||||||
goto tr31;
|
goto tr31;
|
||||||
goto tr2;
|
goto tr2;
|
||||||
case 21:
|
case 19:
|
||||||
if ( 48 <= (*p) && (*p) <= 57 )
|
if ( 48 <= (*p) && (*p) <= 57 )
|
||||||
goto tr32;
|
goto tr32;
|
||||||
goto tr2;
|
goto tr2;
|
||||||
case 22:
|
case 20:
|
||||||
if ( (*p) == 59 )
|
if ( (*p) == 59 )
|
||||||
goto tr33;
|
goto tr33;
|
||||||
if ( 48 <= (*p) && (*p) <= 57 )
|
if ( 48 <= (*p) && (*p) <= 57 )
|
||||||
goto tr32;
|
goto tr32;
|
||||||
goto tr2;
|
goto tr2;
|
||||||
case 23:
|
case 21:
|
||||||
if ( 48 <= (*p) && (*p) <= 57 )
|
if ( 48 <= (*p) && (*p) <= 57 )
|
||||||
goto tr34;
|
goto tr34;
|
||||||
goto tr2;
|
goto tr2;
|
||||||
case 24:
|
case 22:
|
||||||
switch( (*p) ) {
|
switch( (*p) ) {
|
||||||
case 7: goto tr35;
|
case 7: goto tr35;
|
||||||
case 27: goto tr36;
|
case 27: goto tr36;
|
||||||
@@ -266,7 +258,7 @@ case 24:
|
|||||||
if ( 48 <= (*p) && (*p) <= 57 )
|
if ( 48 <= (*p) && (*p) <= 57 )
|
||||||
goto tr34;
|
goto tr34;
|
||||||
goto tr2;
|
goto tr2;
|
||||||
case 25:
|
case 23:
|
||||||
if ( (*p) == 92 )
|
if ( (*p) == 92 )
|
||||||
goto tr35;
|
goto tr35;
|
||||||
goto tr2;
|
goto tr2;
|
||||||
@@ -283,32 +275,32 @@ case 25:
|
|||||||
tr16: cs = 8; goto _again;
|
tr16: cs = 8; goto _again;
|
||||||
tr17: cs = 9; goto f8;
|
tr17: cs = 9; goto f8;
|
||||||
tr18: cs = 10; goto _again;
|
tr18: cs = 10; goto _again;
|
||||||
tr19: cs = 11; goto f11;
|
tr19: cs = 10; goto f11;
|
||||||
tr21: cs = 12; goto _again;
|
tr21: cs = 11; goto _again;
|
||||||
tr13: cs = 13; goto _again;
|
tr13: cs = 12; goto _again;
|
||||||
tr23: cs = 14; goto _again;
|
tr23: cs = 13; goto _again;
|
||||||
tr24: cs = 15; goto _again;
|
tr24: cs = 14; goto _again;
|
||||||
tr25: cs = 16; goto _again;
|
tr25: cs = 15; goto _again;
|
||||||
tr26: cs = 17; goto _again;
|
tr26: cs = 16; goto _again;
|
||||||
tr27: cs = 18; goto _again;
|
tr27: cs = 17; goto _again;
|
||||||
tr28: cs = 19; goto f11;
|
tr28: cs = 17; goto f11;
|
||||||
tr30: cs = 20; goto _again;
|
tr30: cs = 18; goto _again;
|
||||||
tr14: cs = 21; goto _again;
|
tr14: cs = 19; goto _again;
|
||||||
tr32: cs = 22; goto f8;
|
tr32: cs = 20; goto f8;
|
||||||
tr33: cs = 23; goto f9;
|
tr33: cs = 21; goto f9;
|
||||||
tr34: cs = 24; goto f8;
|
tr34: cs = 22; goto f8;
|
||||||
tr36: cs = 25; goto _again;
|
tr36: cs = 23; goto _again;
|
||||||
tr3: cs = 26; goto f2;
|
tr3: cs = 24; goto f2;
|
||||||
tr4: cs = 26; goto f3;
|
tr4: cs = 24; goto f3;
|
||||||
tr5: cs = 26; goto f4;
|
tr5: cs = 24; goto f4;
|
||||||
tr6: cs = 26; goto f5;
|
tr6: cs = 24; goto f5;
|
||||||
tr7: cs = 26; goto f6;
|
tr7: cs = 24; goto f6;
|
||||||
tr11: cs = 27; goto f10;
|
tr11: cs = 25; goto f10;
|
||||||
tr20: cs = 28; goto f12;
|
tr20: cs = 26; goto f12;
|
||||||
tr22: cs = 29; goto f13;
|
tr22: cs = 27; goto f13;
|
||||||
tr31: cs = 29; goto f15;
|
tr31: cs = 27; goto f15;
|
||||||
tr35: cs = 29; goto f16;
|
tr35: cs = 27; goto f16;
|
||||||
tr29: cs = 30; goto f14;
|
tr29: cs = 28; goto f14;
|
||||||
|
|
||||||
f1: _acts = _ansi_actions + 1; goto execFuncs;
|
f1: _acts = _ansi_actions + 1; goto execFuncs;
|
||||||
f4: _acts = _ansi_actions + 3; goto execFuncs;
|
f4: _acts = _ansi_actions + 3; goto execFuncs;
|
||||||
@@ -458,7 +450,7 @@ execFuncs:
|
|||||||
{cs = 1;goto _again;}
|
{cs = 1;goto _again;}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/* #line 462 "user/ansi_parser.c" */
|
/* #line 454 "user/ansi_parser.c" */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goto _again;
|
goto _again;
|
||||||
@@ -484,7 +476,7 @@ _again:
|
|||||||
goto _again;}
|
goto _again;}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/* #line 488 "user/ansi_parser.c" */
|
/* #line 480 "user/ansi_parser.c" */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -169,8 +169,8 @@ ansi_parser(const char *newdata, size_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
OSC_body := (
|
OSC_body := (
|
||||||
("BTN" digit @CSI_digit '=' (NOESC @OSC_text_char)+ OSC_END @OSC_button) |
|
("BTN" digit @CSI_digit '=' (NOESC @OSC_text_char)* OSC_END @OSC_button) |
|
||||||
("TITLE=" (NOESC @OSC_text_char)+ OSC_END @OSC_title) |
|
("TITLE=" (NOESC @OSC_text_char)* OSC_END @OSC_title) |
|
||||||
('W' (digit @CSI_digit)+ ';' @CSI_semi (digit @CSI_digit)+ OSC_END @OSC_resize)
|
('W' (digit @CSI_digit)+ ';' @CSI_semi (digit @CSI_digit)+ OSC_END @OSC_resize)
|
||||||
) $!errBadSeq;
|
) $!errBadSeq;
|
||||||
|
|
||||||
|
|||||||
+21
-5
@@ -22,6 +22,8 @@ cgiTermCfgSetParams(HttpdConnData *connData)
|
|||||||
char redir_url_buf[100];
|
char redir_url_buf[100];
|
||||||
int n, w, h;
|
int n, w, h;
|
||||||
|
|
||||||
|
bool shall_clear_screen = false;
|
||||||
|
|
||||||
char *redir_url = redir_url_buf;
|
char *redir_url = redir_url_buf;
|
||||||
redir_url += sprintf(redir_url, SET_REDIR_ERR);
|
redir_url += sprintf(redir_url, SET_REDIR_ERR);
|
||||||
// we'll test if anything was printed by looking for \0 in failed_keys_buf
|
// we'll test if anything was printed by looking for \0 in failed_keys_buf
|
||||||
@@ -41,8 +43,11 @@ cgiTermCfgSetParams(HttpdConnData *connData)
|
|||||||
h = atoi(buff);
|
h = atoi(buff);
|
||||||
if (h > 1) {
|
if (h > 1) {
|
||||||
if (w * h <= MAX_SCREEN_SIZE) {
|
if (w * h <= MAX_SCREEN_SIZE) {
|
||||||
termconf->width = w;
|
if (termconf->width != w || termconf->height != h) {
|
||||||
termconf->height = h;
|
termconf->width = w;
|
||||||
|
termconf->height = h;
|
||||||
|
shall_clear_screen = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
warn("Bad dimensions: %d x %d (total %d)", w, h, w*h);
|
warn("Bad dimensions: %d x %d (total %d)", w, h, w*h);
|
||||||
redir_url += sprintf(redir_url, "term_width,term_height,");
|
redir_url += sprintf(redir_url, "term_width,term_height,");
|
||||||
@@ -66,7 +71,10 @@ cgiTermCfgSetParams(HttpdConnData *connData)
|
|||||||
dbg("Screen default BG: %s", buff);
|
dbg("Screen default BG: %s", buff);
|
||||||
n = atoi(buff);
|
n = atoi(buff);
|
||||||
if (n >= 0 && n < 16) {
|
if (n >= 0 && n < 16) {
|
||||||
termconf->default_bg = (u8) n;
|
if (termconf->default_bg != n) {
|
||||||
|
termconf->default_bg = (u8) n;
|
||||||
|
shall_clear_screen = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
warn("Bad color %s", buff);
|
warn("Bad color %s", buff);
|
||||||
redir_url += sprintf(redir_url, "default_bg,");
|
redir_url += sprintf(redir_url, "default_bg,");
|
||||||
@@ -88,7 +96,10 @@ cgiTermCfgSetParams(HttpdConnData *connData)
|
|||||||
dbg("Screen default FG: %s", buff);
|
dbg("Screen default FG: %s", buff);
|
||||||
n = atoi(buff);
|
n = atoi(buff);
|
||||||
if (n >= 0 && n < 16) {
|
if (n >= 0 && n < 16) {
|
||||||
termconf->default_fg = (u8) n;
|
if (termconf->default_fg != n) {
|
||||||
|
termconf->default_fg = (u8) n;
|
||||||
|
shall_clear_screen = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
warn("Bad color %s", buff);
|
warn("Bad color %s", buff);
|
||||||
redir_url += sprintf(redir_url, "default_fg,");
|
redir_url += sprintf(redir_url, "default_fg,");
|
||||||
@@ -123,9 +134,14 @@ cgiTermCfgSetParams(HttpdConnData *connData)
|
|||||||
// All was OK
|
// All was OK
|
||||||
info("Set term params - success, saving...");
|
info("Set term params - success, saving...");
|
||||||
|
|
||||||
terminal_apply_settings();
|
|
||||||
persist_store();
|
persist_store();
|
||||||
|
|
||||||
|
if (shall_clear_screen) {
|
||||||
|
terminal_apply_settings();
|
||||||
|
} else {
|
||||||
|
terminal_apply_settings_noclear();
|
||||||
|
}
|
||||||
|
|
||||||
httpdRedirect(connData, SET_REDIR_SUC);
|
httpdRedirect(connData, SET_REDIR_SUC);
|
||||||
} else {
|
} else {
|
||||||
warn("Some settings did not validate, asking for correction");
|
warn("Some settings did not validate, asking for correction");
|
||||||
|
|||||||
+40
-6
@@ -193,6 +193,11 @@ httpd_cgi_state ICACHE_FLASH_ATTR cgiWiFiScan(HttpdConnData *connData)
|
|||||||
int len;
|
int len;
|
||||||
char buff[256];
|
char buff[256];
|
||||||
|
|
||||||
|
if (connData->conn == NULL) {
|
||||||
|
//Connection aborted. Clean up.
|
||||||
|
return HTTPD_CGI_DONE;
|
||||||
|
}
|
||||||
|
|
||||||
// auto-turn on STA
|
// auto-turn on STA
|
||||||
if ((wificonf->opmode & STATION_MODE) == 0) {
|
if ((wificonf->opmode & STATION_MODE) == 0) {
|
||||||
wificonf->opmode |= STATION_MODE;
|
wificonf->opmode |= STATION_MODE;
|
||||||
@@ -265,6 +270,13 @@ httpd_cgi_state ICACHE_FLASH_ATTR cgiWiFiConnStatus(HttpdConnData *connData)
|
|||||||
char buff[100];
|
char buff[100];
|
||||||
struct ip_info info;
|
struct ip_info info;
|
||||||
|
|
||||||
|
buff[0] = 0; // avoid unitialized read
|
||||||
|
|
||||||
|
if (connData->conn == NULL) {
|
||||||
|
//Connection aborted. Clean up.
|
||||||
|
return HTTPD_CGI_DONE;
|
||||||
|
}
|
||||||
|
|
||||||
httpdStartResponse(connData, 200);
|
httpdStartResponse(connData, 200);
|
||||||
httpdHeader(connData, "Content-Type", "application/json");
|
httpdHeader(connData, "Content-Type", "application/json");
|
||||||
httpdEndHeaders(connData);
|
httpdEndHeaders(connData);
|
||||||
@@ -276,6 +288,7 @@ httpd_cgi_state ICACHE_FLASH_ATTR cgiWiFiConnStatus(HttpdConnData *connData)
|
|||||||
}
|
}
|
||||||
|
|
||||||
STATION_STATUS st = wifi_station_get_connect_status();
|
STATION_STATUS st = wifi_station_get_connect_status();
|
||||||
|
dbg("CONN STATE = %d", st);
|
||||||
switch(st) {
|
switch(st) {
|
||||||
case STATION_IDLE:
|
case STATION_IDLE:
|
||||||
sprintf(buff, "{\"status\": \"idle\"}"); // unclear when this is used
|
sprintf(buff, "{\"status\": \"idle\"}"); // unclear when this is used
|
||||||
@@ -301,9 +314,14 @@ httpd_cgi_state ICACHE_FLASH_ATTR cgiWiFiConnStatus(HttpdConnData *connData)
|
|||||||
wifi_get_ip_info(STATION_IF, &info);
|
wifi_get_ip_info(STATION_IF, &info);
|
||||||
sprintf(buff, "{\"status\": \"success\", \"ip\": \""IPSTR"\"}", GOOD_IP2STR(info.ip.addr));
|
sprintf(buff, "{\"status\": \"success\", \"ip\": \""IPSTR"\"}", GOOD_IP2STR(info.ip.addr));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
sprintf(buff, "{\"status\": \"working\", \"wtf\": \"state = %d\"}", st);
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tplSend(connData, buff, -1);
|
httpdSend(connData, buff, -1);
|
||||||
return HTTPD_CGI_DONE;
|
return HTTPD_CGI_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,6 +354,9 @@ httpd_cgi_state ICACHE_FLASH_ATTR cgiWiFiSetParams(HttpdConnData *connData)
|
|||||||
return HTTPD_CGI_DONE;
|
return HTTPD_CGI_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool sta_turned_on = false;
|
||||||
|
bool sta_ssid_pw_changed = false;
|
||||||
|
|
||||||
// ---- WiFi opmode ----
|
// ---- WiFi opmode ----
|
||||||
|
|
||||||
if (GET_ARG("opmode")) {
|
if (GET_ARG("opmode")) {
|
||||||
@@ -366,6 +387,7 @@ httpd_cgi_state ICACHE_FLASH_ATTR cgiWiFiSetParams(HttpdConnData *connData)
|
|||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
wificonf->opmode |= STATION_MODE;
|
wificonf->opmode |= STATION_MODE;
|
||||||
|
sta_turned_on = true;
|
||||||
} else {
|
} else {
|
||||||
wificonf->opmode &= ~STATION_MODE;
|
wificonf->opmode &= ~STATION_MODE;
|
||||||
}
|
}
|
||||||
@@ -463,6 +485,7 @@ httpd_cgi_state ICACHE_FLASH_ATTR cgiWiFiSetParams(HttpdConnData *connData)
|
|||||||
info("Setting station SSID to: \"%s\"", buff);
|
info("Setting station SSID to: \"%s\"", buff);
|
||||||
strncpy_safe(wificonf->sta_ssid, buff, SSID_LEN);
|
strncpy_safe(wificonf->sta_ssid, buff, SSID_LEN);
|
||||||
wifi_change_flags.sta = true;
|
wifi_change_flags.sta = true;
|
||||||
|
sta_ssid_pw_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,12 +497,13 @@ httpd_cgi_state ICACHE_FLASH_ATTR cgiWiFiSetParams(HttpdConnData *connData)
|
|||||||
info("Setting station password to: \"%s\"", buff);
|
info("Setting station password to: \"%s\"", buff);
|
||||||
strncpy_safe(wificonf->sta_password, buff, PASSWORD_LEN);
|
strncpy_safe(wificonf->sta_password, buff, PASSWORD_LEN);
|
||||||
wifi_change_flags.sta = true;
|
wifi_change_flags.sta = true;
|
||||||
|
sta_ssid_pw_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (redir_url_buf[strlen(SET_REDIR_ERR)] == 0) {
|
if (redir_url_buf[strlen(SET_REDIR_ERR)] == 0) {
|
||||||
// All was OK
|
// All was OK
|
||||||
info("Set WiFi params - success, applying in 1000 ms");
|
info("Set WiFi params - success, applying in 2000 ms");
|
||||||
|
|
||||||
// Settings are applied only if all was OK
|
// Settings are applied only if all was OK
|
||||||
//
|
//
|
||||||
@@ -492,9 +516,19 @@ httpd_cgi_state ICACHE_FLASH_ATTR cgiWiFiSetParams(HttpdConnData *connData)
|
|||||||
// If user connects via the Station IF, they may not even notice the connection reset.
|
// If user connects via the Station IF, they may not even notice the connection reset.
|
||||||
os_timer_disarm(&timer);
|
os_timer_disarm(&timer);
|
||||||
os_timer_setfn(&timer, applyWifiSettingsLaterCb, NULL);
|
os_timer_setfn(&timer, applyWifiSettingsLaterCb, NULL);
|
||||||
os_timer_arm(&timer, 1000, false);
|
os_timer_arm(&timer, 2000, false);
|
||||||
|
|
||||||
httpdRedirect(connData, SET_REDIR_SUC);
|
if ((sta_ssid_pw_changed || sta_turned_on)
|
||||||
|
&& wificonf->opmode != SOFTAP_MODE
|
||||||
|
&& wificonf->sta_ssid[0] != 0) {
|
||||||
|
// User wants to connect
|
||||||
|
|
||||||
|
info("User wants to connect to SSID, redirecting to ConnStatus page.");
|
||||||
|
httpdRedirect(connData, "/cfg/wifi/connecting");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
httpdRedirect(connData, SET_REDIR_SUC);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
warn("Some WiFi settings did not validate, asking for correction");
|
warn("Some WiFi settings did not validate, asking for correction");
|
||||||
// Some errors, appended to the URL as ?err=
|
// Some errors, appended to the URL as ?err=
|
||||||
@@ -558,7 +592,7 @@ httpd_cgi_state ICACHE_FLASH_ATTR tplWlan(HttpdConnData *connData, char *token,
|
|||||||
// For display of our current SSID
|
// For display of our current SSID
|
||||||
connectStatus = wifi_station_get_connect_status();
|
connectStatus = wifi_station_get_connect_status();
|
||||||
x = wifi_get_opmode();
|
x = wifi_get_opmode();
|
||||||
if (x == SOFTAP_MODE || connectStatus != STATION_GOT_IP) {
|
if (x == SOFTAP_MODE || connectStatus != STATION_GOT_IP || wificonf->opmode == SOFTAP_MODE) {
|
||||||
strcpy(buff, "");
|
strcpy(buff, "");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -571,7 +605,7 @@ httpd_cgi_state ICACHE_FLASH_ATTR tplWlan(HttpdConnData *connData, char *token,
|
|||||||
x = wifi_get_opmode();
|
x = wifi_get_opmode();
|
||||||
connectStatus = wifi_station_get_connect_status();
|
connectStatus = wifi_station_get_connect_status();
|
||||||
|
|
||||||
if (x == SOFTAP_MODE || connectStatus != STATION_GOT_IP) {
|
if (x == SOFTAP_MODE || connectStatus != STATION_GOT_IP || wificonf->opmode == SOFTAP_MODE) {
|
||||||
strcpy(buff, "");
|
strcpy(buff, "");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
+7
-1
@@ -31,6 +31,12 @@ void terminal_restore_defaults(void)
|
|||||||
* Apply settings after eg. restore from defaults
|
* Apply settings after eg. restore from defaults
|
||||||
*/
|
*/
|
||||||
void terminal_apply_settings(void)
|
void terminal_apply_settings(void)
|
||||||
|
{
|
||||||
|
terminal_apply_settings_noclear();
|
||||||
|
screen_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void terminal_apply_settings_noclear(void)
|
||||||
{
|
{
|
||||||
memcpy(&termconf_scratch, termconf, sizeof(TerminalConfigBundle));
|
memcpy(&termconf_scratch, termconf, sizeof(TerminalConfigBundle));
|
||||||
if (W*H >= MAX_SCREEN_SIZE) {
|
if (W*H >= MAX_SCREEN_SIZE) {
|
||||||
@@ -39,8 +45,8 @@ void terminal_apply_settings(void)
|
|||||||
terminal_restore_defaults();
|
terminal_restore_defaults();
|
||||||
persist_store();
|
persist_store();
|
||||||
memcpy(&termconf_scratch, termconf, sizeof(TerminalConfigBundle));
|
memcpy(&termconf_scratch, termconf, sizeof(TerminalConfigBundle));
|
||||||
|
screen_init();
|
||||||
}
|
}
|
||||||
screen_init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ extern TerminalConfigBundle termconf_scratch;
|
|||||||
|
|
||||||
void terminal_restore_defaults(void);
|
void terminal_restore_defaults(void);
|
||||||
void terminal_apply_settings(void);
|
void terminal_apply_settings(void);
|
||||||
|
void terminal_apply_settings_noclear(void); // the same, but with no screen reset / init
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum screen size (determines size of the static data array)
|
* Maximum screen size (determines size of the static data array)
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
#ifndef USER_MAIN_H_H
|
#ifndef USER_MAIN_H_H
|
||||||
#define USER_MAIN_H_H
|
#define USER_MAIN_H_H
|
||||||
|
|
||||||
#define FIRMWARE_VERSION "0.6.1+" GIT_HASH
|
#define FIRMWARE_VERSION "0.6.3+" GIT_HASH
|
||||||
#define TERMINAL_GITHUB_REPO "https://github.com/MightyPork/esp-vt100-firmware"
|
#define TERMINAL_GITHUB_REPO "https://github.com/MightyPork/esp-vt100-firmware"
|
||||||
|
|
||||||
#endif //USER_MAIN_H_H
|
#endif //USER_MAIN_H_H
|
||||||
|
|||||||
Reference in New Issue
Block a user