Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab00467914 | ||
|
|
97044c2a17 | ||
|
|
8eb01a725b | ||
|
|
b074eb4f2c | ||
|
|
9dd5a1f082 | ||
|
|
e7c26b3e94 | ||
|
|
b6a0e796d8 | ||
|
|
29f726c073 |
@@ -748,7 +748,7 @@ input[type="number"], input[type="password"], input[type="text"], textarea, sele
|
|||||||
.ansiref.w100 {
|
.ansiref.w100 {
|
||||||
width: 100%; }
|
width: 100%; }
|
||||||
.ansiref.w100 td:nth-child(1) {
|
.ansiref.w100 td:nth-child(1) {
|
||||||
width: 7em; }
|
width: 9em; }
|
||||||
.ansiref.w100 td:nth-child(2) {
|
.ansiref.w100 td:nth-child(2) {
|
||||||
width: 8em; }
|
width: 8em; }
|
||||||
|
|
||||||
|
|||||||
+34
-21
@@ -18,9 +18,12 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li>Communication UART on pins <b>Rx, Tx</b> at 115200-8-1-N</li>
|
<li>Communication UART on pins <b>Rx, Tx</b> at 115200-8-1-N</li>
|
||||||
<li>Debug log on pin <b>GPIO2</b> at 115200-8-1-N</li>
|
<li>Debug log on pin <b>GPIO2</b> at 115200-8-1-N</li>
|
||||||
<li>Use 3.3V logic, or 5V with protection resistors (10k)</li>
|
<li>Use 3.3V logic, or 5V with protection resistors (470R or more)</li>
|
||||||
|
<li>If the "LVD" LED on the ESP Term board lights up, the module doesn't get enough power. Check your connections.</li>
|
||||||
<li>Connect Rx and Tx with a piece of wire to test the terminal alone, you should see what you type in the browser.
|
<li>Connect Rx and Tx with a piece of wire to test the terminal alone, you should see what you type in the browser.
|
||||||
NOTE: This won't work if your ESP8266 board has a built-in USB-serial.</li>
|
NOTE: This won't work if your ESP8266 board has a built-in USB-serial (like NodeMCU).</li>
|
||||||
|
<li>For best performance, use the module in the Client mode. In AP mode, check that the channel used is clear;
|
||||||
|
interference may cause lag in the terminal.</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -29,9 +32,10 @@
|
|||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>Most ANSI escape sequences are supported.</li>
|
<li>Most ANSI escape sequences are supported.</li>
|
||||||
<li>The max screen size is 2000 characters (eg. <b>25x80</b>), default is <b>10x26</b>. Set using <code>\e]W?;?\a</code> with rows;cols.</li>
|
<li>The max screen size is 2000 characters (eg. <b>25x80</b>), default is <b>10x26</b>. Set using <code>\e]W<rows>;<cols>\a</code>.</li>
|
||||||
<li>The screen will automatically scroll, can be used for log output.</li>
|
<li>The screen will automatically scroll, can be used for log output.</li>
|
||||||
<li>Display update is sent <b>after 20 ms of inactivity</b>.</li>
|
<li>Display update is sent <b>after 20 ms of inactivity</b>.</li>
|
||||||
|
<li>At most 4 clients can be connected at the same time.</li>
|
||||||
<li>The browser display needs WebSockets for the real-time updating. It may not work on really old phones / browsers.</li>
|
<li>The browser display needs WebSockets for the real-time updating. It may not work on really old phones / browsers.</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -39,7 +43,7 @@
|
|||||||
<div class="Box">
|
<div class="Box">
|
||||||
<h2>Color Reference</h2>
|
<h2>Color Reference</h2>
|
||||||
|
|
||||||
<p>Color is set using <code>\e[?m</code> or <code>\e[?;?m</code> where "?" are numbers from the following tables:</p>
|
<p>Color is set using <code>\e[<c>m</code> or <code>\e[<c>;<c>m</code> where "<c>" are numbers from the following tables:</p>
|
||||||
|
|
||||||
<b>Foreground</b>
|
<b>Foreground</b>
|
||||||
|
|
||||||
@@ -103,8 +107,7 @@
|
|||||||
<p>The buttons under the screen send ASCII codes 1, 2, 3, 4, 5.</p>
|
<p>The buttons under the screen send ASCII codes 1, 2, 3, 4, 5.</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<b>Mouse input</b> (click/tap) is sent as <code>\e?;?M</code> with row;column. You can use this for on-screen buttons, menu navigation etc.
|
<b>Mouse input</b> (click/tap) is sent as <code>\e[<y>;<x>M</code>. You can use this for on-screen buttons, menu navigation etc.
|
||||||
<i>Please note this is a custom sequence, not supported by PuTTY or other terminals.</i>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -167,42 +170,42 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>\e[?A</td>
|
<td>\e[<n>A</td>
|
||||||
<td>[count]</td>
|
<td>[count]</td>
|
||||||
<td>Move cursor up</td>
|
<td>Move cursor up</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>\e[?B</td>
|
<td>\e[<n>B</td>
|
||||||
<td>[count]</td>
|
<td>[count]</td>
|
||||||
<td>Move cursor down</td>
|
<td>Move cursor down</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>\e[?C</td>
|
<td>\e[<n>C</td>
|
||||||
<td>[count]</td>
|
<td>[count]</td>
|
||||||
<td>Move cursor forward (right)</td>
|
<td>Move cursor forward (right)</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>\e[?D</td>
|
<td>\e[<n>D</td>
|
||||||
<td>[count]</td>
|
<td>[count]</td>
|
||||||
<td>Move cursor backward (left)</td>
|
<td>Move cursor backward (left)</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>\e[?E</td>
|
<td>\e[<n>E</td>
|
||||||
<td>[count]</td>
|
<td>[count]</td>
|
||||||
<td>Go N line down, start of line</td>
|
<td>Go N line down, start of line</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>\e[?F</td>
|
<td>\e[<n>F</td>
|
||||||
<td>[count]</td>
|
<td>[count]</td>
|
||||||
<td>Go N lines up, start of line</td>
|
<td>Go N lines up, start of line</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>\e[?G</td>
|
<td>\e[<n>G</td>
|
||||||
<td>column</td>
|
<td>column</td>
|
||||||
<td>Go to column</td>
|
<td>Go to column</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>\e[?;?G</td>
|
<td>\e[<y>;<x>G</td>
|
||||||
<td>[row=1];[col=1]</td>
|
<td>[row=1];[col=1]</td>
|
||||||
<td>Go to row and column</td>
|
<td>Go to row and column</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -234,12 +237,22 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>\e[?25l</td>
|
<td>\e[?25l</td>
|
||||||
<td>--</td>
|
<td>--</td>
|
||||||
<td>Hide cursor (literal question mark, lowercase L!)</td>
|
<td>Hide cursor</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>\e[?25h</td>
|
<td>\e[?25h</td>
|
||||||
<td>--</td>
|
<td>--</td>
|
||||||
<td>Show cursor (literal question mark!)</td>
|
<td>Show cursor</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>\e[?7l</td>
|
||||||
|
<td>--</td>
|
||||||
|
<td>Disable cursor auto-wrap & auto-scroll at end of screen</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>\e[?7h</td>
|
||||||
|
<td>--</td>
|
||||||
|
<td>Enable cursor auto-wrap & auto-scroll at end of screen</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -256,27 +269,27 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>\e[?J</td>
|
<td>\e[<m>J</td>
|
||||||
<td>[mode=0]</td>
|
<td>[mode=0]</td>
|
||||||
<td>Clear screen. Mode: 0 - from cursor, 1 - to cursor, 2 - all</td>
|
<td>Clear screen. Mode: 0 - from cursor, 1 - to cursor, 2 - all</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>\e[?K</td>
|
<td>\e[<m>K</td>
|
||||||
<td>[mode=0]</td>
|
<td>[mode=0]</td>
|
||||||
<td>Erase line. Mode: 0 - from cursor, 1 - to cursor, 2 - all</td>
|
<td>Erase line. Mode: 0 - from cursor, 1 - to cursor, 2 - all</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>\e[?S</td>
|
<td>\e[<n>S</td>
|
||||||
<td>[lines]</td>
|
<td>[lines]</td>
|
||||||
<td>Scroll screen content up, add empty line at the bottom</td>
|
<td>Scroll screen content up, add empty line at the bottom</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>\e[?T</td>
|
<td>\e[<n>T</td>
|
||||||
<td>[lines]</td>
|
<td>[lines]</td>
|
||||||
<td>Scroll screen content down, add empty line at the top</td>
|
<td>Scroll screen content down, add empty line at the top</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>\e]W?;?\a</td>
|
<td>\e]W<r>;<c>\a</td>
|
||||||
<td>rows;cols</td>
|
<td>rows;cols</td>
|
||||||
<td>Set screen size, maximum 25x80 (resp. total 2000 characters). This also clears the screen.</td>
|
<td>Set screen size, maximum 25x80 (resp. total 2000 characters). This also clears the screen.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
+11
-9
@@ -896,7 +896,8 @@ $._loader = function(vis) {
|
|||||||
var screen = [];
|
var screen = [];
|
||||||
var blinkIval;
|
var blinkIval;
|
||||||
|
|
||||||
/** Clear screen */
|
/*
|
||||||
|
/!** Clear screen *!/
|
||||||
function cls() {
|
function cls() {
|
||||||
screen.forEach(function(cell, i) {
|
screen.forEach(function(cell, i) {
|
||||||
cell.t = ' ';
|
cell.t = ' ';
|
||||||
@@ -905,6 +906,7 @@ $._loader = function(vis) {
|
|||||||
blit(cell);
|
blit(cell);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/** Set text and color at XY */
|
/** Set text and color at XY */
|
||||||
function cellAt(y, x) {
|
function cellAt(y, x) {
|
||||||
@@ -916,14 +918,15 @@ $._loader = function(vis) {
|
|||||||
return cellAt(cursor.y, cursor.x);
|
return cellAt(cursor.y, cursor.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Enable or disable cursor visibility */
|
/*
|
||||||
|
/!** Enable or disable cursor visibility *!/
|
||||||
function cursorEnable(enable) {
|
function cursorEnable(enable) {
|
||||||
cursor.hidden = !enable;
|
cursor.hidden = !enable;
|
||||||
cursor.a &= enable;
|
cursor.a &= enable;
|
||||||
blit(cursorCell(), cursor.a);
|
blit(cursorCell(), cursor.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Safely move cursor */
|
/!** Safely move cursor *!/
|
||||||
function cursorSet(y, x) {
|
function cursorSet(y, x) {
|
||||||
// Hide and prevent from showing up during the move
|
// Hide and prevent from showing up during the move
|
||||||
cursor.suppress = true;
|
cursor.suppress = true;
|
||||||
@@ -936,6 +939,7 @@ $._loader = function(vis) {
|
|||||||
cursor.suppress = false;
|
cursor.suppress = false;
|
||||||
blit(cursorCell(), cursor.a);
|
blit(cursorCell(), cursor.a);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/** Update cell on display. inv = invert (for cursor) */
|
/** Update cell on display. inv = invert (for cursor) */
|
||||||
function blit(cell, inv) {
|
function blit(cell, inv) {
|
||||||
@@ -1081,7 +1085,10 @@ $._loader = function(vis) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onClose(evt) {
|
function onClose(evt) {
|
||||||
console.error("SOCKET CLOSED");
|
console.warn("SOCKET CLOSED, code "+evt.code+". Reconnecting...");
|
||||||
|
setTimeout(function() {
|
||||||
|
init();
|
||||||
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMessage(evt) {
|
function onMessage(evt) {
|
||||||
@@ -1094,10 +1101,6 @@ $._loader = function(vis) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onError(evt) {
|
|
||||||
console.error(evt.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
function doSend(message) {
|
function doSend(message) {
|
||||||
console.log("TX: ", message);
|
console.log("TX: ", message);
|
||||||
if (ws.readyState != 1) {
|
if (ws.readyState != 1) {
|
||||||
@@ -1115,7 +1118,6 @@ $._loader = function(vis) {
|
|||||||
ws.onopen = onOpen;
|
ws.onopen = onOpen;
|
||||||
ws.onclose = onClose;
|
ws.onclose = onClose;
|
||||||
ws.onmessage = onMessage;
|
ws.onmessage = onMessage;
|
||||||
ws.onerror = onError;
|
|
||||||
|
|
||||||
console.log("Opening socket.");
|
console.log("Opening socket.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,7 +197,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onClose(evt) {
|
function onClose(evt) {
|
||||||
console.error("SOCKET CLOSED");
|
console.warn("SOCKET CLOSED, code "+evt.code+". Reconnecting...");
|
||||||
|
setTimeout(function() {
|
||||||
|
init();
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMessage(evt) {
|
function onMessage(evt) {
|
||||||
@@ -210,10 +213,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onError(evt) {
|
|
||||||
console.error(evt.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
function doSend(message) {
|
function doSend(message) {
|
||||||
console.log("TX: ", message);
|
console.log("TX: ", message);
|
||||||
if (ws.readyState != 1) {
|
if (ws.readyState != 1) {
|
||||||
@@ -231,7 +230,6 @@
|
|||||||
ws.onopen = onOpen;
|
ws.onopen = onOpen;
|
||||||
ws.onclose = onClose;
|
ws.onclose = onClose;
|
||||||
ws.onmessage = onMessage;
|
ws.onmessage = onMessage;
|
||||||
ws.onerror = onError;
|
|
||||||
|
|
||||||
console.log("Opening socket.");
|
console.log("Opening socket.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Packing js..."
|
||||||
|
|
||||||
cat jssrc/chibi.js \
|
cat jssrc/chibi.js \
|
||||||
jssrc/utils.js \
|
jssrc/utils.js \
|
||||||
jssrc/modal.js \
|
jssrc/modal.js \
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
td:nth-child(1) {
|
td:nth-child(1) {
|
||||||
width: 7em;
|
width: 9em;
|
||||||
}
|
}
|
||||||
|
|
||||||
td:nth-child(2) {
|
td:nth-child(2) {
|
||||||
|
|||||||
@@ -5,6 +5,15 @@
|
|||||||
<title>ESP8266 Remote Terminal</title>
|
<title>ESP8266 Remote Terminal</title>
|
||||||
<meta name="viewport" content="width=device-width,shrink-to-fit=no,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0">
|
<meta name="viewport" content="width=device-width,shrink-to-fit=no,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0">
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// Workaround for badly loaded page
|
||||||
|
setTimeout(function() {
|
||||||
|
if (typeof termInit == 'undefined' || typeof $ == 'undefined') {
|
||||||
|
location.reload(true);
|
||||||
|
}
|
||||||
|
}, 2000);
|
||||||
|
</script>
|
||||||
|
|
||||||
<link rel="stylesheet" href="/css/app.css">
|
<link rel="stylesheet" href="/css/app.css">
|
||||||
<script src="/js/app.js"></script>
|
<script src="/js/app.js"></script>
|
||||||
</head>
|
</head>
|
||||||
@@ -31,8 +40,13 @@
|
|||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
try {
|
||||||
_root = window.location.host;
|
_root = window.location.host;
|
||||||
termInit(%screenData%);
|
termInit(%screenData%);
|
||||||
|
} catch(e) {
|
||||||
|
console.error("Fail, reloading...");
|
||||||
|
location.reload(true);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
+2
-2
@@ -50,8 +50,8 @@
|
|||||||
<tr><td colspan=2 style="white-space: normal;">
|
<tr><td colspan=2 style="white-space: normal;">
|
||||||
<p>Some changes require a reboot, dropping connection. It can take a while to re-connect.</p>
|
<p>Some changes require a reboot, dropping connection. It can take a while to re-connect.</p>
|
||||||
<p>
|
<p>
|
||||||
<b>If you lose access</b>, connect GPIO0 to GND for 5 seconds to enter Client+AP mode.
|
<b>If you lose access</b>, hold the BOOT button for 2 seconds (the Tx LED starts blinking) to re-enable AP mode.
|
||||||
If that fails, try the UART factory reset command "<code>\e]FR\a</code>".
|
If that fails, hold the BOOT button for over 5 seconds (rapid Tx LED flashing) to perform a factory reset.
|
||||||
<p>
|
<p>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -138,7 +138,6 @@ apars_handle_CSI(char leadchar, int *params, char keychar)
|
|||||||
screen_clear_line(CLEAR_FROM_CURSOR);
|
screen_clear_line(CLEAR_FROM_CURSOR);
|
||||||
} else {
|
} else {
|
||||||
screen_clear_line(CLEAR_ALL);
|
screen_clear_line(CLEAR_ALL);
|
||||||
screen_cursor_set_x(0);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -157,20 +156,29 @@ apars_handle_CSI(char leadchar, int *params, char keychar)
|
|||||||
}
|
}
|
||||||
else if (n1 == 5) {
|
else if (n1 == 5) {
|
||||||
// Query device status - reply "Device is OK"
|
// Query device status - reply "Device is OK"
|
||||||
UART_WriteString(UART0, "\0330n", UART_TIMEOUT_US);
|
UART_WriteString(UART0, "\033[0n", UART_TIMEOUT_US);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// DECTCEM cursor show hide
|
// DECTCEM feature enable / disable
|
||||||
case 'l':
|
|
||||||
if (leadchar == '?' && n1 == 25) {
|
|
||||||
screen_cursor_enable(1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
if (leadchar == '?' && n1 == 25) {
|
if (leadchar == '?') {
|
||||||
|
if (n1 == 25) {
|
||||||
|
screen_cursor_enable(1);
|
||||||
|
} else if (n1 == 7) {
|
||||||
|
screen_wrap_enable(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'l':
|
||||||
|
if (leadchar == '?') {
|
||||||
|
if (n1 == 25) {
|
||||||
screen_cursor_enable(0);
|
screen_cursor_enable(0);
|
||||||
|
} else if (n1 == 7) {
|
||||||
|
screen_wrap_enable(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -224,7 +232,9 @@ apars_handle_RESET_cmd(void)
|
|||||||
void ICACHE_FLASH_ATTR
|
void ICACHE_FLASH_ATTR
|
||||||
apars_handle_OSC_FactoryReset(void)
|
apars_handle_OSC_FactoryReset(void)
|
||||||
{
|
{
|
||||||
info("OSC: Factory reset");
|
warn("-------- Factory reset --------");
|
||||||
|
|
||||||
|
dbg("Switching to Client+AP mode");
|
||||||
|
|
||||||
// Send acknowledgement message to UART0
|
// Send acknowledgement message to UART0
|
||||||
// User is performing this manually, so we can just print it as string
|
// User is performing this manually, so we can just print it as string
|
||||||
@@ -240,10 +250,12 @@ apars_handle_OSC_FactoryReset(void)
|
|||||||
wifi_set_opmode(STATIONAP_MODE);
|
wifi_set_opmode(STATIONAP_MODE);
|
||||||
|
|
||||||
// --- AP config ---
|
// --- AP config ---
|
||||||
|
dbg("AP WiFi channel: 6");
|
||||||
|
|
||||||
struct softap_config apconf;
|
struct softap_config apconf;
|
||||||
wifi_softap_get_config(&apconf);
|
wifi_softap_get_config(&apconf);
|
||||||
apconf.authmode=AUTH_OPEN; // Disable access protection
|
apconf.authmode=AUTH_OPEN; // Disable access protection
|
||||||
apconf.channel=1; // Reset channel; user may have set bad channel in the UI
|
apconf.channel=6; // Reset channel; user may have set bad channel in the UI
|
||||||
|
|
||||||
// generate unique AP name
|
// generate unique AP name
|
||||||
u8 mac[6];
|
u8 mac[6];
|
||||||
@@ -251,7 +263,11 @@ apars_handle_OSC_FactoryReset(void)
|
|||||||
sprintf((char*)apconf.ssid, "TERM-%02X%02X%02X", mac[3], mac[4], mac[5]);
|
sprintf((char*)apconf.ssid, "TERM-%02X%02X%02X", mac[3], mac[4], mac[5]);
|
||||||
apconf.ssid_len = (u8)strlen((char*)apconf.ssid);
|
apconf.ssid_len = (u8)strlen((char*)apconf.ssid);
|
||||||
|
|
||||||
|
info("New AP name: %s", (char*)apconf.ssid);
|
||||||
|
|
||||||
// --- Station ---
|
// --- Station ---
|
||||||
|
dbg("Erasing stored WiFi credentials...");
|
||||||
|
|
||||||
struct station_config staconf;
|
struct station_config staconf;
|
||||||
wifi_station_get_config(&staconf);
|
wifi_station_get_config(&staconf);
|
||||||
|
|
||||||
@@ -260,12 +276,16 @@ apars_handle_OSC_FactoryReset(void)
|
|||||||
staconf.bssid_set=0;
|
staconf.bssid_set=0;
|
||||||
staconf.password[0]=0;
|
staconf.password[0]=0;
|
||||||
|
|
||||||
|
dbg("Commiting changes...");
|
||||||
wifi_softap_set_config(&apconf);
|
wifi_softap_set_config(&apconf);
|
||||||
wifi_station_set_config(&staconf);
|
wifi_station_set_config(&staconf);
|
||||||
|
|
||||||
UART_WriteString(UART0, "Factory Reset complete, device reset.\r\n\r\n", UART_TIMEOUT_US);
|
UART_WriteString(UART0, "Factory Reset complete, device reset.\r\n\r\n", UART_TIMEOUT_US);
|
||||||
|
|
||||||
// Reboot to clean STA+AP mode with Channel 1 & reset AP SSID.
|
info("*** FACTORY RESET COMPLETE ***");
|
||||||
|
dbg("Device reset...");
|
||||||
|
|
||||||
|
// Reboot to clean STA+AP mode with Channel X & reset AP SSID.
|
||||||
system_restart();
|
system_restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <esp8266.h>
|
#include <esp8266.h>
|
||||||
|
#include "ansi_parser_callbacks.h"
|
||||||
|
|
||||||
#define BTNGPIO 0
|
#define BTNGPIO 0
|
||||||
|
|
||||||
@@ -17,16 +18,59 @@
|
|||||||
static bool enable_ap_button = false;
|
static bool enable_ap_button = false;
|
||||||
|
|
||||||
static ETSTimer resetBtntimer;
|
static ETSTimer resetBtntimer;
|
||||||
|
static ETSTimer blinkyTimer;
|
||||||
|
|
||||||
|
static void ICACHE_FLASH_ATTR bootHoldIndicatorTimerCb(void *arg) {
|
||||||
|
static bool state = true;
|
||||||
|
|
||||||
|
if (GPIO_INPUT_GET(BTNGPIO)) {
|
||||||
|
// if user released, shut up
|
||||||
|
state = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state) {
|
||||||
|
GPIO_OUTPUT_SET(1, 1);
|
||||||
|
} else {
|
||||||
|
GPIO_OUTPUT_SET(1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
state = !state;
|
||||||
|
}
|
||||||
|
|
||||||
static void ICACHE_FLASH_ATTR resetBtnTimerCb(void *arg) {
|
static void ICACHE_FLASH_ATTR resetBtnTimerCb(void *arg) {
|
||||||
static int resetCnt=0;
|
static int resetCnt=0;
|
||||||
if (enable_ap_button && !GPIO_INPUT_GET(BTNGPIO)) {
|
if (enable_ap_button && !GPIO_INPUT_GET(BTNGPIO)) {
|
||||||
resetCnt++;
|
resetCnt++;
|
||||||
|
|
||||||
|
// indicating AP reset
|
||||||
|
if (resetCnt == 2) {
|
||||||
|
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_GPIO1);
|
||||||
|
GPIO_OUTPUT_SET(1, 0); // GPIO 1 OFF
|
||||||
|
|
||||||
|
os_timer_disarm(&blinkyTimer);
|
||||||
|
os_timer_setfn(&blinkyTimer, bootHoldIndicatorTimerCb, NULL);
|
||||||
|
os_timer_arm(&blinkyTimer, 500, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// indicating we'll perform a factory reset
|
||||||
|
if (resetCnt == 10) {
|
||||||
|
os_timer_disarm(&blinkyTimer);
|
||||||
|
os_timer_setfn(&blinkyTimer, bootHoldIndicatorTimerCb, NULL);
|
||||||
|
os_timer_arm(&blinkyTimer, 100, 1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (resetCnt>=6) { //3 sec pressed
|
// Switch Tx back to UART pin, so we can print our farewells
|
||||||
|
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD);
|
||||||
|
|
||||||
|
if (resetCnt>=10) { //5 secs pressed - FR
|
||||||
|
info("BOOT-button triggered FACTORY RESET!");
|
||||||
|
apars_handle_OSC_FactoryReset();
|
||||||
|
}
|
||||||
|
else if (resetCnt>=2) { //1 sec pressed
|
||||||
wifi_station_disconnect();
|
wifi_station_disconnect();
|
||||||
wifi_set_opmode(STATIONAP_MODE); //reset to AP+STA mode
|
wifi_set_opmode(STATIONAP_MODE); //reset to AP+STA mode
|
||||||
info("Reset to AP mode from GPIO0, Restarting system...");
|
info("BOOT-button triggered reset to AP mode, restarting...");
|
||||||
|
|
||||||
system_restart();
|
system_restart();
|
||||||
}
|
}
|
||||||
resetCnt=0;
|
resetCnt=0;
|
||||||
|
|||||||
+20
-3
@@ -31,6 +31,7 @@ static struct {
|
|||||||
int y; //!< Y coordinate
|
int y; //!< Y coordinate
|
||||||
bool visible; //!< Visible
|
bool visible; //!< Visible
|
||||||
bool inverse; //!< Inverse colors
|
bool inverse; //!< Inverse colors
|
||||||
|
bool autowrap; //!< Wrapping when EOL
|
||||||
Color fg; //!< Foreground color for writing
|
Color fg; //!< Foreground color for writing
|
||||||
Color bg; //!< Background color for writing
|
Color bg; //!< Background color for writing
|
||||||
} cursor;
|
} cursor;
|
||||||
@@ -102,6 +103,7 @@ cursor_reset(void)
|
|||||||
cursor.bg = SCREEN_DEF_BG;
|
cursor.bg = SCREEN_DEF_BG;
|
||||||
cursor.visible = 1;
|
cursor.visible = 1;
|
||||||
cursor.inverse = 0;
|
cursor.inverse = 0;
|
||||||
|
cursor.autowrap = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
@@ -397,6 +399,17 @@ screen_cursor_enable(bool enable)
|
|||||||
NOTIFY_DONE();
|
NOTIFY_DONE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable autowrap
|
||||||
|
*/
|
||||||
|
void ICACHE_FLASH_ATTR
|
||||||
|
screen_wrap_enable(bool enable)
|
||||||
|
{
|
||||||
|
NOTIFY_LOCK();
|
||||||
|
cursor.autowrap = enable;
|
||||||
|
NOTIFY_DONE();
|
||||||
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
//region Colors
|
//region Colors
|
||||||
@@ -492,7 +505,7 @@ screen_putchar(char ch)
|
|||||||
cursor.x--;
|
cursor.x--;
|
||||||
} else {
|
} else {
|
||||||
// wrap around start of line
|
// wrap around start of line
|
||||||
if (cursor.y>0) {
|
if (cursor.autowrap && cursor.y>0) {
|
||||||
cursor.x=W-1;
|
cursor.x=W-1;
|
||||||
cursor.y--;
|
cursor.y--;
|
||||||
}
|
}
|
||||||
@@ -532,13 +545,17 @@ screen_putchar(char ch)
|
|||||||
cursor.x++;
|
cursor.x++;
|
||||||
// X wrap
|
// X wrap
|
||||||
if (cursor.x >= W) {
|
if (cursor.x >= W) {
|
||||||
|
if (cursor.autowrap) {
|
||||||
cursor.x = 0;
|
cursor.x = 0;
|
||||||
cursor.y++;
|
cursor.y++;
|
||||||
// Y wrap
|
// Y wrap
|
||||||
if (cursor.y > H-1) {
|
if (cursor.y > H - 1) {
|
||||||
// Scroll up, so we have space for writing
|
// Scroll up, so we have space for writing
|
||||||
screen_scroll_up(1);
|
screen_scroll_up(1);
|
||||||
cursor.y = H-1;
|
cursor.y = H - 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cursor.x = W - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,6 +109,9 @@ void screen_cursor_restore(bool withAttrs);
|
|||||||
/** Enable cursor display */
|
/** Enable cursor display */
|
||||||
void screen_cursor_enable(bool enable);
|
void screen_cursor_enable(bool enable);
|
||||||
|
|
||||||
|
/** Enable auto wrap */
|
||||||
|
void screen_wrap_enable(bool enable);
|
||||||
|
|
||||||
// --- Colors ---
|
// --- Colors ---
|
||||||
|
|
||||||
/** Set cursor foreground color */
|
/** Set cursor foreground color */
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "routes.h"
|
#include "routes.h"
|
||||||
#include "user_main.h"
|
#include "user_main.h"
|
||||||
|
#include "uart_driver.h"
|
||||||
|
#include "ansi_parser_callbacks.h"
|
||||||
|
|
||||||
#ifdef ESPFS_POS
|
#ifdef ESPFS_POS
|
||||||
CgiUploadFlashDef uploadParams={
|
CgiUploadFlashDef uploadParams={
|
||||||
@@ -92,6 +94,15 @@ void ICACHE_FLASH_ATTR user_init(void)
|
|||||||
|
|
||||||
ioInit();
|
ioInit();
|
||||||
|
|
||||||
|
// Change AP name if AI-THINKER found (means un-initialized device)
|
||||||
|
struct softap_config apconf;
|
||||||
|
wifi_softap_get_config(&apconf);
|
||||||
|
if (strstarts((char*)apconf.ssid, "AI-THINKER")) {
|
||||||
|
warn("Un-initialized device, performing factory reset.");
|
||||||
|
apars_handle_OSC_FactoryReset();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 0x40200000 is the base address for spi flash memory mapping, ESPFS_POS is the position
|
// 0x40200000 is the base address for spi flash memory mapping, ESPFS_POS is the position
|
||||||
// where image is written in flash that is defined in Makefile.
|
// where image is written in flash that is defined in Makefile.
|
||||||
#ifdef ESPFS_POS
|
#ifdef ESPFS_POS
|
||||||
@@ -114,6 +125,10 @@ void ICACHE_FLASH_ATTR user_init(void)
|
|||||||
// The terminal screen
|
// The terminal screen
|
||||||
screen_init();
|
screen_init();
|
||||||
|
|
||||||
|
// Print the CANCEL character to indicate the module has restarted
|
||||||
|
// Critically important for client application if any kind of screen persistence / content re-use is needed
|
||||||
|
UART_WriteChar(UART0, 24, UART_TIMEOUT_US); // 0x18 - 24 - CAN
|
||||||
|
|
||||||
info("Listening on UART0, 115200-8-N-1!");
|
info("Listening on UART0, 115200-8-N-1!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+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.5"
|
#define FIRMWARE_VERSION "0.5.5"
|
||||||
#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