Intro
Using WebSerial Lite we now have some core elements for a web remote console:
* Serial I/O duplication
* Asynchronous web server
* Webserver console
There are a set of improvements I would like to make
* Format console layout to my taste
* Use a DNS name to access console via a browser
* Add a command line parser to identify commands and parameters
* Include an option to use HTML input (buttons etc) to control ESP32
Tailor WebSerial Lite
My first enhancement was to tailor the web server console. There is a github version of the WebSerial Lite library which I can work with. Initially I just want to simply screen layout and present my own title.
It isn't good practice to modify a library in place so I copied the three library files into a sketch.
One file contains a web page (HTML, CSS, JS) which provides the browser console layout and functionality. Unfortunately the page is zipped. Reviewing the excellent ESPAsyncWebServer documentation I found out how to use a text version of the web page instead.
I was then able to format the title / page layout so that it now looks like a proper console to me.
Add mDNS
mDNS is a minor addition to the sketch. As usual there is an excellent RNT tutorial to set it up. Now we can access our console with a URL "foxy.local" rather than an IP address and the URL remains the same if ESP32 ip address changes.CLI
I dont want to invent my own command line interface (CLI). SimpleCLI provides a good solution allowing us to enter commands with a variety of parameters. I added an example to my Web Remote Console sketch to get an idea of CLI usage and I am pleased that "it feels right".
To use SimpleCLI you define a number of commands, together with the parameters they require. You take terminal command input and parse it. SimpleCLI then invokes code you write for each command. My framework just prints out a suitable message for each command.
Buttons
We now have a practical console. As an aside we still have the ability to incorporate traditional web page buttons, text, options etc to display output or provide input. Some applications dont require much interaction and it can be more appropriate to control them without a command line, especially when it is important to simplify the interface. CLI control requires less effort to setup when there may be a variety of controls / parameters required.
Outro
Our Web Remote Console is beginning to feel like a real computer tool. As yet we have no file storage so our next mission is to add a file system.





No comments:
Post a Comment