The previous example will only work if the computer running the browser has internet access. This is almost always possible on a developer machine, but there are situations where the user's computer might not have internet access (for example, out in the desert or on Mars, the coverage might not be that great). Luckily, weโve got this covered as well. The Shellminator library can host the same WebTerminal you used earlier through its own web server, independent of the platform (there are a few minor differences, but weโll go over them later).
This is really useful if you have a local network thatโs not connected to the internet. However, you should know that this operation can be resource-intensive, but an ESP32 or a Pico W can handle it just fine. Starting from the previous example, all you need to do is import the required library:
Then, create an object from the ShellminatorWebServerThemedOffline class. In its constructor, youโll need to specify a port where the web server will be available. Since itโs a regular HTML server, **port 80* is recommended.
In the init section, start the server (optionally, we log debug messages, but thatโs not mandatory):
htmlServer.attachDebugChannel( &Serial );
htmlServer.begin();
Finally, in the loop section, youโll need to periodically update the web server:
htmlServer.update();
If youโve done everything right, all thatโs left is to open a new tab in your browser and enter the device's IP address in the URL. Youโll see pretty much the same interface as the WebTerminal hosted in the documentation, except for a few differences:
You donโt need to specify the WebSocket address since the WebTerminal can extract it from the URI.
There are no tooltips to reduce the resources the page uses.
The webpage has been minified to consume fewer resources.