A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol
C arduinobluetoothcan-busdebuggingeepromesp32flipperzerogpiohardware-hackingi2cjtagopenocdprotocolspwmradiorfidspisubghzuartwifi
add support for barebone stampS3
Geo8a30b6c6a87d
diff --git a/src/Controllers/UsbCardputerController.cpp b/src/Controllers/UsbS3Controller.cppsimilarity index 84%rename from src/Controllers/UsbCardputerController.cpprename to src/Controllers/UsbS3Controller.cppindex 47a1544e..4b427615 100644--- a/src/Controllers/UsbCardputerController.cpp+++ b/src/Controllers/UsbS3Controller.cpp@@ -1,18 +1,18 @@-#ifdef DEVICE_CARDPUTER+#ifndef DEVICE_M5STICK-#include "UsbCardputerController.h"+#include "UsbS3Controller.h"/*Constructor*/-UsbCardputerController::UsbCardputerController(ITerminalView& terminalView, IInput& terminalInput,+UsbS3Controller::UsbS3Controller(ITerminalView& terminalView, IInput& terminalInput,IUsbService& usbService, ArgTransformer& argTransformer, UserInputManager& userInputManager): terminalView(terminalView), terminalInput(terminalInput), usbService(usbService), argTransformer(argTransformer), userInputManager(userInputManager) {}/*Entry point for command*/-void UsbCardputerController::handleCommand(const TerminalCommand& cmd) {+void UsbS3Controller::handleCommand(const TerminalCommand& cmd) {if (cmd.getRoot() == "stick") {handleUsbStick();@@ -46,7 +46,7 @@ void UsbCardputerController::handleCommand(const TerminalCommand& cmd) {/*Keyboard Send*/-void UsbCardputerController::handleKeyboardSend(const TerminalCommand& cmd) {+void UsbS3Controller::handleKeyboardSend(const TerminalCommand& cmd) {terminalView.println("USB Keyboard: Configuring...");usbService.keyboardBegin();terminalView.println("USB Keyboard: Initialize...");@@ -58,7 +58,7 @@ void UsbCardputerController::handleKeyboardSend(const TerminalCommand& cmd) {/*Mouse Move*/-void UsbCardputerController::handleMouseMove(const TerminalCommand& cmd) {+void UsbS3Controller::handleMouseMove(const TerminalCommand& cmd) {int x, y = 0;// mouse move x y@@ -79,7 +79,7 @@ void UsbCardputerController::handleMouseMove(const TerminalCommand& cmd) {/*Mouse Click*/-void UsbCardputerController::handleMouseClick() {+void UsbS3Controller::handleMouseClick() {// Left clickusbService.mouseClick(1);delay(100);@@ -90,7 +90,7 @@ void UsbCardputerController::handleMouseClick() {/*Mouse*/-void UsbCardputerController::handleMouse(const TerminalCommand& cmd) {+void UsbS3Controller::handleMouse(const TerminalCommand& cmd) {terminalView.println("USB Mouse: Configuring HID...");usbService.mouseBegin();terminalView.println("USB Mouse: Initialize HID...");@@ -105,7 +105,7 @@ void UsbCardputerController::handleMouse(const TerminalCommand& cmd) {/*Gamepad*/-void UsbCardputerController::handleGamepad(const TerminalCommand& cmd) {+void UsbS3Controller::handleGamepad(const TerminalCommand& cmd) {terminalView.println("USB Gamepad: Configuring HID...");usbService.gamepadBegin();@@ -126,7 +126,7 @@ void UsbCardputerController::handleGamepad(const TerminalCommand& cmd) {/*Stick*/-void UsbCardputerController::handleUsbStick() {+void UsbS3Controller::handleUsbStick() {terminalView.println("USB Stick: Starting... USB Drive can take 30sec to appear");usbService.storageBegin(state.getSpiCSPin(), state.getSpiCLKPin(),state.getSpiMISOPin(), state.getSpiMOSIPin());@@ -135,7 +135,7 @@ void UsbCardputerController::handleUsbStick() {/*Config*/-void UsbCardputerController::handleConfig() {+void UsbS3Controller::handleConfig() {terminalView.println("");terminalView.println("USB Configuration:");@@ -163,7 +163,7 @@ void UsbCardputerController::handleConfig() {/*Reset*/-void UsbCardputerController::handleReset() {+void UsbS3Controller::handleReset() {usbService.reset();terminalView.println("USB Reset: Disable interfaces...");}@@ -171,7 +171,7 @@ void UsbCardputerController::handleReset() {/*Help*/-void UsbCardputerController::handleHelp() {+void UsbS3Controller::handleHelp() {terminalView.println("Unknown command.");terminalView.println("Usage:");terminalView.println(" stick");@@ -186,7 +186,7 @@ void UsbCardputerController::handleHelp() {/*Ensure Configuration*/-void UsbCardputerController::ensureConfigured() {+void UsbS3Controller::ensureConfigured() {if (!configured) {handleConfig();configured = true;diff --git a/src/Controllers/UsbCardputerController.h b/src/Controllers/UsbS3Controller.hsimilarity index 85%rename from src/Controllers/UsbCardputerController.hrename to src/Controllers/UsbS3Controller.hindex 48977d76..cc0ee3d6 100644--- a/src/Controllers/UsbCardputerController.h+++ b/src/Controllers/UsbS3Controller.h@@ -1,6 +1,6 @@#pragma once-#ifdef DEVICE_CARDPUTER+#ifndef DEVICE_M5STICK#include <sstream>#include <Arduino.h>@@ -14,10 +14,10 @@#include "Interfaces/IUsbController.h"#include "Interfaces/IUsbService.h"-class UsbCardputerController: public IUsbController {+class UsbS3Controller: public IUsbController {public:// Constructor- UsbCardputerController(ITerminalView& terminalView, IInput& terminalInput, IUsbService& usbService, ArgTransformer& argTransformer, UserInputManager& userInputManager);+ UsbS3Controller(ITerminalView& terminalView, IInput& terminalInput, IUsbService& usbService, ArgTransformer& argTransformer, UserInputManager& userInputManager);// Entry point for handle raw terminal commandvoid handleCommand(const TerminalCommand& cmd);diff --git a/src/Providers/DependencyProvider.h b/src/Providers/DependencyProvider.hindex 02a788d3..7b3b995d 100644--- a/src/Providers/DependencyProvider.h+++ b/src/Providers/DependencyProvider.h@@ -18,7 +18,7 @@ and injecting shared instances of core components#include "Services/I2cService.h"#include "Services/OneWireService.h"#include "Services/InfraredService.h"-#include "Services/UsbCardputerService.h"+#include "Services/UsbS3Service.h"#include "Services/HdUartService.h"#include "Services/SpiService.h"#include "Services/PinService.h"@@ -30,7 +30,7 @@ and injecting shared instances of core components#include "Controllers/I2cController.h"#include "Controllers/OneWireController.h"#include "Controllers/UtilityController.h"-#include "Controllers/UsbCardputerController.h"+#include "Controllers/UsbS3Controller.h"#include "Controllers/HdUartController.h"#include "Controllers/JtagController.h"#include "Controllers/SpiController.h"diff --git a/src/Services/UsbCardputerService.cpp b/src/Services/UsbS3Service.cppsimilarity index 78%rename from src/Services/UsbCardputerService.cpprename to src/Services/UsbS3Service.cppindex b9bccb0d..1f232d17 100644--- a/src/Services/UsbCardputerService.cpp+++ b/src/Services/UsbS3Service.cpp@@ -1,12 +1,12 @@-#ifdef DEVICE_CARDPUTER+#ifndef DEVICE_M5STICK-#include "UsbCardputerService.h"+#include "UsbS3Service.h"-UsbCardputerService::UsbCardputerService()+UsbS3Service::UsbS3Service(): keyboardActive(false), storageActive(false), initialized(false) {}-void UsbCardputerService::keyboardBegin() {+void UsbS3Service::keyboardBegin() {if (keyboardActive) return;USB.begin();@@ -15,7 +15,7 @@ void UsbCardputerService::keyboardBegin() {keyboardActive = true;}-void UsbCardputerService::storageBegin(uint8_t cs, uint8_t clk, uint8_t miso, uint8_t mosi) {+void UsbS3Service::storageBegin(uint8_t cs, uint8_t clk, uint8_t miso, uint8_t mosi) {if (initialized) return;sdSPI.begin(clk, miso, mosi, cs);@@ -45,7 +45,7 @@ void UsbCardputerService::storageBegin(uint8_t cs, uint8_t clk, uint8_t miso, uiinitialized = true;}-void UsbCardputerService::keyboardSendString(const std::string& text) {+void UsbS3Service::keyboardSendString(const std::string& text) {if (!keyboardActive) return;// Wait HID init@@ -59,7 +59,7 @@ void UsbCardputerService::keyboardSendString(const std::string& text) {}}-void UsbCardputerService::keyboardSendChunkedString(const std::string& data, size_t chunkSize, unsigned long delayBetweenChunks) {+void UsbS3Service::keyboardSendChunkedString(const std::string& data, size_t chunkSize, unsigned long delayBetweenChunks) {if (!keyboardActive) return;size_t totalLength = data.length();@@ -74,7 +74,7 @@ void UsbCardputerService::keyboardSendChunkedString(const std::string& data, siz}}-void UsbCardputerService::mouseBegin() {+void UsbS3Service::mouseBegin() {if (mouseActive) return;USB.begin();@@ -83,7 +83,7 @@ void UsbCardputerService::mouseBegin() {hidInitTime = millis();}-void UsbCardputerService::mouseMove(int x, int y) {+void UsbS3Service::mouseMove(int x, int y) {// Wait HID initwhile (millis() - hidInitTime < 1500) {delay(10);@@ -92,7 +92,7 @@ void UsbCardputerService::mouseMove(int x, int y) {mouse.move(x, y);}-void UsbCardputerService::mouseClick(int button) {+void UsbS3Service::mouseClick(int button) {// Wait HID initwhile (millis() - hidInitTime < 1500) {delay(10);@@ -103,12 +103,12 @@ void UsbCardputerService::mouseClick(int button) {mouse.release(button);}-void UsbCardputerService::mouseRelease(int button) {+void UsbS3Service::mouseRelease(int button) {if (!mouseActive) return;mouse.release(button);}-void UsbCardputerService::gamepadBegin() {+void UsbS3Service::gamepadBegin() {if (gamepadActive) return;gamepad.begin();@@ -117,7 +117,7 @@ void UsbCardputerService::gamepadBegin() {hidInitTime = millis();}-void UsbCardputerService::gamepadPress(const std::string& name) {+void UsbS3Service::gamepadPress(const std::string& name) {if (!gamepadActive) return;// Wait HID init@@ -156,23 +156,23 @@ void UsbCardputerService::gamepadPress(const std::string& name) {}-bool UsbCardputerService::isKeyboardActive() const {+bool UsbS3Service::isKeyboardActive() const {return keyboardActive;}-bool UsbCardputerService::isStorageActive() const {+bool UsbS3Service::isStorageActive() const {return storageActive;}-bool UsbCardputerService::isMouseActive() const {+bool UsbS3Service::isMouseActive() const {return mouseActive;}-bool UsbCardputerService::isGamepadActive() const {+bool UsbS3Service::isGamepadActive() const {return gamepadActive;}-int32_t UsbCardputerService::storageReadCallback(uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) {+int32_t UsbS3Service::storageReadCallback(uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) {const uint32_t secSize = SD.sectorSize();if (secSize == 0) return -1;@@ -185,7 +185,7 @@ int32_t UsbCardputerService::storageReadCallback(uint32_t lba, uint32_t offset,return bufsize;}-int32_t UsbCardputerService::storageWriteCallback(uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize) {+int32_t UsbS3Service::storageWriteCallback(uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize) {const uint32_t secSize = SD.sectorSize();if (secSize == 0) return -1;@@ -204,11 +204,11 @@ int32_t UsbCardputerService::storageWriteCallback(uint32_t lba, uint32_t offset,return bufsize;}-bool UsbCardputerService::usbStartStopCallback(uint8_t power_condition, bool start, bool load_eject) {+bool UsbS3Service::usbStartStopCallback(uint8_t power_condition, bool start, bool load_eject) {return true;}-void UsbCardputerService::setupStorageEvent() {+void UsbS3Service::setupStorageEvent() {USB.onEvent([](void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) {if (event_base == ARDUINO_USB_EVENTS) {auto* data = reinterpret_cast<arduino_usb_event_data_t*>(event_data);@@ -232,7 +232,7 @@ void UsbCardputerService::setupStorageEvent() {});}-void UsbCardputerService::reset() {+void UsbS3Service::reset() {if (initialized) {keyboard.releaseAll(); // si clavier actifmsc.end(); // si stockage actifdiff --git a/src/Services/UsbCardputerService.h b/src/Services/UsbS3Service.hsimilarity index 95%rename from src/Services/UsbCardputerService.hrename to src/Services/UsbS3Service.hindex 9a5f1893..4c13d389 100644--- a/src/Services/UsbCardputerService.h+++ b/src/Services/UsbS3Service.h@@ -1,6 +1,6 @@#pragma once-#ifdef DEVICE_CARDPUTER+#ifndef DEVICE_M5STICK#include <Arduino.h>#include <USB.h>@@ -19,9 +19,9 @@// ➤ If you enable any other USB mode, USB CDC will automatically stop.// ###############################################################################-class UsbCardputerService: public IUsbService {+class UsbS3Service: public IUsbService {public:- UsbCardputerService();+ UsbS3Service();// Begin USB HID keyboard modevoid keyboardBegin();diff --git a/src/main.cpp b/src/main.cppindex 94f28c64..17f280f1 100644--- a/src/main.cpp+++ b/src/main.cpp@@ -4,9 +4,11 @@#include <Views/SerialTerminalView.h>#include <Views/M5DeviceView.h>#include <Views/WebTerminalView.h>+#include <Views/NoScreenDeviceView.h>#include <Inputs/SerialTerminalInput.h>#include <Inputs/CardputerInput.h>#include <Inputs/StickInput.h>+#include <Inputs/StampS3Input.h>#include <Providers/DependencyProvider.h>#include <Dispatchers/ActionDispatcher.h>#include <Servers/HttpServer.h>@@ -22,21 +24,28 @@void setup() {- M5DeviceView deviceView;GlobalState& state = GlobalState::getInstance();#if defined(DEVICE_M5STICK)// Setup the M5stickCplus2auto cfg = M5.config();M5.begin(cfg);+ M5DeviceView deviceView;deviceView.setRotation(3);StickInput deviceInput;- #else+ #elif defined(DEVICE_CARDPUTER)// Setup the Cardputerauto cfg = M5.config();M5Cardputer.begin(cfg, true);+ M5DeviceView deviceView;deviceView.setRotation(1);CardputerInput deviceInput;+ #elif defined(DEVICE_M5STAMPS3)+ // Setup the StampS3+ auto cfg = M5.config();+ M5.begin(cfg);+ NoScreenDeviceView deviceView;+ StampS3Input deviceInput;#endifdeviceView.logo();