Giter VIP home page Giter VIP logo

espterm-firmware's Introduction

ESPTerm

ESPTerm is a VT100-like terminal emulator running on the ESP8266 WiFi chip.

Photo
Fig 1: Breadboard adapter developed for ESPTerm

ESPTerm passes most of VTTEST test cases, making it functionally comparable to eg. gnome-terminal, terminator, konsole, GtkTerm or PuTTY. ESPTerm is capable of running Midnight Commander through agetty, including full mouse support, provided agetty is made to believe it's Xterm, which shows ESPTerm is compatible with ncurses.

In addition to control sequences that manipulate the terminal or user input, there is a set of simple networking commands for device-to-device message exchange and interacting with remote servers.

To see what escape sequences are supported, check out this annotated Xterm manual page which was used for reference, or the built-in help page (online demo)

The terminal screen can be accessed using any web browser, even on a phone or tablet. It works with ESP-01, ESP-01S, ESP-12 and likely many other modules.

With ESPTerm, you can add remote access via WiFi to any embeded project, all you need is UART and some imagination!

Try it online

You can try the web user interface here: espterm.github.io

The demo is almost identical to the real thing, except, of course, it doesn't do much without the emulator backend that runs on the ESP8266. The web version will be updated to match this repository after each minor release (and sometimes in between for testing; the version currently being show-cased can be read on the About page of the demo).

Browser support

Use the above linked online demo to verify compatibility with your browser.

To our knowledge, ESPTerm works with:

  • Google Chrome (desktop, mobile)
  • Firefox (desktop, mobile not tested)
  • Safari (desktop, mobile)
  • Chromium
  • Opera
  • Brave
  • Konqueror

It does not work with:

  • Microsoft Edge - runs, but is extremely laggy
  • Internet Explorer (any version) - crashes, missing JS features
  • Opera Mini - crashes, missing JS and CSS features
  • Blackberry browser - not tested, but unlikely
  • Safari on old iOS versions - missing features
  • WebOS browser
  • Old Android Browser (before 4.4?) - not tested, likely missing JS features

Main features

  • Almost complete VT102 emulation with some extras from Xterm, eg.
    • Screen size up to 80x25 (the limit can be modified when compiling from source)
    • All standard text styles and 16 colors supported
    • Full UTF-8 support, alternate character sets
    • Standard mouse tracking modes
    • You can dynamically set screen title, button labels...
  • Networking commands
    • Command for sending a message to another ESPTerm
    • API endpoint (/api/v1/msg) for receiving messages sent e.g. from a script on PC, web browser or CURL
    • Command for requesting remote servers and getting back response headers and/or body
  • Web Terminal Interface
    • Real-time screen update via WebSocket
    • Mouse and keyboard input, works also on mobile
    • 5 optional buttons for quick commands
    • Text file upload tool with adjustable delays and line endings
    • Built-in help page (demo) with basic troubleshooting and command reference
  • User-friendly comprehensive WiFi configuration (Demo: WiFi, network config)
    • Static IP, DHCP, channel selection, power
    • SSID search utility for finding your existing network
  • Basic security features
    • Possibility to password-lock parts of the web interface
    • Admin password for some sensitive operations (can be changed!)
    • Configurable AP password & Hidden attribute
  • Advanced settings storage
    • Stored in Flash
    • Seamlesly updated and usually backwards compatible in minor releases
    • Settings can be saved as defaults and later easily restored (ideal e.g. for classroom use, saving
      good tested settings before giving the module to students)

Bugs? Ideas?

To ask any questions or discuss new features you'd like to see added, it's best to use the ESPTerm Dev mailing list

Subscribe to the mailing list to also receive new release announcements.

If you found a bug (that happens alot!), please submit it to our bug tracker. We also use it to track planned ideas. If you don't want to create a GitHub account for that, just send it to the mailing list.

Running ESPTerm

