Compare commits

...
3 Commits
10 changed files with 113 additions and 28 deletions
+6 -3
View File
@@ -18,9 +18,12 @@
<ul>
<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>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.
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>
</div>
@@ -32,6 +35,7 @@
<li>The max screen size is 2000 characters (eg. <b>25x80</b>), default is <b>10x26</b>. Set using <code>\e]W&lt;rows&gt;;&lt;cols&gt;\a</code>.</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>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>
</ul>
</div>
@@ -104,7 +108,6 @@
<p>
<b>Mouse input</b> (click/tap) is sent as <code>\e[&lt;y&gt;;&lt;x&gt;M</code>. You can use this for on-screen buttons, menu navigation etc.
<i>Please note this is a custom escape sequence, not supported by PuTTY or other terminals.</i>
</p>
</div>
+11 -9
View File
@@ -896,7 +896,8 @@ $._loader = function(vis) {
var screen = [];
var blinkIval;
/** Clear screen */
/*
/!** Clear screen *!/
function cls() {
screen.forEach(function(cell, i) {
cell.t = ' ';
@@ -905,6 +906,7 @@ $._loader = function(vis) {
blit(cell);
});
}
*/
/** Set text and color at XY */
function cellAt(y, x) {
@@ -916,14 +918,15 @@ $._loader = function(vis) {
return cellAt(cursor.y, cursor.x);
}
/** Enable or disable cursor visibility */
/*
/!** Enable or disable cursor visibility *!/
function cursorEnable(enable) {
cursor.hidden = !enable;
cursor.a &= enable;
blit(cursorCell(), cursor.a);
}
/** Safely move cursor */
/!** Safely move cursor *!/
function cursorSet(y, x) {
// Hide and prevent from showing up during the move
cursor.suppress = true;
@@ -936,6 +939,7 @@ $._loader = function(vis) {
cursor.suppress = false;
blit(cursorCell(), cursor.a);
}
*/
/** Update cell on display. inv = invert (for cursor) */
function blit(cell, inv) {
@@ -1081,7 +1085,10 @@ $._loader = function(vis) {
}
function onClose(evt) {
console.error("SOCKET CLOSED");
console.warn("SOCKET CLOSED, code "+evt.code+". Reconnecting...");
setTimeout(function() {
init();
}, 2000);
}
function onMessage(evt) {
@@ -1094,10 +1101,6 @@ $._loader = function(vis) {
}
}
function onError(evt) {
console.error(evt.data);
}
function doSend(message) {
console.log("TX: ", message);
if (ws.readyState != 1) {
@@ -1115,7 +1118,6 @@ $._loader = function(vis) {
ws.onopen = onOpen;
ws.onclose = onClose;
ws.onmessage = onMessage;
ws.onerror = onError;
console.log("Opening socket.");
}
+4 -6
View File
@@ -197,7 +197,10 @@
}
function onClose(evt) {
console.error("SOCKET CLOSED");
console.warn("SOCKET CLOSED, code "+evt.code+". Reconnecting...");
setTimeout(function() {
init();
}, 1000);
}
function onMessage(evt) {
@@ -210,10 +213,6 @@
}
}
function onError(evt) {
console.error(evt.data);
}
function doSend(message) {
console.log("TX: ", message);
if (ws.readyState != 1) {
@@ -231,7 +230,6 @@
ws.onopen = onOpen;
ws.onclose = onClose;
ws.onmessage = onMessage;
ws.onerror = onError;
console.log("Opening socket.");
}
+2
View File
@@ -1,5 +1,7 @@
#!/bin/bash
echo "Packing js..."
cat jssrc/chibi.js \
jssrc/utils.js \
jssrc/modal.js \
+14
View File
@@ -5,6 +5,15 @@
<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">
<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">
<script src="/js/app.js"></script>
</head>
@@ -31,8 +40,13 @@
</nav>
<script>
try {
_root = window.location.host;
termInit(%screenData%);
} catch(e) {
console.error("Fail, reloading...");
location.reload(true);
}
</script>
</body>
+2 -2
View File
@@ -50,8 +50,8 @@
<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>
<b>If you lose access</b>, connect GPIO0 to GND for 5 seconds to enter Client+AP mode.
If that fails, try the UART factory reset command "<code>\e]FR\a</code>".
<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, hold the BOOT button for over 5 seconds (rapid Tx LED flashing) to perform a factory reset.
<p>
</td></tr>
</table>
+15 -3
View File
@@ -232,7 +232,9 @@ apars_handle_RESET_cmd(void)
void ICACHE_FLASH_ATTR
apars_handle_OSC_FactoryReset(void)
{
info("OSC: Factory reset");
warn("-------- Factory reset --------");
dbg("Switching to Client+AP mode");
// Send acknowledgement message to UART0
// User is performing this manually, so we can just print it as string
@@ -248,10 +250,12 @@ apars_handle_OSC_FactoryReset(void)
wifi_set_opmode(STATIONAP_MODE);
// --- AP config ---
dbg("AP WiFi channel: 6");
struct softap_config apconf;
wifi_softap_get_config(&apconf);
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
u8 mac[6];
@@ -259,7 +263,11 @@ apars_handle_OSC_FactoryReset(void)
sprintf((char*)apconf.ssid, "TERM-%02X%02X%02X", mac[3], mac[4], mac[5]);
apconf.ssid_len = (u8)strlen((char*)apconf.ssid);
info("New AP name: %s", (char*)apconf.ssid);
// --- Station ---
dbg("Erasing stored WiFi credentials...");
struct station_config staconf;
wifi_station_get_config(&staconf);
@@ -268,12 +276,16 @@ apars_handle_OSC_FactoryReset(void)
staconf.bssid_set=0;
staconf.password[0]=0;
dbg("Commiting changes...");
wifi_softap_set_config(&apconf);
wifi_station_set_config(&staconf);
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();
}
+46 -2
View File
@@ -10,6 +10,7 @@
#include <esp8266.h>
#include "ansi_parser_callbacks.h"
#define BTNGPIO 0
@@ -17,16 +18,59 @@
static bool enable_ap_button = false;
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 int resetCnt=0;
if (enable_ap_button && !GPIO_INPUT_GET(BTNGPIO)) {
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 {
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_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();
}
resetCnt=0;
+10
View File
@@ -25,6 +25,7 @@
#include "routes.h"
#include "user_main.h"
#include "uart_driver.h"
#include "ansi_parser_callbacks.h"
#ifdef ESPFS_POS
CgiUploadFlashDef uploadParams={
@@ -93,6 +94,15 @@ void ICACHE_FLASH_ATTR user_init(void)
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
// where image is written in flash that is defined in Makefile.
#ifdef ESPFS_POS
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef USER_MAIN_H_H
#define USER_MAIN_H_H
#define FIRMWARE_VERSION "0.5.2"
#define FIRMWARE_VERSION "0.5.5"
#define TERMINAL_GITHUB_REPO "https://github.com/MightyPork/esp-vt100-firmware"
#endif //USER_MAIN_H_H