hpsaturn / esp32-wifi-cli

Basic CLI for WiFi setup over ESP32
GNU General Public License v3.0
9 stars 3 forks source link

PlatformIO ViewCount

esp32-nmcli

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

Features

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:

nmcli preview commands

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

ESP32 nmcli CanAirIO demo

v0.2.x

ESP32 Wifi CLI Blink demo

ESP32 Wifi CLI Demo

Projects

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

Crypto panel

Crypto panel

GPS via Virtual UART port

screenshot20221102_231819

Basic T-Display S3 clock

ESP32S3 Clock T-Display

CanAirIO - Air quality network

CanAirIO Community

ICENav - ESP32 Based GPS Navigator

ICENav v3

Credits

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

v0.2.x Extended from SerialTerminal by Michael Ochmann