mirror of
https://github.com/okalachev/flix.git
synced 2026-06-27 21:46:38 +00:00
Add command for setting the wifi mode easier
This commit is contained in:
+7
-4
@@ -45,9 +45,10 @@ const char* motd =
|
||||
"cr - calibrate RC\n"
|
||||
"pw - show power info\n"
|
||||
"wifi - show Wi-Fi info\n"
|
||||
"ap <ssid> <password> - setup Wi-Fi access point\n"
|
||||
"sta <ssid> <password> - setup Wi-Fi client mode\n"
|
||||
"espnow <mac> [<key>] - setup ESP-NOW peer\n"
|
||||
"wifi ap/sta/espnow/off - set Wi-Fi mode\n"
|
||||
"ap <ssid> <password> - configure Wi-Fi access point\n"
|
||||
"sta <ssid> <password> - configure Wi-Fi client mode\n"
|
||||
"espnow <mac> [<key>] - 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") {
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
@@ -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"); };
|
||||
|
||||
Reference in New Issue
Block a user