Basic and extendible Wifi network manager CLI via serial command line for ESP32
- Network manager nmcli command (connect, up, down, scan, list, etc)
- Wifi multi AP and single AP modes
- New Telnet service for remote shell via IP and port
- New shell improved & migrated to Shellminator development
- New interactive shell, autocomplete, history, prompt, logo and others
- extendible custom user commands
- preferences persist in flash ROM
- two parsers: Argument into quotes or two parameters without quotes
- debug messages mode off (new silent mode)
- disable auto connect in the boot
- esp32c3, esp32s3 support
- VT100 compatibility
- esp8266 support
#include <Arduino.h>
#include <ESP32WifiCLI.hpp>
void setup() {
Serial.begin(115200); // set here the Serial baudrate or in
wcli.begin(); // the begin method like a parameter
}
void loop() {
wcli.loop();
}
This is a sample of the nmcli commands output:
For instance for setup a new connection:
nmcli connect Your SSID password "Your Password"
Note that you could enter your ssid with spaces but without quotes, and your password with spaces but into quotes.
nmcli support many WiFi networks, and you are able to list those with nmcli list
, also select your WiFi network default with nmcli select #
where # is the number or ID of each WiFi network listed with list
command. Also, you could enable multi network with nmcli mode multi
, that means that the device will try to detect what WiFi network is available, or force with nmcli mode single
to use only your WiFi network default.
For instance you can extend the available commands adding new ones in the setup, also add your prompt name and custom logo, like this example:
void setup() {
Serial.begin(115200); // Optional, you can init it on begin()
Serial.flush(); // Only for showing the message on serial
wcli.setCallback(new mESP32WifiCLICallbacks());
wcli.setSilentMode(true); // less debug output
// Custom commands:
wcli.add("sleep", &sleep, "\t\t<mode> <time> ESP32 sleep mode (deep/light)\r\n");
wcli.add("echo", &echo, "\t\t\"message\" Echo the msg. Parameter into quotes");
wcli.add("info", &info, "\t\tsystem status info");
wcli.add("setled", &setled, "\t<PIN> config the LED GPIO for blink");
wcli.add("blink", &blink, "\t\t<times> <millis> LED blink x times each x millis");
wcli.add("reboot", &reboot, "\tperform a ESP32 reboot");
wcli.shell->attachLogo(logo);
wcli.shell->clear();
wcli.begin("CanAirIO"); // your prompt custom name
}
For more details, please review the M5Atom and Advanced examples.
The v0.3.x version uses Shellminator that needs some special build flags. Please add these in your build config, for instance in PlatformIO ini file:
build_flags =
-D SHELLMINATOR_BUFF_LEN=70
-D SHELLMINATOR_BUFF_DIM=70
-D COMMANDER_MAX_COMMAND_SIZE=70
-D WCLI_MAX_CMDS=7 ; your custom commands count plus one
Be careful with the last flag WCLI_MAX_CMDS
when you are adding more custom commands to your CLI, it should be n 1. Also you can check the plaformio.ini file in this repo to see the configuration for the main example.
You able to install this library with pio pkg command:
pio pkg install --library "hpsaturn/ESP32 Wifi CLI @^0.3.2"
Or add it in your ini file. Also you can compile here the examples with a simple pio run
over root of this repo.
Because Arduino IDE is very bad to resolve dependencies, you need first download and install the next libraries dependencies:
After that install ESP32 Wifi CLI library from this repo. Download it on releases.
The next projects are using esp32-wifi-cli
library:
v0.3.x Extended and using Shellminator by Daniel Hajnal
v0.2.x Extended from SerialTerminal by Michael Ochmann