esp32-wifi-cli

Basic CLI for WiFi setup over ESP32

GPL-3.0 License

Stars
9
Committers
1

esp32-nmcli

Basic and extendible Wifi network manager CLI via serial command line for ESP32

Features

  • 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

Basic implementation

#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();
}

Network manager commands

This is a sample of the nmcli commands output:

Custom parameters

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.

Global configuration

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.

PlatformIO install

You able to install this library with pio pkg command:

pio pkg install --library "hpsaturn/ESP32 Wifi CLI @^0.3.0"

Or add it in your ini file. Also you can compile here the examples with a simple pio run over root of this repo.

Arduino IDE requirements

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.

Changelog

v0.3.x

v0.2.x

Projects

The next projects are using esp32-wifi-cli library:

Crypto panel

GPS via Virtual UART port

Basic T-Display S3 clock

CanAirIO - Air quality network

ICENav - ESP32 Based GPS Navigator

Credits

v0.3.x Extended and using Shellminator by Daniel Hajnal

v0.2.x Extended from SerialTerminal by Michael Ochmann