A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol
C arduinobluetoothcan-busdebuggingeepromesp32flipperzerogpiohardware-hackingi2cjtagopenocdprotocolspwmradiorfidspisubghzuartwifi
add standalone wifi setup for M5stickcplus2 and hoarmize cardputer one
Geo20f9576c6f60
diff --git a/src/Vendors/CardWifiSetup.cpp b/src/Vendors/CardWifiSetup.cppindex 8ac02a30..7ea72c86 100644--- a/src/Vendors/CardWifiSetup.cpp+++ b/src/Vendors/CardWifiSetup.cpp@@ -11,6 +11,8 @@* WiFi: https://github.com/espressif/arduino-esp32/tree/master/libraries/WiFi**/+#ifdef DEVICE_CARDPUTER+#include "CardWifiSetup.h"@@ -52,6 +54,8 @@ int scanWifiNetworks() {M5Cardputer.Display.fillScreen(TFT_BLACK);M5Cardputer.Display.setTextColor(0x05A3);M5Cardputer.Display.setTextSize(1.5);+ M5.Lcd.fillRoundRect(20, 20, M5.Lcd.width() - 40, M5.Lcd.height() - 40, 5, 0x0841);+ M5.Lcd.drawRoundRect(20, 20, M5.Lcd.width() - 40, M5.Lcd.height() - 40, 5, 0x05A3);M5Cardputer.Display.drawString("Scanning Networks...", 28, 60);networksCount = WiFi.scanNetworks();@@ -106,7 +110,7 @@ String selectWifiNetwork(int numNetworks) {void setWifiCredentials(String ssid, String password) {Preferences& preferences = getPreferences();- preferences.begin("wifi_settings", false);+ preferences.begin(NVS_DOMAIN, false);preferences.putString(NVS_SSID_KEY, ssid);preferences.putString(NVS_PASS_KEY, password);preferences.end();@@ -163,7 +167,7 @@ String askWifiPassword(String ssid) {return inputText("> ", 4, M5Cardputer.Display.height() - 24);}-void setupWifi() {+void setupCardputerWifi() {bool connected = false;int numNetworks = 0;String savedSSID;@@ -196,4 +200,6 @@ void setupWifi() {setWifiCredentials("", ""); // erase creds}}-}\ No newline at end of file+}++#endif\ No newline at end of filediff --git a/src/Vendors/CardWifiSetup.h b/src/Vendors/CardWifiSetup.hindex 81dfe97d..ed08a480 100644--- a/src/Vendors/CardWifiSetup.h+++ b/src/Vendors/CardWifiSetup.h@@ -13,12 +13,15 @@#pragma once+#ifdef DEVICE_CARDPUTER+#include <WiFi.h>#include <M5Cardputer.h>#include <Preferences.h>-#define NVS_SSID_KEY "wifi_ssid"-#define NVS_PASS_KEY "wifi_pass"+#define NVS_SSID_KEY "ssid"+#define NVS_PASS_KEY "pass"+#define NVS_DOMAIN "wifi_settings"inline Preferences& getPreferences() {static Preferences preferences;@@ -32,4 +35,6 @@ void setWifiCredentials(String ssid, String password);void getWifiCredentials(String& ssid, String& password);bool connectToWifi(String wifiSSID, String wifiPassword);String askWifiPassword(String ssid);-void setupWifi();+void setupCardputerWifi();++#endif\ No newline at end of filediff --git a/src/Vendors/StickWifiSetup.cpp b/src/Vendors/StickWifiSetup.cppnew file mode 100644index 00000000..2e60e639--- /dev/null+++ b/src/Vendors/StickWifiSetup.cpp@@ -0,0 +1,71 @@+#ifdef DEVICE_M5STICK++#include "StickWifiSetup.h"++Preferences& getPreferences() {+ static Preferences preferences;+ return preferences;+}++bool loadWifiCredentials(String& ssid, String& password) {+ Preferences& preferences = getPreferences();+ preferences.begin("wifi_settings", true);+ ssid = preferences.getString(NVS_SSID_KEY, "");+ password = preferences.getString(NVS_PASS_KEY, "");+ preferences.end();+ return !ssid.isEmpty() && !password.isEmpty();+}++bool setupStickWifi() {+ String ssid, password;+ M5.Lcd.setTextColor(TFT_LIGHTGRAY);+ M5.Lcd.fillScreen(TFT_BLACK);+ M5.Lcd.fillRoundRect(20, 20, M5.Lcd.width() - 40, M5.Lcd.height() - 40, 5, 0x0841);++ if (!loadWifiCredentials(ssid, password)) {+ M5.Lcd.drawRoundRect(20, 20, M5.Lcd.width() - 40, M5.Lcd.height() - 40, 5, TFT_RED);++ M5.Lcd.setTextColor(TFT_RED);+ M5.Lcd.setTextSize(2.2);+ M5.Lcd.drawString("No saved WiFi", 37, 45);++ M5.Lcd.setTextSize(1.5);+ M5.Lcd.setTextColor(TFT_LIGHTGRAY);+ M5.Lcd.drawString("USB Serial to setup", 36, 70);++ delay(10000);+ return false;+ }++ M5.Lcd.drawRoundRect(20, 20, M5.Lcd.width() - 40, M5.Lcd.height() - 40, 5, 0x05A3);+ WiFi.begin(ssid.c_str(), password.c_str());+ M5.Lcd.setTextSize(1.8);+ M5.Lcd.setTextColor(TFT_LIGHTGRAY);+ M5.Lcd.drawString("Connecting", 67, 60);++ M5.Lcd.setTextSize(0.8);+ M5.Lcd.setCursor(55, 79);+ for (int i = 0; i < 30; ++i) {+ if (WiFi.status() == WL_CONNECTED) {+ return true;+ }+ delay(800);+ M5.Lcd.print(".");+ }++ M5.Lcd.fillRoundRect(20, 20, M5.Lcd.width() - 40, M5.Lcd.height() - 40, 5, 0x0841);+ M5.Lcd.drawRoundRect(20, 20, M5.Lcd.width() - 40, M5.Lcd.height() - 40, 5, TFT_RED);++ M5.Lcd.setTextColor(TFT_RED);+ M5.Lcd.setTextSize(1.5);+ M5.Lcd.drawString("Failed to connect", 43, 45);++ M5.Lcd.setTextColor(TFT_LIGHTGRAY);+ M5.Lcd.setTextSize(1.5);+ M5.Lcd.drawString("USB Serial to setup", 36, 70);++ delay(10000);+ return false;+}++#endif\ No newline at end of filediff --git a/src/Vendors/StickWifiSetup.h b/src/Vendors/StickWifiSetup.hnew file mode 100644index 00000000..9ed43b4d--- /dev/null+++ b/src/Vendors/StickWifiSetup.h@@ -0,0 +1,17 @@+#pragma one++#ifdef DEVICE_M5STICK++#define NVS_SSID_KEY "ssid"+#define NVS_PASS_KEY "pass"+#define NVS_DOMAIN "wifi_settings"++#include <Arduino.h>+#include <Preferences.h>+#include <M5Unified.h>+#include <WiFi.h>++bool setupStickWifi();+++#endif\ No newline at end of file