Skip to content

A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol

add eeprom cmd for 1wire

Geoe067c23ac499
diff --git a/src/Controllers/OneWireController.cpp b/src/Controllers/OneWireController.cpp
index 48717986..8d2c8a89 100644
--- a/src/Controllers/OneWireController.cpp
+++ b/src/Controllers/OneWireController.cpp
@@ -3,10 +3,22 @@
/*
Constructor
*/
-OneWireController::OneWireController(ITerminalView& terminalView, IInput& terminalInput,
- OneWireService& service, ArgTransformer& argTransformer,
- UserInputManager& userInputManager, IbuttonShell& ibuttonShell)
- : terminalView(terminalView), terminalInput(terminalInput), oneWireService(service), argTransformer(argTransformer), userInputManager(userInputManager), ibuttonShell(ibuttonShell) {
+OneWireController::OneWireController(
+ ITerminalView& terminalView,
+ IInput& terminalInput,
+ OneWireService& service,
+ ArgTransformer& argTransformer,
+ UserInputManager& userInputManager,
+ IbuttonShell& ibuttonShell,
+ OneWireEepromShell& eepromShell
+)
+ : terminalView(terminalView),
+ terminalInput(terminalInput),
+ oneWireService(service),
+ argTransformer(argTransformer),
+ userInputManager(userInputManager),
+ ibuttonShell(ibuttonShell),
+ eepromShell(eepromShell) {
}
/*
@@ -19,6 +31,7 @@ void OneWireController::handleCommand(const TerminalCommand& command) {
else if (command.getRoot() == "read") handleRead();
else if (command.getRoot() == "write") handleWrite(command);
else if (command.getRoot() == "ibutton") handleIbutton(command);
+ else if (command.getRoot() == "eeprom") handleEeprom();
else if (command.getRoot() == "temp") handleTemperature();
else if (command.getRoot() == "config") handleConfig();
else handleHelp();
@@ -495,6 +508,23 @@ void OneWireController::handleTemperature() {
terminalView.println(tempStr.str());
}
+/*
+EEPROM
+*/
+void OneWireController::handleEeprom() {
+ #ifndef DEVICE_M5STICK
+ terminalView.println("OneWire EEPROM: EEPROM Shell starts...");
+ oneWireService.close();
+ oneWireService.configureEeprom(state.getOneWirePin());
+ eepromShell.run();
+ oneWireService.closeEeprom();
+
+ #else
+ // No space left for the eeprom lib
+ terminalView.println("OneWire EEPROM: Not supported on M5STICK.");
+ #endif
+}
+
/*
Help
*/
@@ -507,6 +537,7 @@ void OneWireController::handleHelp() {
terminalView.println(" write id [8 bytes]");
terminalView.println(" write sp [8 bytes]");
terminalView.println(" ibutton");
+ terminalView.println(" eeprom");
terminalView.println(" temp");
terminalView.println(" config");
terminalView.println(" raw instructions, [0X33 r:8] ...");
@@ -521,4 +552,5 @@ void OneWireController::ensureConfigured() {
uint8_t pin = state.getOneWirePin();
oneWireService.configure(pin);
-}
\ No newline at end of file
+}
+
diff --git a/src/Controllers/OneWireController.h b/src/Controllers/OneWireController.h
index 58595022..8df96a41 100644
--- a/src/Controllers/OneWireController.h
+++ b/src/Controllers/OneWireController.h
@@ -10,13 +10,20 @@
#include "Transformers/ArgTransformer.h"
#include "Managers/UserInputManager.h"
#include "Shells/IbuttonShell.h"
+#include "Shells/OneWireEepromShell.h"
class OneWireController {
public:
// Constructor
- OneWireController(ITerminalView& terminalView, IInput& terminalInput,
- OneWireService& service, ArgTransformer& argTransformer,
- UserInputManager& userInputManager, IbuttonShell& ibuttonShell);
+ OneWireController(
+ ITerminalView& terminalView,
+ IInput& terminalInput,
+ OneWireService& service,
+ ArgTransformer& argTransformer,
+ UserInputManager& userInputManager,
+ IbuttonShell& ibuttonShell,
+ OneWireEepromShell& eepromShell
+ );
// Entry point for handle command
void handleCommand(const TerminalCommand& cmd);
@@ -34,6 +41,7 @@ private:
ArgTransformer& argTransformer;
UserInputManager& userInputManager;
IbuttonShell& ibuttonShell;
+ OneWireEepromShell& eepromShell;
GlobalState& state = GlobalState::getInstance();
bool configured = false;
@@ -75,4 +83,7 @@ private:
// Read temperature sensor
void handleTemperature();
+
+ // 1Wire EEPROM shell
+ void handleEeprom();
};
diff --git a/src/Controllers/UtilityController.cpp b/src/Controllers/UtilityController.cpp
index e400deb9..9dcfb44f 100644
--- a/src/Controllers/UtilityController.cpp
+++ b/src/Controllers/UtilityController.cpp
@@ -292,6 +292,7 @@ void UtilityController::handleHelp() {
terminalView.println(" write sp [8 bytes] - Write scratchpad");
terminalView.println(" temp - Read temperature");
terminalView.println(" ibutton - iButton operations");
+ terminalView.println(" eeprom - EEPROM operations");
terminalView.println(" config - Configure settings");
terminalView.println(" [0xAA r:8] ... - Instruction syntax");