To run ESPTerm on your ESP8266, either build it yourself from source using xtensa-lx106-elf-gcc (and the included Makefile), or download pre-built binaries from the GitHub releases section. Flash the binaries using esptool.

Pins

  • Pin GPIO2 is used for debug messages at 115200 baud, 8 bit, no parity.
  • Pins Rx and Tx are used for the main communication UART, parameters of which can be set on the system config page. Connect your USB-serial dongle or application microcontroller here.

Setup

  • When flashed for the first time, ESPTerm wipes any possible previous WiFi configuration, because it implements its own WiFi config manager with many additional features.
  • It should start in AP mode, the default SSID being TERM-MACADR with MACADR being three unique bytes from the MAC address / Device ID as ASCII hex.
  • Connect to the AP via a smartphone or laptop and configure WiFi as desired. If a captive portal page does not open, try 192.168.4.1 in your web browser.

Rescue from messed up config

It can happen that some changes to the WiFi or network config make the module inaccessible.

  • To re-enable the built-in AP, hold the BOOT (GPIO0 -> GND) button for about 1 s, until the blue LED starts flashing. Then quickly release the button.
  • To reset all settings to defaults, hold the button a couple seconds until the LED flashes rapidly, then release it.
  • You can cancel this wipe/reset operation (when triggered by accident) by pressing Reset or disconnecting the power supply.

Config banks

ESPTerm has two config "files", one for defaults and one for the currently used settings. In the case of the terminal config, there is also a third, temporary file for changes done via ESC commands.

When you get your settings just right, you can store them as defaults, which can then be at any time restored by holding the BOOT (GPIO0) button. You can do this on the System Settings page. This asks for an "admin password", which can (and should!) be changed. This password can't be easily recovered when forgotten.

You can also restore everything (except the saved defaults) to "factory defaults", there is a button for this on the System Settings page. Those are the initial values you would get after a clean install.

Research resources

Developing the terminal emulator was complicated by the information being scattered across many places and the existing implementations I used for reference often got some details wrong or didn't implement certain features at all. Xterm proved to be by far the most complete implementation.

A great tool for checking my code has proven to be VTTTEST. ESPTerm passes most of the tests on the main page and some additional Xterm specific ones, like Mouse Tracking.

Here is a list of useful VT100 emulation resources I've collected for reference.

Development

ESPTerm's firmware is written in C and is based on SpriteTM's libesphttpd http server library forked to MightyPork/libesphttpd. This fork includes various improvements and changes required by the project.

