Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e944a994a7 | ||
|
|
6535b49551 | ||
|
|
2cb8586c94 | ||
|
|
ec1cebdd4c | ||
|
|
af5a3a64ed | ||
|
|
7b94eef448 | ||
|
|
c8067122d5 | ||
|
|
12385b7a5f | ||
|
|
5564147f67 | ||
|
|
32ba7dc0d7 | ||
|
|
80721c1715 | ||
|
|
e22d3f26d9 |
@@ -65,7 +65,7 @@ LIBS += esphttpd
|
||||
# compiler flags using during compilation of source files
|
||||
CFLAGS = -Os -ggdb -std=gnu99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \
|
||||
-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)"'
|
||||
|
||||
# linker flags used to generate the main object file
|
||||
|
||||
+17
-2
@@ -16,6 +16,11 @@ return [
|
||||
|
||||
'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.sta' => 'DHCP Client (Station)',
|
||||
'net.sta_mac' => 'Station MAC',
|
||||
@@ -100,10 +105,20 @@ return [
|
||||
|
||||
'wifi.conn.status' => 'Status:',
|
||||
'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.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.working' => "Connecting to selected AP",
|
||||
'wifi.conn.fail' => "Connection failed, check settings & try again. Cause: ",
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
</div>
|
||||
</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>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<div class="Box">
|
||||
<p><?= tr('wifi.conn.explain_android_sucks') ?></p>
|
||||
<p><?= tr('wifi.conn.explain_reset') ?></p>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var xhr = new XMLHttpRequest();
|
||||
var abortTmeo;
|
||||
var failCounter = 0;
|
||||
|
||||
var messages = <?= json_encode([
|
||||
'disabled' => tr('wifi.conn.disabled'),
|
||||
@@ -17,33 +23,63 @@
|
||||
'fail' => tr('wifi.conn.fail'),
|
||||
]) ?>;
|
||||
|
||||
function onFail() {
|
||||
$("#status").html(<?= json_encode(tr('wifi.conn.telemetry_lost')) ?>);
|
||||
$('.anim-dots').addClass('hidden');
|
||||
}
|
||||
|
||||
function getStatus() {
|
||||
xhr.open("GET", 'http://'+_root+'<?= url('wifi_connstatus', true) ?>');
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState == 4 && xhr.status >= 200 && xhr.status < 300) {
|
||||
clearTimeout(abortTmeo);
|
||||
var data = JSON.parse(xhr.responseText);
|
||||
var done = false;
|
||||
var msg = messages[data.status] || '...';
|
||||
if (data.status == 'success') msg += data.ip;
|
||||
if (data.status == 'fail') msg += data.cause;
|
||||
if (xhr.readyState == 4) {
|
||||
if (xhr.status == 200) {
|
||||
clearTimeout(abortTmeo);
|
||||
|
||||
$("#status").html(msg);
|
||||
try {
|
||||
var data = JSON.parse(xhr.responseText);
|
||||
var done = false;
|
||||
var msg = messages[data.status] || '...';
|
||||
|
||||
if (done) {
|
||||
// $('#backbtn').removeClass('hidden');
|
||||
$('.anim-dots').addClass('hidden');
|
||||
if (data.status == 'success') {
|
||||
msg += data.ip;
|
||||
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 {
|
||||
window.setTimeout(getStatus, 1000);
|
||||
onFail();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// XHR timeout
|
||||
abortTmeo = setTimeout(function () {
|
||||
xhr.abort();
|
||||
$("#status").html(<?= json_encode(tr('wifi.conn.telemetry_lost')) ?>);
|
||||
// $('#backbtn').removeClass('hidden');
|
||||
$('.anim-dots').addClass('hidden');
|
||||
onFail();
|
||||
}, 4000);
|
||||
|
||||
xhr.send();
|
||||
|
||||
@@ -26,9 +26,10 @@
|
||||
|
||||
<nav id="botnav">
|
||||
<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('help') ?>">Help</a><!--
|
||||
--><a href="<?= url('about') ?>">About</a>
|
||||
--><a href="<?= url('cfg_term') ?>"><?= tr('term_nav.config') ?></a><!--
|
||||
--><a href="<?= url('cfg_wifi') ?>"><?= tr('term_nav.wifi') ?></a><!--
|
||||
--><a href="<?= url('help') ?>"><?= tr('term_nav.help') ?></a><!--
|
||||
--><a href="<?= url('about') ?>"><?= tr('term_nav.about') ?></a>
|
||||
</nav>
|
||||
|
||||
<script>
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
/**
|
||||
* 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(x) STR_HELPER(x)
|
||||
|
||||
+235
-181
@@ -12,22 +12,25 @@ static const char _ansi_actions[] = {
|
||||
3, 1, 4, 1, 5, 1, 6, 1,
|
||||
7, 1, 8, 1, 9, 1, 10, 1,
|
||||
11, 1, 12, 1, 13, 1, 14, 2,
|
||||
9, 10, 2, 9, 11
|
||||
2, 5, 2, 10, 11, 2, 10, 12
|
||||
|
||||
};
|
||||
|
||||
static const char _ansi_eof_actions[] = {
|
||||
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, 0, 0, 0, 0, 0
|
||||
13, 13, 13, 13, 0, 0, 0, 0,
|
||||
0, 0, 0, 0
|
||||
};
|
||||
|
||||
static const int ansi_start = 1;
|
||||
static const int ansi_first_final = 26;
|
||||
static const int ansi_first_final = 28;
|
||||
static const int ansi_error = 0;
|
||||
|
||||
static const int ansi_en_CSI_body = 3;
|
||||
static const int ansi_en_OSC_body = 5;
|
||||
static const int ansi_en_CSI_body = 4;
|
||||
static const int ansi_en_OSC_body = 6;
|
||||
static const int ansi_en_TITLE_body = 26;
|
||||
static const int ansi_en_main = 1;
|
||||
|
||||
|
||||
@@ -80,7 +83,7 @@ ansi_parser(const char *newdata, size_t len)
|
||||
// Init Ragel on the first run
|
||||
if (cs == -1) {
|
||||
|
||||
/* #line 84 "user/ansi_parser.c" */
|
||||
/* #line 87 "user/ansi_parser.c" */
|
||||
{
|
||||
cs = ansi_start;
|
||||
}
|
||||
@@ -97,7 +100,7 @@ ansi_parser(const char *newdata, size_t len)
|
||||
|
||||
// The parser
|
||||
|
||||
/* #line 101 "user/ansi_parser.c" */
|
||||
/* #line 104 "user/ansi_parser.c" */
|
||||
{
|
||||
const char *_acts;
|
||||
unsigned int _nacts;
|
||||
@@ -114,219 +117,268 @@ case 1:
|
||||
goto tr0;
|
||||
case 2:
|
||||
switch( (*p) ) {
|
||||
case 55: goto tr3;
|
||||
case 56: goto tr4;
|
||||
case 35: goto tr3;
|
||||
case 91: goto tr5;
|
||||
case 93: goto tr6;
|
||||
case 99: goto tr7;
|
||||
case 107: goto tr7;
|
||||
}
|
||||
if ( (*p) < 65 ) {
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr4;
|
||||
} else if ( (*p) > 90 ) {
|
||||
if ( 97 <= (*p) && (*p) <= 122 )
|
||||
goto tr4;
|
||||
} else
|
||||
goto tr4;
|
||||
goto tr2;
|
||||
case 0:
|
||||
goto _out;
|
||||
case 26:
|
||||
case 3:
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr8;
|
||||
goto tr2;
|
||||
case 28:
|
||||
if ( (*p) == 27 )
|
||||
goto tr1;
|
||||
goto tr0;
|
||||
case 3:
|
||||
if ( (*p) == 59 )
|
||||
goto tr10;
|
||||
case 4:
|
||||
switch( (*p) ) {
|
||||
case 59: goto tr11;
|
||||
case 64: goto tr12;
|
||||
}
|
||||
if ( (*p) < 60 ) {
|
||||
if ( (*p) > 47 ) {
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr9;
|
||||
goto tr10;
|
||||
} else if ( (*p) >= 32 )
|
||||
goto tr8;
|
||||
} else if ( (*p) > 64 ) {
|
||||
if ( (*p) > 90 ) {
|
||||
if ( 97 <= (*p) && (*p) <= 122 )
|
||||
goto tr11;
|
||||
} else if ( (*p) >= 65 )
|
||||
goto tr11;
|
||||
} else
|
||||
goto tr8;
|
||||
goto tr2;
|
||||
case 4:
|
||||
if ( (*p) == 59 )
|
||||
goto tr10;
|
||||
if ( (*p) < 65 ) {
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr9;
|
||||
} else if ( (*p) > 90 ) {
|
||||
if ( 97 <= (*p) && (*p) <= 122 )
|
||||
goto tr11;
|
||||
} else if ( (*p) > 63 ) {
|
||||
if ( (*p) > 90 ) {
|
||||
if ( 96 <= (*p) && (*p) <= 122 )
|
||||
goto tr13;
|
||||
} else if ( (*p) >= 65 )
|
||||
goto tr13;
|
||||
} else
|
||||
goto tr11;
|
||||
goto tr2;
|
||||
case 27:
|
||||
goto tr9;
|
||||
goto tr2;
|
||||
case 5:
|
||||
switch( (*p) ) {
|
||||
case 66: goto tr12;
|
||||
case 84: goto tr13;
|
||||
case 87: goto tr14;
|
||||
}
|
||||
goto tr2;
|
||||
case 6:
|
||||
if ( (*p) == 84 )
|
||||
goto tr15;
|
||||
goto tr2;
|
||||
case 7:
|
||||
if ( (*p) == 78 )
|
||||
goto tr16;
|
||||
goto tr2;
|
||||
case 8:
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr17;
|
||||
goto tr2;
|
||||
case 9:
|
||||
if ( (*p) == 61 )
|
||||
goto tr18;
|
||||
goto tr2;
|
||||
case 10:
|
||||
if ( (*p) == 27 )
|
||||
goto tr2;
|
||||
goto tr19;
|
||||
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 )
|
||||
goto tr22;
|
||||
if ( (*p) == 59 )
|
||||
goto tr11;
|
||||
if ( (*p) < 64 ) {
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr10;
|
||||
} else if ( (*p) > 90 ) {
|
||||
if ( 96 <= (*p) && (*p) <= 122 )
|
||||
goto tr13;
|
||||
} else
|
||||
goto tr13;
|
||||
goto tr2;
|
||||
case 29:
|
||||
goto tr2;
|
||||
case 13:
|
||||
if ( (*p) == 73 )
|
||||
case 30:
|
||||
if ( (*p) == 59 )
|
||||
goto tr11;
|
||||
if ( (*p) < 64 ) {
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr10;
|
||||
} else if ( (*p) > 90 ) {
|
||||
if ( 96 <= (*p) && (*p) <= 122 )
|
||||
goto tr13;
|
||||
} else
|
||||
goto tr13;
|
||||
goto tr2;
|
||||
case 6:
|
||||
switch( (*p) ) {
|
||||
case 48: goto tr14;
|
||||
case 66: goto tr15;
|
||||
case 84: goto tr16;
|
||||
case 87: goto tr17;
|
||||
}
|
||||
goto tr2;
|
||||
case 7:
|
||||
if ( (*p) == 59 )
|
||||
goto tr18;
|
||||
goto tr2;
|
||||
case 8:
|
||||
switch( (*p) ) {
|
||||
case 7: goto tr20;
|
||||
case 27: goto tr21;
|
||||
}
|
||||
goto tr19;
|
||||
case 31:
|
||||
switch( (*p) ) {
|
||||
case 7: goto tr20;
|
||||
case 27: goto tr21;
|
||||
}
|
||||
goto tr19;
|
||||
case 9:
|
||||
if ( (*p) == 92 )
|
||||
goto tr22;
|
||||
goto tr2;
|
||||
case 32:
|
||||
goto tr2;
|
||||
case 10:
|
||||
if ( (*p) == 84 )
|
||||
goto tr23;
|
||||
goto tr2;
|
||||
case 14:
|
||||
if ( (*p) == 84 )
|
||||
case 11:
|
||||
if ( (*p) == 78 )
|
||||
goto tr24;
|
||||
goto tr2;
|
||||
case 15:
|
||||
if ( (*p) == 76 )
|
||||
case 12:
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr25;
|
||||
goto tr2;
|
||||
case 16:
|
||||
if ( (*p) == 69 )
|
||||
case 13:
|
||||
if ( (*p) == 61 )
|
||||
goto tr26;
|
||||
goto tr2;
|
||||
case 14:
|
||||
switch( (*p) ) {
|
||||
case 7: goto tr28;
|
||||
case 27: goto tr29;
|
||||
}
|
||||
goto tr27;
|
||||
case 33:
|
||||
switch( (*p) ) {
|
||||
case 7: goto tr28;
|
||||
case 27: goto tr29;
|
||||
}
|
||||
goto tr27;
|
||||
case 15:
|
||||
if ( (*p) == 92 )
|
||||
goto tr30;
|
||||
goto tr2;
|
||||
case 16:
|
||||
if ( (*p) == 73 )
|
||||
goto tr31;
|
||||
goto tr2;
|
||||
case 17:
|
||||
if ( (*p) == 61 )
|
||||
goto tr27;
|
||||
if ( (*p) == 84 )
|
||||
goto tr32;
|
||||
goto tr2;
|
||||
case 18:
|
||||
if ( (*p) == 27 )
|
||||
goto tr2;
|
||||
goto tr28;
|
||||
if ( (*p) == 76 )
|
||||
goto tr33;
|
||||
goto tr2;
|
||||
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;
|
||||
if ( (*p) == 69 )
|
||||
goto tr34;
|
||||
goto tr2;
|
||||
case 20:
|
||||
if ( (*p) == 92 )
|
||||
goto tr31;
|
||||
if ( (*p) == 61 )
|
||||
goto tr35;
|
||||
goto tr2;
|
||||
case 21:
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr32;
|
||||
goto tr36;
|
||||
goto tr2;
|
||||
case 22:
|
||||
if ( (*p) == 59 )
|
||||
goto tr33;
|
||||
goto tr37;
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr32;
|
||||
goto tr36;
|
||||
goto tr2;
|
||||
case 23:
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr34;
|
||||
goto tr38;
|
||||
goto tr2;
|
||||
case 24:
|
||||
switch( (*p) ) {
|
||||
case 7: goto tr35;
|
||||
case 27: goto tr36;
|
||||
case 7: goto tr39;
|
||||
case 27: goto tr40;
|
||||
}
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr34;
|
||||
goto tr38;
|
||||
goto tr2;
|
||||
case 25:
|
||||
if ( (*p) == 92 )
|
||||
goto tr35;
|
||||
goto tr39;
|
||||
goto tr2;
|
||||
case 26:
|
||||
switch( (*p) ) {
|
||||
case 7: goto tr42;
|
||||
case 27: goto tr43;
|
||||
}
|
||||
goto tr41;
|
||||
case 34:
|
||||
switch( (*p) ) {
|
||||
case 7: goto tr42;
|
||||
case 27: goto tr43;
|
||||
}
|
||||
goto tr41;
|
||||
case 27:
|
||||
if ( (*p) == 92 )
|
||||
goto tr44;
|
||||
goto tr2;
|
||||
case 35:
|
||||
goto tr2;
|
||||
}
|
||||
|
||||
tr2: cs = 0; goto f0;
|
||||
tr0: cs = 1; goto f1;
|
||||
tr1: cs = 2; goto _again;
|
||||
tr8: cs = 4; goto f7;
|
||||
tr9: cs = 4; goto f8;
|
||||
tr10: cs = 4; goto f9;
|
||||
tr12: cs = 6; goto _again;
|
||||
tr15: cs = 7; goto _again;
|
||||
tr16: cs = 8; goto _again;
|
||||
tr17: cs = 9; goto f8;
|
||||
tr18: cs = 10; goto _again;
|
||||
tr19: cs = 11; goto f11;
|
||||
tr21: cs = 12; goto _again;
|
||||
tr13: cs = 13; goto _again;
|
||||
tr23: cs = 14; goto _again;
|
||||
tr24: cs = 15; goto _again;
|
||||
tr25: cs = 16; goto _again;
|
||||
tr26: cs = 17; goto _again;
|
||||
tr27: cs = 18; goto _again;
|
||||
tr28: cs = 19; goto f11;
|
||||
tr30: cs = 20; goto _again;
|
||||
tr14: cs = 21; goto _again;
|
||||
tr32: cs = 22; goto f8;
|
||||
tr33: cs = 23; goto f9;
|
||||
tr34: cs = 24; goto f8;
|
||||
tr36: cs = 25; goto _again;
|
||||
tr3: cs = 26; goto f2;
|
||||
tr4: cs = 26; goto f3;
|
||||
tr5: cs = 26; goto f4;
|
||||
tr6: cs = 26; goto f5;
|
||||
tr7: cs = 26; goto f6;
|
||||
tr11: cs = 27; goto f10;
|
||||
tr20: cs = 28; goto f12;
|
||||
tr22: cs = 29; goto f13;
|
||||
tr31: cs = 29; goto f15;
|
||||
tr35: cs = 29; goto f16;
|
||||
tr29: cs = 30; goto f14;
|
||||
tr3: cs = 3; goto _again;
|
||||
tr9: cs = 5; goto f7;
|
||||
tr10: cs = 5; goto f8;
|
||||
tr11: cs = 5; goto f9;
|
||||
tr14: cs = 7; goto _again;
|
||||
tr18: cs = 8; goto _again;
|
||||
tr19: cs = 8; goto f12;
|
||||
tr21: cs = 9; goto _again;
|
||||
tr15: cs = 10; goto _again;
|
||||
tr23: cs = 11; goto _again;
|
||||
tr24: cs = 12; goto _again;
|
||||
tr25: cs = 13; goto f8;
|
||||
tr26: cs = 14; goto _again;
|
||||
tr27: cs = 14; goto f12;
|
||||
tr29: cs = 15; goto _again;
|
||||
tr16: cs = 16; goto _again;
|
||||
tr31: cs = 17; goto _again;
|
||||
tr32: cs = 18; goto _again;
|
||||
tr33: cs = 19; goto _again;
|
||||
tr34: cs = 20; goto _again;
|
||||
tr17: cs = 21; goto _again;
|
||||
tr36: cs = 22; goto f8;
|
||||
tr37: cs = 23; goto f9;
|
||||
tr38: cs = 24; goto f8;
|
||||
tr40: cs = 25; goto _again;
|
||||
tr41: cs = 26; goto f12;
|
||||
tr43: cs = 27; goto _again;
|
||||
tr4: cs = 28; goto f2;
|
||||
tr5: cs = 28; goto f3;
|
||||
tr6: cs = 28; goto f4;
|
||||
tr7: cs = 28; goto f5;
|
||||
tr8: cs = 28; goto f6;
|
||||
tr13: cs = 29; goto f11;
|
||||
tr12: cs = 30; goto f10;
|
||||
tr20: cs = 31; goto f13;
|
||||
tr35: cs = 32; goto f5;
|
||||
tr22: cs = 32; goto f14;
|
||||
tr30: cs = 32; goto f16;
|
||||
tr39: cs = 32; goto f17;
|
||||
tr28: cs = 33; goto f15;
|
||||
tr42: cs = 34; goto f13;
|
||||
tr44: cs = 35; goto f14;
|
||||
|
||||
f1: _acts = _ansi_actions + 1; goto execFuncs;
|
||||
f4: _acts = _ansi_actions + 3; goto execFuncs;
|
||||
f3: _acts = _ansi_actions + 3; goto execFuncs;
|
||||
f7: _acts = _ansi_actions + 5; goto execFuncs;
|
||||
f8: _acts = _ansi_actions + 7; goto execFuncs;
|
||||
f9: _acts = _ansi_actions + 9; goto execFuncs;
|
||||
f10: _acts = _ansi_actions + 11; goto execFuncs;
|
||||
f11: _acts = _ansi_actions + 11; goto execFuncs;
|
||||
f0: _acts = _ansi_actions + 13; goto execFuncs;
|
||||
f5: _acts = _ansi_actions + 15; goto execFuncs;
|
||||
f16: _acts = _ansi_actions + 17; goto execFuncs;
|
||||
f11: _acts = _ansi_actions + 19; goto execFuncs;
|
||||
f15: _acts = _ansi_actions + 21; goto execFuncs;
|
||||
f13: _acts = _ansi_actions + 23; goto execFuncs;
|
||||
f6: _acts = _ansi_actions + 25; goto execFuncs;
|
||||
f2: _acts = _ansi_actions + 27; goto execFuncs;
|
||||
f3: _acts = _ansi_actions + 29; goto execFuncs;
|
||||
f14: _acts = _ansi_actions + 31; goto execFuncs;
|
||||
f12: _acts = _ansi_actions + 34; goto execFuncs;
|
||||
f4: _acts = _ansi_actions + 15; goto execFuncs;
|
||||
f5: _acts = _ansi_actions + 17; goto execFuncs;
|
||||
f17: _acts = _ansi_actions + 19; goto execFuncs;
|
||||
f12: _acts = _ansi_actions + 21; goto execFuncs;
|
||||
f14: _acts = _ansi_actions + 23; goto execFuncs;
|
||||
f16: _acts = _ansi_actions + 25; goto execFuncs;
|
||||
f6: _acts = _ansi_actions + 27; goto execFuncs;
|
||||
f2: _acts = _ansi_actions + 29; goto execFuncs;
|
||||
f10: _acts = _ansi_actions + 31; goto execFuncs;
|
||||
f13: _acts = _ansi_actions + 34; goto execFuncs;
|
||||
f15: _acts = _ansi_actions + 37; goto execFuncs;
|
||||
|
||||
execFuncs:
|
||||
_nacts = *_acts++;
|
||||
@@ -350,7 +402,7 @@ execFuncs:
|
||||
csi_n[i] = 0;
|
||||
}
|
||||
|
||||
{cs = 3;goto _again;}
|
||||
{cs = 4;goto _again;}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
@@ -404,61 +456,61 @@ execFuncs:
|
||||
osc_bi = 0;
|
||||
osc_buffer[0] = '\0';
|
||||
|
||||
{cs = 5;goto _again;}
|
||||
{cs = 6;goto _again;}
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
/* #line 150 "user/ansi_parser.rl" */
|
||||
/* #line 151 "user/ansi_parser.rl" */
|
||||
{
|
||||
osc_bi = 0;
|
||||
osc_buffer[0] = '\0';
|
||||
{cs = 26;goto _again;}
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
/* #line 157 "user/ansi_parser.rl" */
|
||||
{
|
||||
apars_handle_OSC_SetScreenSize(csi_n[0], csi_n[1]);
|
||||
{cs = 1;goto _again;}
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
/* #line 155 "user/ansi_parser.rl" */
|
||||
case 10:
|
||||
/* #line 162 "user/ansi_parser.rl" */
|
||||
{
|
||||
osc_buffer[osc_bi++] = (*p);
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
/* #line 159 "user/ansi_parser.rl" */
|
||||
case 11:
|
||||
/* #line 166 "user/ansi_parser.rl" */
|
||||
{
|
||||
osc_buffer[osc_bi++] = '\0';
|
||||
apars_handle_OSC_SetTitle(osc_buffer);
|
||||
{cs = 1;goto _again;}
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
/* #line 165 "user/ansi_parser.rl" */
|
||||
case 12:
|
||||
/* #line 172 "user/ansi_parser.rl" */
|
||||
{
|
||||
osc_buffer[osc_bi++] = '\0';
|
||||
apars_handle_OSC_SetButton(csi_n[0], osc_buffer);
|
||||
{cs = 1;goto _again;}
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
/* #line 177 "user/ansi_parser.rl" */
|
||||
{
|
||||
// Reset screen
|
||||
apars_handle_RESET_cmd();
|
||||
{cs = 1;goto _again;}
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
/* #line 183 "user/ansi_parser.rl" */
|
||||
/* #line 204 "user/ansi_parser.rl" */
|
||||
{
|
||||
apars_handle_saveCursorAttrs();
|
||||
apars_handle_hashCode((*p));
|
||||
{cs = 1;goto _again;}
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
/* #line 188 "user/ansi_parser.rl" */
|
||||
/* #line 209 "user/ansi_parser.rl" */
|
||||
{
|
||||
apars_handle_restoreCursorAttrs();
|
||||
apars_handle_shortCode((*p));
|
||||
{cs = 1;goto _again;}
|
||||
}
|
||||
break;
|
||||
/* #line 462 "user/ansi_parser.c" */
|
||||
/* #line 514 "user/ansi_parser.c" */
|
||||
}
|
||||
}
|
||||
goto _again;
|
||||
@@ -484,7 +536,7 @@ _again:
|
||||
goto _again;}
|
||||
}
|
||||
break;
|
||||
/* #line 488 "user/ansi_parser.c" */
|
||||
/* #line 540 "user/ansi_parser.c" */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -492,6 +544,8 @@ goto _again;}
|
||||
_out: {}
|
||||
}
|
||||
|
||||
/* #line 208 "user/ansi_parser.rl" */
|
||||
/* #line 229 "user/ansi_parser.rl" */
|
||||
|
||||
}
|
||||
|
||||
// 'ESC k blah OSC_end' is a shortcut for setting title (k is defined in GNU screen as Title Definition String)
|
||||
|
||||
+3
-4
@@ -9,14 +9,13 @@
|
||||
#define OSC_CHAR_MAX TERM_TITLE_LEN
|
||||
|
||||
extern void apars_handle_badseq(void);
|
||||
extern void apars_handle_CSI(char leadchar, int *params, char keychar);
|
||||
extern void apars_handle_RESET_cmd(void);
|
||||
extern void apars_handle_plainchar(char c);
|
||||
extern void apars_handle_CSI(char leadchar, int *params, char keychar);
|
||||
extern void apars_handle_OSC_SetScreenSize(int rows, int cols);
|
||||
extern void apars_handle_saveCursorAttrs(void);
|
||||
extern void apars_handle_restoreCursorAttrs(void);
|
||||
extern void apars_handle_OSC_SetButton(int num, const char *buffer);
|
||||
extern void apars_handle_OSC_SetTitle(const char *buffer);
|
||||
extern void apars_handle_shortCode(char c);
|
||||
extern void apars_handle_hashCode(char c);
|
||||
|
||||
/**
|
||||
* \brief Linear ANSI chars stream parser
|
||||
|
||||
+32
-9
@@ -127,7 +127,7 @@ ansi_parser(const char *newdata, size_t len)
|
||||
|
||||
CSI_body := ((32..47|60..64) @CSI_leading)?
|
||||
((digit @CSI_digit)* ';' @CSI_semi)*
|
||||
(digit @CSI_digit)* alpha @CSI_end $!errBadSeq;
|
||||
(digit @CSI_digit)* (alpha|'`'|'@') @CSI_end $!errBadSeq;
|
||||
|
||||
|
||||
# --- OSC commands (Operating System Commands) ---
|
||||
@@ -147,6 +147,13 @@ ansi_parser(const char *newdata, size_t len)
|
||||
fgoto OSC_body;
|
||||
}
|
||||
|
||||
# collecting title string; this can also be entered by ESC k
|
||||
action SetTitle_start {
|
||||
osc_bi = 0;
|
||||
osc_buffer[0] = '\0';
|
||||
fgoto TITLE_body;
|
||||
}
|
||||
|
||||
action OSC_resize {
|
||||
apars_handle_OSC_SetScreenSize(csi_n[0], csi_n[1]);
|
||||
fgoto main;
|
||||
@@ -167,13 +174,17 @@ ansi_parser(const char *newdata, size_t len)
|
||||
apars_handle_OSC_SetButton(csi_n[0], osc_buffer);
|
||||
fgoto main;
|
||||
}
|
||||
|
||||
|
||||
# 0; is xterm title hack
|
||||
OSC_body := (
|
||||
("BTN" digit @CSI_digit '=' (NOESC @OSC_text_char)+ OSC_END @OSC_button) |
|
||||
("TITLE=" (NOESC @OSC_text_char)+ OSC_END @OSC_title) |
|
||||
("BTN" digit @CSI_digit '=' (NOESC @OSC_text_char)* OSC_END @OSC_button) |
|
||||
("TITLE=" @SetTitle_start) |
|
||||
("0;" (NOESC @OSC_text_char)* OSC_END @OSC_title) |
|
||||
('W' (digit @CSI_digit)+ ';' @CSI_semi (digit @CSI_digit)+ OSC_END @OSC_resize)
|
||||
) $!errBadSeq;
|
||||
|
||||
TITLE_body := (NOESC @OSC_text_char)* OSC_END @OSC_title $!errBadSeq;
|
||||
|
||||
action RESET_cmd {
|
||||
// Reset screen
|
||||
apars_handle_RESET_cmd();
|
||||
@@ -190,16 +201,26 @@ ansi_parser(const char *newdata, size_t len)
|
||||
fgoto main;
|
||||
}
|
||||
|
||||
action HASH_code {
|
||||
apars_handle_hashCode(fc);
|
||||
fgoto main;
|
||||
}
|
||||
|
||||
action SHORT_code {
|
||||
apars_handle_shortCode(fc);
|
||||
fgoto main;
|
||||
}
|
||||
|
||||
# --- Main parser loop ---
|
||||
|
||||
main :=
|
||||
(
|
||||
(NOESC @plain_char)* ESC (
|
||||
'[' @CSI_start |
|
||||
']' @OSC_start |
|
||||
'c' @RESET_cmd |
|
||||
'7' @CSI_SaveCursorAttrs |
|
||||
'8' @CSI_RestoreCursorAttrs
|
||||
('[' @CSI_start) |
|
||||
(']' @OSC_start) |
|
||||
('#' digit @HASH_code) |
|
||||
('k' @SetTitle_start) |
|
||||
([a-jl-zA-Z0-9] @SHORT_code)
|
||||
)
|
||||
)+ $!errBadSeq;
|
||||
|
||||
@@ -207,3 +228,5 @@ ansi_parser(const char *newdata, size_t len)
|
||||
#*/
|
||||
}%%
|
||||
}
|
||||
|
||||
// 'ESC k blah OSC_end' is a shortcut for setting title (k is defined in GNU screen as Title Definition String)
|
||||
|
||||
+104
-44
@@ -9,7 +9,8 @@
|
||||
#include "screen.h"
|
||||
#include "ansi_parser.h"
|
||||
#include "uart_driver.h"
|
||||
#include "persist.h"
|
||||
|
||||
// screen manpage - https://www.gnu.org/software/screen/manual/html_node/Control-Sequences.html
|
||||
|
||||
static char utf_collect[4];
|
||||
static int utf_i = 0;
|
||||
@@ -93,6 +94,8 @@ apars_handle_CSI(char leadchar, int *params, char keychar)
|
||||
CSI u RCP – Restore Cursor Position
|
||||
CSI ?25l DECTCEM Hides the cursor
|
||||
CSI ?25h DECTCEM Shows the cursor
|
||||
|
||||
and some others
|
||||
*/
|
||||
|
||||
int n1 = params[0];
|
||||
@@ -101,15 +104,22 @@ apars_handle_CSI(char leadchar, int *params, char keychar)
|
||||
|
||||
// defaults
|
||||
switch (keychar) {
|
||||
case 'A':
|
||||
case 'A': // move
|
||||
case 'B':
|
||||
case 'C':
|
||||
case 'D':
|
||||
case 'E':
|
||||
case 'F':
|
||||
case 'G':
|
||||
case 'S':
|
||||
case 'G': // set X
|
||||
case '`':
|
||||
case 'S': // scrolling
|
||||
case 'T':
|
||||
case 'X': // clear in line
|
||||
case 'd': // set Y
|
||||
case 'L':
|
||||
case 'M':
|
||||
case '@':
|
||||
case 'P':
|
||||
if (n1 == 0) n1 = 1;
|
||||
break;
|
||||
|
||||
@@ -127,35 +137,48 @@ apars_handle_CSI(char leadchar, int *params, char keychar)
|
||||
|
||||
switch (keychar) {
|
||||
// CUU CUD CUF CUB
|
||||
case 'A': screen_cursor_move(-n1, 0); break;
|
||||
case 'B': screen_cursor_move(n1, 0); break;
|
||||
case 'C': screen_cursor_move(0, n1); break;
|
||||
case 'D': screen_cursor_move(0, -n1); break;
|
||||
case 'A': screen_cursor_move(-n1, 0, false); break;
|
||||
case 'B': screen_cursor_move(n1, 0, false); break;
|
||||
case 'C': screen_cursor_move(0, n1, false); break;
|
||||
case 'D': screen_cursor_move(0, -n1, false); break;
|
||||
|
||||
case 'E': // CNL
|
||||
screen_cursor_move(n1, 0);
|
||||
case 'E': // CNL - Cursor Next Line
|
||||
screen_cursor_move(n1, 0, false);
|
||||
screen_cursor_set_x(0);
|
||||
break;
|
||||
|
||||
case 'F': // CPL
|
||||
screen_cursor_move(-n1, 0);
|
||||
case 'F': // CPL - Cursor Prev Line
|
||||
screen_cursor_move(-n1, 0, false);
|
||||
screen_cursor_set_x(0);
|
||||
break;
|
||||
|
||||
// CHA
|
||||
// Set X
|
||||
case 'G':
|
||||
screen_cursor_set_x(n1 - 1); break; // 1-based
|
||||
case '`': // alternate code
|
||||
screen_cursor_set_x(n1 - 1);
|
||||
break; // 1-based
|
||||
|
||||
// SU, SD
|
||||
// Set Y
|
||||
case 'd':
|
||||
screen_cursor_set_y(n1 - 1);
|
||||
break; // 1-based
|
||||
|
||||
// clear in line
|
||||
case 'X':
|
||||
screen_clear_in_line(n1);
|
||||
break; // 1-based
|
||||
|
||||
// SU, SD - scroll up/down
|
||||
case 'S': screen_scroll_up(n1); break;
|
||||
case 'T': screen_scroll_down(n1); break;
|
||||
|
||||
// CUP,HVP
|
||||
// CUP,HVP - set position
|
||||
case 'H':
|
||||
case 'f':
|
||||
screen_cursor_set(n1-1, n2-1); break; // 1-based
|
||||
screen_cursor_set(n1-1, n2-1);
|
||||
break; // 1-based
|
||||
|
||||
case 'J': // ED
|
||||
case 'J': // ED - clear screen
|
||||
if (n1 == 0) {
|
||||
screen_clear(CLEAR_TO_CURSOR);
|
||||
} else if (n1 == 1) {
|
||||
@@ -166,7 +189,7 @@ apars_handle_CSI(char leadchar, int *params, char keychar)
|
||||
}
|
||||
break;
|
||||
|
||||
case 'K': // EL
|
||||
case 'K': // EL - clear line
|
||||
if (n1 == 0) {
|
||||
screen_clear_line(CLEAR_TO_CURSOR);
|
||||
} else if (n1 == 1) {
|
||||
@@ -176,11 +199,11 @@ apars_handle_CSI(char leadchar, int *params, char keychar)
|
||||
}
|
||||
break;
|
||||
|
||||
// SCP, RCP
|
||||
// SCP, RCP - save/restore position
|
||||
case 's': screen_cursor_save(0); break;
|
||||
case 'u': screen_cursor_restore(0); break;
|
||||
|
||||
case 'n':
|
||||
case 'n': // queries
|
||||
if (n1 == 6) {
|
||||
// Query cursor position
|
||||
char buf[20];
|
||||
@@ -197,7 +220,7 @@ apars_handle_CSI(char leadchar, int *params, char keychar)
|
||||
|
||||
// DECTCEM feature enable / disable
|
||||
|
||||
case 'h':
|
||||
case 'h': // feature enable
|
||||
if (leadchar == '?') {
|
||||
if (n1 == 25) {
|
||||
screen_cursor_enable(1);
|
||||
@@ -207,7 +230,7 @@ apars_handle_CSI(char leadchar, int *params, char keychar)
|
||||
}
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
case 'l': // feature disable
|
||||
if (leadchar == '?') {
|
||||
if (n1 == 25) {
|
||||
screen_cursor_enable(0);
|
||||
@@ -217,47 +240,84 @@ apars_handle_CSI(char leadchar, int *params, char keychar)
|
||||
}
|
||||
break;
|
||||
|
||||
case 'm': // SGR
|
||||
case 'm': // SGR - graphics rendition aka attributes
|
||||
// iterate arguments
|
||||
for (int i = 0; i < CSI_N_MAX; i++) {
|
||||
int n = params[i];
|
||||
|
||||
if (i == 0 && n == 0) { // reset SGR
|
||||
screen_reset_cursor(); // resets colors, inverse and bold.
|
||||
break; // cannot combine reset with others
|
||||
break; // cannot combine reset with others - discard
|
||||
}
|
||||
else if (n >= 30 && n <= 37) screen_set_fg(n-30); // ANSI normal fg
|
||||
else if (n >= 40 && n <= 47) screen_set_bg(n-40); // ANSI normal bg
|
||||
else if (n == 39) screen_set_fg(7); // default fg
|
||||
else if (n == 49) screen_set_bg(false); // default bg
|
||||
else if (n >= 30 && n <= 37) screen_set_fg((Color) (n - 30)); // ANSI normal fg
|
||||
else if (n >= 40 && n <= 47) screen_set_bg((Color) (n - 40)); // ANSI normal bg
|
||||
else if (n == 39) screen_set_fg(termconf_scratch.default_fg); // default fg
|
||||
else if (n == 49) screen_set_bg(termconf_scratch.default_bg); // default bg
|
||||
else if (n == 7) screen_inverse(true); // inverse
|
||||
else if (n == 27) screen_inverse(false); // positive
|
||||
else if (n == 1) screen_set_bold(true); // bold
|
||||
else if (n == 21 || n == 22) screen_set_bold(false); // bold off
|
||||
else if (n >= 90 && n <= 97) screen_set_fg(n-90+8); // AIX bright fg
|
||||
else if (n >= 100 && n <= 107) screen_set_bg(n-100+8); // AIX bright bg
|
||||
else if (n >= 90 && n <= 97) screen_set_fg((Color) (n - 90 + 8)); // AIX bright fg
|
||||
else if (n >= 100 && n <= 107) screen_set_bg((Color) (n - 100 + 8)); // AIX bright bg
|
||||
}
|
||||
break;
|
||||
|
||||
case 't': // SunView code to set screen size (from GNU Screen)
|
||||
screen_resize(n1, n2);
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
screen_insert_lines(n1);
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
screen_delete_lines(n1);
|
||||
break;
|
||||
|
||||
case '@':
|
||||
screen_insert_characters(n1);
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
screen_delete_characters(n1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ICACHE_FLASH_ATTR apars_handle_saveCursorAttrs(void)
|
||||
/** codes in the format ESC # n */
|
||||
void ICACHE_FLASH_ATTR apars_handle_hashCode(char c)
|
||||
{
|
||||
screen_cursor_save(1);
|
||||
switch(c) {
|
||||
case '8':
|
||||
screen_fill_with_E();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ICACHE_FLASH_ATTR apars_handle_restoreCursorAttrs(void)
|
||||
/** those are single-character escape codes (ESC x) */
|
||||
void ICACHE_FLASH_ATTR apars_handle_shortCode(char c)
|
||||
{
|
||||
screen_cursor_restore(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Handle a request to reset the display device
|
||||
*/
|
||||
void ICACHE_FLASH_ATTR
|
||||
apars_handle_RESET_cmd(void)
|
||||
{
|
||||
screen_reset();
|
||||
switch(c) {
|
||||
case 'c': // screen reset
|
||||
screen_reset();
|
||||
break;
|
||||
case '7': // save cursor + attrs
|
||||
screen_cursor_save(true);
|
||||
break;
|
||||
case '8': // restore cursor + attrs
|
||||
screen_cursor_restore(true);
|
||||
break;
|
||||
case 'E': // same as CR LF
|
||||
screen_cursor_move(1, 0, false);
|
||||
screen_cursor_set_x(0);
|
||||
break;
|
||||
case 'D': // move cursor down, scroll screen up if needed
|
||||
screen_cursor_move(1, 0, true);
|
||||
break;
|
||||
case 'M': // move cursor up, scroll screen down if needed
|
||||
screen_cursor_move(-1, 0, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,13 +2,12 @@
|
||||
#define ANSI_PARSER_CALLBACKS_H
|
||||
|
||||
void apars_handle_badseq(void);
|
||||
void apars_handle_CSI(char leadchar, int *params, char keychar);
|
||||
void apars_handle_RESET_cmd(void);
|
||||
void apars_handle_plainchar(char c);
|
||||
void apars_handle_CSI(char leadchar, int *params, char keychar);
|
||||
void apars_handle_OSC_SetScreenSize(int rows, int cols);
|
||||
void apars_handle_saveCursorAttrs(void);
|
||||
void apars_handle_restoreCursorAttrs(void);
|
||||
void apars_handle_OSC_SetButton(int num, const char *buffer);
|
||||
void apars_handle_OSC_SetTitle(const char *buffer);
|
||||
void apars_handle_shortCode(char c);
|
||||
void apars_handle_hashCode(char c);
|
||||
|
||||
#endif //ESP_VT100_FIRMWARE_ANSI_PARSER_CALLBACKS_H
|
||||
|
||||
+21
-5
@@ -22,6 +22,8 @@ cgiTermCfgSetParams(HttpdConnData *connData)
|
||||
char redir_url_buf[100];
|
||||
int n, w, h;
|
||||
|
||||
bool shall_clear_screen = false;
|
||||
|
||||
char *redir_url = redir_url_buf;
|
||||
redir_url += sprintf(redir_url, SET_REDIR_ERR);
|
||||
// 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);
|
||||
if (h > 1) {
|
||||
if (w * h <= MAX_SCREEN_SIZE) {
|
||||
termconf->width = w;
|
||||
termconf->height = h;
|
||||
if (termconf->width != w || termconf->height != h) {
|
||||
termconf->width = w;
|
||||
termconf->height = h;
|
||||
shall_clear_screen = true;
|
||||
}
|
||||
} else {
|
||||
warn("Bad dimensions: %d x %d (total %d)", w, h, w*h);
|
||||
redir_url += sprintf(redir_url, "term_width,term_height,");
|
||||
@@ -66,7 +71,10 @@ cgiTermCfgSetParams(HttpdConnData *connData)
|
||||
dbg("Screen default BG: %s", buff);
|
||||
n = atoi(buff);
|
||||
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 {
|
||||
warn("Bad color %s", buff);
|
||||
redir_url += sprintf(redir_url, "default_bg,");
|
||||
@@ -88,7 +96,10 @@ cgiTermCfgSetParams(HttpdConnData *connData)
|
||||
dbg("Screen default FG: %s", buff);
|
||||
n = atoi(buff);
|
||||
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 {
|
||||
warn("Bad color %s", buff);
|
||||
redir_url += sprintf(redir_url, "default_fg,");
|
||||
@@ -123,9 +134,14 @@ cgiTermCfgSetParams(HttpdConnData *connData)
|
||||
// All was OK
|
||||
info("Set term params - success, saving...");
|
||||
|
||||
terminal_apply_settings();
|
||||
persist_store();
|
||||
|
||||
if (shall_clear_screen) {
|
||||
terminal_apply_settings();
|
||||
} else {
|
||||
terminal_apply_settings_noclear();
|
||||
}
|
||||
|
||||
httpdRedirect(connData, SET_REDIR_SUC);
|
||||
} else {
|
||||
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;
|
||||
char buff[256];
|
||||
|
||||
if (connData->conn == NULL) {
|
||||
//Connection aborted. Clean up.
|
||||
return HTTPD_CGI_DONE;
|
||||
}
|
||||
|
||||
// auto-turn on STA
|
||||
if ((wificonf->opmode & STATION_MODE) == 0) {
|
||||
wificonf->opmode |= STATION_MODE;
|
||||
@@ -265,6 +270,13 @@ httpd_cgi_state ICACHE_FLASH_ATTR cgiWiFiConnStatus(HttpdConnData *connData)
|
||||
char buff[100];
|
||||
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);
|
||||
httpdHeader(connData, "Content-Type", "application/json");
|
||||
httpdEndHeaders(connData);
|
||||
@@ -276,6 +288,7 @@ httpd_cgi_state ICACHE_FLASH_ATTR cgiWiFiConnStatus(HttpdConnData *connData)
|
||||
}
|
||||
|
||||
STATION_STATUS st = wifi_station_get_connect_status();
|
||||
dbg("CONN STATE = %d", st);
|
||||
switch(st) {
|
||||
case STATION_IDLE:
|
||||
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);
|
||||
sprintf(buff, "{\"status\": \"success\", \"ip\": \""IPSTR"\"}", GOOD_IP2STR(info.ip.addr));
|
||||
break;
|
||||
|
||||
default:
|
||||
sprintf(buff, "{\"status\": \"working\", \"wtf\": \"state = %d\"}", st);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
tplSend(connData, buff, -1);
|
||||
httpdSend(connData, buff, -1);
|
||||
return HTTPD_CGI_DONE;
|
||||
}
|
||||
|
||||
@@ -336,6 +354,9 @@ httpd_cgi_state ICACHE_FLASH_ATTR cgiWiFiSetParams(HttpdConnData *connData)
|
||||
return HTTPD_CGI_DONE;
|
||||
}
|
||||
|
||||
bool sta_turned_on = false;
|
||||
bool sta_ssid_pw_changed = false;
|
||||
|
||||
// ---- WiFi opmode ----
|
||||
|
||||
if (GET_ARG("opmode")) {
|
||||
@@ -366,6 +387,7 @@ httpd_cgi_state ICACHE_FLASH_ATTR cgiWiFiSetParams(HttpdConnData *connData)
|
||||
|
||||
if (enable) {
|
||||
wificonf->opmode |= STATION_MODE;
|
||||
sta_turned_on = true;
|
||||
} else {
|
||||
wificonf->opmode &= ~STATION_MODE;
|
||||
}
|
||||
@@ -463,6 +485,7 @@ httpd_cgi_state ICACHE_FLASH_ATTR cgiWiFiSetParams(HttpdConnData *connData)
|
||||
info("Setting station SSID to: \"%s\"", buff);
|
||||
strncpy_safe(wificonf->sta_ssid, buff, SSID_LEN);
|
||||
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);
|
||||
strncpy_safe(wificonf->sta_password, buff, PASSWORD_LEN);
|
||||
wifi_change_flags.sta = true;
|
||||
sta_ssid_pw_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (redir_url_buf[strlen(SET_REDIR_ERR)] == 0) {
|
||||
// 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
|
||||
//
|
||||
@@ -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.
|
||||
os_timer_disarm(&timer);
|
||||
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 {
|
||||
warn("Some WiFi settings did not validate, asking for correction");
|
||||
// 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
|
||||
connectStatus = wifi_station_get_connect_status();
|
||||
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, "");
|
||||
}
|
||||
else {
|
||||
@@ -571,7 +605,7 @@ httpd_cgi_state ICACHE_FLASH_ATTR tplWlan(HttpdConnData *connData, char *token,
|
||||
x = wifi_get_opmode();
|
||||
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, "");
|
||||
}
|
||||
else {
|
||||
|
||||
+133
-12
@@ -31,6 +31,12 @@ void terminal_restore_defaults(void)
|
||||
* Apply settings after eg. restore from defaults
|
||||
*/
|
||||
void terminal_apply_settings(void)
|
||||
{
|
||||
terminal_apply_settings_noclear();
|
||||
screen_init();
|
||||
}
|
||||
|
||||
void terminal_apply_settings_noclear(void)
|
||||
{
|
||||
memcpy(&termconf_scratch, termconf, sizeof(TerminalConfigBundle));
|
||||
if (W*H >= MAX_SCREEN_SIZE) {
|
||||
@@ -39,8 +45,8 @@ void terminal_apply_settings(void)
|
||||
terminal_restore_defaults();
|
||||
persist_store();
|
||||
memcpy(&termconf_scratch, termconf, sizeof(TerminalConfigBundle));
|
||||
screen_init();
|
||||
}
|
||||
screen_init();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,14 +122,18 @@ clear_range(unsigned int from, unsigned int to)
|
||||
if (to >= W*H) to = W*H-1;
|
||||
Color fg = cursor.inverse ? cursor.bg : cursor.fg;
|
||||
Color bg = cursor.inverse ? cursor.fg : cursor.bg;
|
||||
|
||||
Cell sample;
|
||||
sample.c[0] = ' ';
|
||||
sample.c[1] = 0;
|
||||
sample.c[2] = 0;
|
||||
sample.c[3] = 0;
|
||||
sample.fg = fg;
|
||||
sample.bg = bg;
|
||||
sample.bold = false;
|
||||
|
||||
for (unsigned int i = from; i <= to; i++) {
|
||||
screen[i].c[0] = ' ';
|
||||
screen[i].c[1] = 0;
|
||||
screen[i].c[2] = 0;
|
||||
screen[i].c[3] = 0;
|
||||
screen[i].fg = fg;
|
||||
screen[i].bg = bg;
|
||||
screen[i].bold = false;
|
||||
memcpy(&screen[i], &sample, sizeof(Cell));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,10 +240,121 @@ screen_clear_line(ClearMode mode)
|
||||
NOTIFY_DONE();
|
||||
}
|
||||
|
||||
void ICACHE_FLASH_ATTR
|
||||
screen_clear_in_line(unsigned int count)
|
||||
{
|
||||
if (cursor.x + count >= W) {
|
||||
screen_clear_line(CLEAR_FROM_CURSOR);
|
||||
}
|
||||
else {
|
||||
NOTIFY_LOCK();
|
||||
clear_range(cursor.y * W + cursor.x, cursor.y * W + cursor.x + count - 1);
|
||||
NOTIFY_DONE();
|
||||
}
|
||||
}
|
||||
|
||||
void ICACHE_FLASH_ATTR
|
||||
screen_fill_with_E(void)
|
||||
{
|
||||
NOTIFY_LOCK();
|
||||
Cell sample;
|
||||
sample.c[0] = 'E';
|
||||
sample.c[1] = 0;
|
||||
sample.c[2] = 0;
|
||||
sample.c[3] = 0;
|
||||
sample.fg = termconf_scratch.default_fg;
|
||||
sample.bg = termconf_scratch.default_bg;
|
||||
sample.bold = false;
|
||||
|
||||
for (unsigned int i = 0; i <= W*H-1; i++) {
|
||||
memcpy(&screen[i], &sample, sizeof(Cell));
|
||||
}
|
||||
NOTIFY_DONE();
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
//region Screen manipulation
|
||||
|
||||
void screen_insert_lines(unsigned int lines)
|
||||
{
|
||||
NOTIFY_LOCK();
|
||||
// shift the following lines
|
||||
int targetStart = cursor.y + lines;
|
||||
if (targetStart >= H) {
|
||||
targetStart = H;
|
||||
} else {
|
||||
// do the moving
|
||||
for (int i = H-1; i >= targetStart; i--) {
|
||||
memcpy(screen+i*W, screen+(i-lines)*W, sizeof(Cell)*W);
|
||||
}
|
||||
}
|
||||
|
||||
// clear the first line
|
||||
screen_clear_line(CLEAR_ALL);
|
||||
// copy it to the rest of the cleared region
|
||||
for (int i = cursor.y+1; i < targetStart; i++) {
|
||||
memcpy(screen+i*W, screen+cursor.y*W, sizeof(Cell)*W);
|
||||
}
|
||||
NOTIFY_DONE();
|
||||
}
|
||||
|
||||
void screen_delete_lines(unsigned int lines)
|
||||
{
|
||||
NOTIFY_LOCK();
|
||||
// shift lines up
|
||||
int targetEnd = H - 1 - lines;
|
||||
if (targetEnd <= cursor.y) {
|
||||
targetEnd = cursor.y;
|
||||
} else {
|
||||
// do the moving
|
||||
for (int i = cursor.y; i <= targetEnd; i++) {
|
||||
memcpy(screen+i*W, screen+(i+lines)*W, sizeof(Cell)*W);
|
||||
}
|
||||
}
|
||||
|
||||
// clear the rest
|
||||
clear_range(targetEnd*W, W*H-1);
|
||||
NOTIFY_DONE();
|
||||
}
|
||||
|
||||
void screen_insert_characters(unsigned int count)
|
||||
{
|
||||
NOTIFY_LOCK();
|
||||
int targetStart = cursor.x + count;
|
||||
if (targetStart >= W) {
|
||||
targetStart = W-1;
|
||||
} else {
|
||||
// do the moving
|
||||
for (int i = W-1; i >= targetStart; i--) {
|
||||
memcpy(screen+cursor.y*W+i, screen+cursor.y*W+(i-count), sizeof(Cell));
|
||||
}
|
||||
}
|
||||
|
||||
clear_range(cursor.y*W+cursor.x, cursor.y*W+targetStart-1);
|
||||
NOTIFY_DONE();
|
||||
}
|
||||
|
||||
void screen_delete_characters(unsigned int count)
|
||||
{
|
||||
NOTIFY_LOCK();
|
||||
int targetEnd = W - count;
|
||||
if (targetEnd > cursor.x) {
|
||||
// do the moving
|
||||
for (int i = cursor.x; i <= targetEnd; i++) {
|
||||
memcpy(screen+cursor.y*W+i, screen+cursor.y*W+(i+count), sizeof(Cell));
|
||||
}
|
||||
}
|
||||
|
||||
if (targetEnd <= cursor.x) {
|
||||
screen_clear_line(CLEAR_FROM_CURSOR);
|
||||
}
|
||||
else {
|
||||
clear_range(cursor.y * W + (W - count), (cursor.y + 1) * W - 1);
|
||||
}
|
||||
NOTIFY_DONE();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the screen size
|
||||
*
|
||||
@@ -373,7 +494,7 @@ screen_cursor_set_y(int y)
|
||||
* Relative cursor move
|
||||
*/
|
||||
void ICACHE_FLASH_ATTR
|
||||
screen_cursor_move(int dy, int dx)
|
||||
screen_cursor_move(int dy, int dx, bool scroll)
|
||||
{
|
||||
NOTIFY_LOCK();
|
||||
int move;
|
||||
@@ -386,13 +507,13 @@ screen_cursor_move(int dy, int dx)
|
||||
if (cursor.y < 0) {
|
||||
move = -cursor.y;
|
||||
cursor.y = 0;
|
||||
screen_scroll_down((unsigned int)move);
|
||||
if (scroll) screen_scroll_down((unsigned int)move);
|
||||
}
|
||||
|
||||
if (cursor.y >= H) {
|
||||
move = cursor.y - (H - 1);
|
||||
cursor.y = H - 1;
|
||||
screen_scroll_up((unsigned int)move);
|
||||
if (scroll) screen_scroll_up((unsigned int)move);
|
||||
}
|
||||
|
||||
NOTIFY_DONE();
|
||||
@@ -555,7 +676,7 @@ screen_putchar(const char *ch)
|
||||
goto done;
|
||||
|
||||
case '\n':
|
||||
screen_cursor_move(1, 0);
|
||||
screen_cursor_move(1, 0, true); // can scroll
|
||||
goto done;
|
||||
|
||||
case 8: // BS
|
||||
|
||||
+14
-24
@@ -70,6 +70,7 @@ extern TerminalConfigBundle termconf_scratch;
|
||||
|
||||
void terminal_restore_defaults(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)
|
||||
@@ -89,7 +90,6 @@ httpd_cgi_state screenSerializeToBuffer(char *buffer, size_t buf_len, void **dat
|
||||
|
||||
void screenSerializeLabelsToBuffer(char *buffer, size_t buf_len);
|
||||
|
||||
|
||||
typedef struct {
|
||||
u8 lsb;
|
||||
u8 msb;
|
||||
@@ -100,10 +100,8 @@ void encode2B(u16 number, WordB2 *stru);
|
||||
|
||||
/** Init the screen */
|
||||
void screen_init(void);
|
||||
|
||||
/** Change the screen size */
|
||||
void screen_resize(int rows, int cols);
|
||||
|
||||
/** Check if coord is valid */
|
||||
bool screen_isCoordValid(int y, int x);
|
||||
|
||||
@@ -111,48 +109,45 @@ bool screen_isCoordValid(int y, int x);
|
||||
|
||||
/** Screen reset to default state */
|
||||
void screen_reset(void);
|
||||
|
||||
/** Clear entire screen, set all to 7 on 0 */
|
||||
/** Clear entire screen */
|
||||
void screen_clear(ClearMode mode);
|
||||
|
||||
/** Line reset to gray-on-white, empty */
|
||||
/** Clear line */
|
||||
void screen_clear_line(ClearMode mode);
|
||||
|
||||
/** Clear part of line */
|
||||
void screen_clear_in_line(unsigned int count);
|
||||
/** Shift screen upwards */
|
||||
void screen_scroll_up(unsigned int lines);
|
||||
|
||||
/** Shift screen downwards */
|
||||
void screen_scroll_down(unsigned int lines);
|
||||
/** esc # 8 - fill entire screen with E of default colors */
|
||||
void screen_fill_with_E(void);
|
||||
|
||||
// --- insert / delete ---
|
||||
void screen_insert_lines(unsigned int lines);
|
||||
void screen_delete_lines(unsigned int lines);
|
||||
void screen_insert_characters(unsigned int count);
|
||||
void screen_delete_characters(unsigned int count);
|
||||
|
||||
// --- Cursor control ---
|
||||
|
||||
/** Set cursor position */
|
||||
void screen_cursor_set(int y, int x);
|
||||
|
||||
/** Read cursor pos to given vars */
|
||||
void screen_cursor_get(int *y, int *x);
|
||||
|
||||
/** Set cursor X position */
|
||||
void screen_cursor_set_x(int x);
|
||||
|
||||
/** Set cursor Y position */
|
||||
void screen_cursor_set_y(int y);
|
||||
|
||||
/** Reset cursor attribs */
|
||||
void screen_reset_cursor(void);
|
||||
|
||||
/** Relative cursor move */
|
||||
void screen_cursor_move(int dy, int dx);
|
||||
|
||||
void screen_cursor_move(int dy, int dx, bool scroll);
|
||||
/** Save the cursor pos */
|
||||
void screen_cursor_save(bool withAttrs);
|
||||
|
||||
/** Restore the cursor pos */
|
||||
void screen_cursor_restore(bool withAttrs);
|
||||
|
||||
/** Enable cursor display */
|
||||
void screen_cursor_enable(bool enable);
|
||||
|
||||
/** Enable auto wrap */
|
||||
void screen_wrap_enable(bool enable);
|
||||
|
||||
@@ -160,20 +155,15 @@ void screen_wrap_enable(bool enable);
|
||||
|
||||
/** Set cursor foreground color */
|
||||
void screen_set_fg(Color color);
|
||||
|
||||
/** Set cursor background coloor */
|
||||
void screen_set_bg(Color color);
|
||||
|
||||
/** make foreground bright */
|
||||
void screen_set_bold(bool bold);
|
||||
|
||||
/** Set cursor foreground and background color */
|
||||
void screen_set_colors(Color fg, Color bg);
|
||||
|
||||
/** Invert colors */
|
||||
void screen_inverse(bool inverse);
|
||||
|
||||
|
||||
/**
|
||||
* Set a character in the cursor color, move to right with wrap.
|
||||
* The character may be ASCII (then only one char is used), or
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#ifndef USER_MAIN_H_H
|
||||
#define USER_MAIN_H_H
|
||||
|
||||
#define FIRMWARE_VERSION "0.6.1+" GIT_HASH
|
||||
#define FIRMWARE_VERSION "0.6.4+" GIT_HASH
|
||||
#define TERMINAL_GITHUB_REPO "https://github.com/MightyPork/esp-vt100-firmware"
|
||||
|
||||
#endif //USER_MAIN_H_H
|
||||
|
||||
Reference in New Issue
Block a user