From e51b47b798e3a110f893b7212cc0d7690af9f2ec Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Tue, 9 Jun 2026 02:44:09 +0300 Subject: [PATCH] Add command for setting the wifi mode easier --- flix/cli.ino | 11 +++++++---- flix/wifi.ino | 17 +++++++++++++++++ gazebo/flix.h | 1 + 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/flix/cli.ino b/flix/cli.ino index ed87692..858e7ac 100644 --- a/flix/cli.ino +++ b/flix/cli.ino @@ -45,9 +45,10 @@ const char* motd = "cr - calibrate RC\n" "pw - show power info\n" "wifi - show Wi-Fi info\n" -"ap - setup Wi-Fi access point\n" -"sta - setup Wi-Fi client mode\n" -"espnow [] - setup ESP-NOW peer\n" +"wifi ap/sta/espnow/off - set Wi-Fi mode\n" +"ap - configure Wi-Fi access point\n" +"sta - configure Wi-Fi client mode\n" +"espnow [] - configure ESP-NOW peer\n" "mot - show motor output\n" "log [dump] - print log header [and data]\n" "mfr, mfl, mrr, mrl - test motor (remove props)\n" @@ -139,8 +140,10 @@ void doCommand(String str, bool echo = false) { print("armed: %d\n", armed); } else if (command == "pw") { print("Voltage: %.1f V\n", voltage); - } else if (command == "wifi") { + } else if (command == "wifi" && arg0 == "") { printWiFiInfo(); + } else if (command == "wifi") { + setWiFiMode(arg0); } else if (command == "ap") { configWiFi(W_AP, arg0.c_str(), arg1.c_str()); } else if (command == "sta") { diff --git a/flix/wifi.ino b/flix/wifi.ino index ccdf0fa..8d45ca2 100644 --- a/flix/wifi.ino +++ b/flix/wifi.ino @@ -132,3 +132,20 @@ void configWiFi(int mode, const char *first, const char *second) { } print("✓ Reboot to apply new settings\n"); } + +void setWiFiMode(const String& mode) { + if (mode == "ap") { + wifiMode = W_AP; + } else if (mode == "sta") { + wifiMode = W_STA; + } else if (mode == "espnow") { + wifiMode = W_ESPNOW; + } else if (mode == "off") { + wifiMode = W_DISABLED; + } else { + print("Invalid Wi-Fi mode\n"); + return; + } + static const char *modes[] = {"Disabled", "Access Point (AP)", "Client (STA)", "ESP-NOW"}; + print("✓ Wi-Fi mode set to %s, reboot to apply\n", modes[wifiMode]); +} diff --git a/gazebo/flix.h b/gazebo/flix.h index 8c3f1c3..e0ba9ab 100644 --- a/gazebo/flix.h +++ b/gazebo/flix.h @@ -79,3 +79,4 @@ void printIMUCalibration() { print("cal: N/A\n"); }; void printIMUInfo() {}; void printWiFiInfo() {}; void configWiFi(bool, const char*, const char*) { print("Skip WiFi config\n"); }; +void setWiFiMode(const String& mode) { print("Skip WiFi mode set\n"); };