Installation for development

  • Clone this project with --recursive, or afterwards run git submodule init and git submodule update.
  • Install esp-open-sdk and build it with make toolchain esptool libhal STANDALONE=n. Make sure the xtensa-lx106-elf/bin folder is on $PATH.
  • Install esptool (it's in the Arch community repo and on AUR, too)
  • Set up udev rules so you have access to ttyUSB0 without root, eg:
    KERNEL=="tty[A-Z]*[0-9]*", GROUP="uucp", MODE="0666"
    
  • Install Ragel if you wish to make modifications to the ANSI sequence parser. If not, comment out its call in build_parser.sh. The .rl file is the actual source, the .c is generated.
  • Install dependencies of the front-end submodule (yarn install in the front-end folder, installed PHP)
  • Make sure your esphttpdconfig.mk is set up properly - link to the SDK etc.

The IoT SDK is now included in the project due to problems with obtaining the correct version and patching it. It works with version 1.5.2, any newer seems to be incompatible. If you get it working with a newer SDK, a PR is more than welcome!

Web resources

The web resources are in the front-end git submodule. To prepare the web resources for a build, run make web. The resulting files are copied to html/. The html/ folder is then embedded in the firmware image.

It's kind of tricky to develop the web resources locally; you might want to try the "split image" Makefile option, then you can flash just the html portion with make htmlflash. I haven't tried this.

For local development, use the server.sh script in html_orig (more details in the front-end repo's readme). It's possible to talk to the API endpoints of a running ESP8266 from a page served by your local server if you configure _env.php with its IP.

Flashing

The Makefile should automatically build the parser and web resources for you when you run make. The web resources are normally no re-built, because the build process is quite slow. To manually rebuild them, run make web before make.

To flash, just run make flash. It will use parameters you setup in the esphttpdconfig.mk file.

espterm-firmware's People

Contributors

billprozac avatar bjpirt avatar cpsdqs avatar dzindra avatar jkent avatar mightypork avatar schneemaier avatar spritetm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

espterm-firmware's Issues

New wifi config options with persistence

Implemented, but not exposed outside atm:

  • transmit power
  • static IP, mask, gw
  • own IP, mask, gw in AP mode
  • own hidden AP
  • own AP password (WPA2 PSK)
  • hostname (does not seem to have any effect, maybe not that useful)

TODO:

This all must be stored to flash via persistence and loaded on startup.
some things like rf power and static IP are not stored by ESP, so for simplicity we wont store anything natively.

This also allows to have the entire config in one place for the "factory reset" functionality and loading defaults.

image background

Default image background, a color, or from a local server (configured URL)

nice to have, low priority

Static IP configuration

Option to disable DHCP and set static IP, mask.

This needs to be implemented as part of the libesphttpd fork.

Add proper documentation

Easy to understand (latex generated PDF or a page?) explaining how to get started and use it as a complete module

Automatic parser reset after a no-input timeout

make it so ragel resets after some time from last received char.

this will prevent it getting stuck in the middle of a sequence and losing following data

it's a similar feature to the reset timeout in TinyFrame.

peer-to-peer communication (telnet or UDP packets)

GET API variant:

eg.

A (192.168.12.1) talking to B (192.168.12.2)

  • uC A sends to ESP(a):

    \e^S,192.168.12.2,Message Text\a

  • ESP(a) sends a request to ESP(b), eg

    192.168.12.2/api/msg?t=Message%20Text

  • ESP(b) sends to uC B:

    \e^R,192.168.12.1,Message Text\a

Default screen size configuration

Make it possible to configure a default screen size.
Use the flash storage functions for this, possibly will need a new page "terminal config".

configurable password to protect the settings pages

I'm not yet sure how to implement this to work nicely with the dual settings store we have now.

Who can change it? How to clear it if it's forgotten? Should holding the boot button instead of defaults reset to factory settings?

this depends on #99

Add buffering for input stream and screen updates

Currently each character is sent to the parser state machine individually and each access to the screen generates an individual screen update event (and a socket broadcast).

This is wasteful.

We can buffer those for some time and then process sequentially. That could be done with a buffer, and trigger the event / parser when

(a) some time passes (20 ms?)
(b) the buffer is full

The ESP is fast so this is not really a big deal and can be left as is, but we can do better

Add UTF-8 support (line drawing characters, °C, etc)

  • this will mean parsing multi-byte unicode points
  • storing up to 4 bytes in each cell (extra 6 kB of RAM used)
  • figure out unicode -> JSON escapes
  • may be finally needed to implement incremental updates over websocket, not full repaints. The compression is already quite inadequate

Standard mouse support (X10, X11, SGR...)

js detection & new codes

  • client-side mouse tracking and reporting
  • server-side report parsing
  • mouse tracking mode global struct (expose struct from screen.c?) for use by commands
  • implement private commands (9, 1000, 1002, 1003, 1006 etc)
  • sending reports to UART

Configurable baud rate

  • Configure default using the web interface.
  • Possibly add a command to change it at run time
  • Revert to 115200 on factory reset

Make "factory defaults" configurable for classroom usage

Factory defaults would be configurable via the web UI (eg. a "set as defaults" button with a password prompt). Performing a Factory Reset would the reset to those settings.

The password could be hardcoded (easy but less practical) or configurable (risk of losing access).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.