Shellminator V3.0.1
Simple Terminal
|
These days, wireless solutions are becoming more and more popular, and this trend has also made its way into the affordable embedded systems sector over the years. It all started with the ESP8266, but today we have a variety of microcontrollers and development boards available with WiFi connectivity options, such as the Raspberry Pi Pico W, ESP32, and Arduino. The Shellminator currently offers three solutions for this: WebSocket, TCP, and Bluetooth Low Energy.
Let’s start by looking at the WebSocket implementation, as it’s the easiest of the three and all you’ll need is a browser. First, you’ll need a microcontroller that supports WiFi communication. We tested the Raspberry Pi Pico W, ESP32, ESP8266, and the Arduino Uno R4 in-house, and with these, we were able to create a working terminal.
Since we wanted the system to be available across multiple platforms, we implemented our own WebSocket driver. This is basically a WebSocket server optimized for message sending and working as a Stream, which makes it easy to integrate into the Shellminator ecosystem.
You’ll need to specify a port for the server to run on. The commonly accepted WebSocket default port is 443, but it can be anything else if your requirements differ. Once you’ve chosen a port, create an object of the ShellminatorWebSocket
class and specify the port in the constructor.
Now, in the constructor of the Shellminator object, you can easily link the WebSocket object as the communication channel.
At the end of the init
section, it’s a good idea to start the WebSocket server. It’s enough to start it after everything else is initialized. Additionally, if you want, you can enable debug messages with the attachDebugChannel
method (but be careful with this, especially in security-critical products, since it will print encryption keys).
Finally, the only thing left is to continuously process the WebSocket messages in the loop
section. For devices managing networks, it's good practice to add at least a 2ms delay at the end of the loop
, so the microkernel running on these devices has time to handle networking tasks.
Once the example code is uploaded to the desired platform, it will print a few useful messages to the Serial after boot, such as the device’s IP address. You’ll need this to use the demo. The demo window will load the WebTerminal app, which we’ve included for convenience, but you can always access it separately from the flashing WebTerminal menu at the bottom of the left-side list.
For the WebTerminal to connect to your device, you need to enter the WebSocket server’s address in the TargetIP text field at the top right corner, in the format: ws://DEVICE-IP:WS-PORT
. For example, in our case, it looks like this: ws://192.168.0.223:443
.
It’s a bit slow and flickering, right? In this example, we just wanted to showcase the basic functionality and the framework, but don't worry, in the next example we’ll fix those aesthetic issues 😉