Skip to content

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

add universal remote command, adjust delay between ir signals

Geo9dfbfc5fe68c
diff --git a/src/Controllers/InfraredController.cpp b/src/Controllers/InfraredController.cpp
index 7957cbea..0dd9060e 100644
--- a/src/Controllers/InfraredController.cpp
+++ b/src/Controllers/InfraredController.cpp
@@ -1,35 +1,35 @@
#include "InfraredController.h"
-InfraredController::InfraredController(ITerminalView& view, IInput& terminalInput, InfraredService& service, ArgTransformer& argTransformer, UserInputManager& userInputManager)
- : terminalView(view), terminalInput(terminalInput), infraredService(service), argTransformer(argTransformer), userInputManager(userInputManager) {}
+/*
+Constructor
+*/
+InfraredController::InfraredController(
+ ITerminalView& view,
+ IInput& terminalInput,
+ InfraredService& service,
+ ArgTransformer& argTransformer,
+ UserInputManager& userInputManager,
+ UniversalRemoteShell& universalRemoteShell
+)
+ : terminalView(view),
+ terminalInput(terminalInput),
+ infraredService(service),
+ argTransformer(argTransformer),
+ userInputManager(userInputManager),
+ universalRemoteShell(universalRemoteShell)
+{}
/*
Entry point to handle Infrared command
*/
void InfraredController::handleCommand(const TerminalCommand& command) {
- if (command.getRoot() == "config") {
- handleConfig();
- }
-
- else if (command.getRoot() == "send") {
- handleSend(command);
- }
-
- else if (command.getRoot() == "receive") {
- handleReceive();
- }
-
- else if (command.getRoot() == "devicebgone") {
- handleDeviceBgone();
- }
-
- else if (command.getRoot() == "setprotocol") {
- handleSetProtocol();
- }
-
- else {
- handleHelp();
- }
+ if (command.getRoot() == "config") handleConfig();
+ else if (command.getRoot() == "send") handleSend(command);
+ else if (command.getRoot() == "receive") handleReceive();
+ else if (command.getRoot() == "devicebgone") handleDeviceBgone();
+ else if (command.getRoot() == "remote") handleRemote();
+ else if (command.getRoot() == "setprotocol") handleSetProtocol();
+ else handleHelp();
}
/*
@@ -62,7 +62,7 @@ void InfraredController::handleSend(const TerminalCommand& command) {
for (int i = 0; i < 3; ++i) {
infraredService.sendInfraredCommand(infraredCommand);
- delay(150);
+ delay(100);
}
terminalView.println("IR command sent with protocol " + InfraredProtocolMapper::toString(state.getInfraredProtocol()));
@@ -116,7 +116,7 @@ void InfraredController::handleDeviceBgone() {
for (int i = 0; i < 2; ++i) { // send 2x per command
infraredService.sendInfraredCommand(cmd);
- delay(150);
+ delay(100);
}
terminalView.println(
@@ -130,6 +130,13 @@ void InfraredController::handleDeviceBgone() {
terminalView.println("Device-B-Gone sequence completed.");
}
+/*
+Universal Remote
+*/
+void InfraredController::handleRemote() {
+ universalRemoteShell.run();
+}
+
/*
Set protocol
*/
@@ -219,6 +226,7 @@ void InfraredController::handleHelp() {
terminalView.println(" receive");
terminalView.println(" setprotocol");
terminalView.println(" devicebgone");
+ terminalView.println(" remote");
terminalView.println(" config");
}
diff --git a/src/Controllers/InfraredController.h b/src/Controllers/InfraredController.h
index 244104e7..c31b850f 100644
--- a/src/Controllers/InfraredController.h
+++ b/src/Controllers/InfraredController.h
@@ -13,13 +13,14 @@
#include "Transformers/ArgTransformer.h"
#include "Managers/UserInputManager.h"
#include "States/GlobalState.h"
+#include "Shells/UniversalRemoteShell.h"
class InfraredController {
public:
// Constructor
InfraredController(ITerminalView& view, IInput& terminalInput,
InfraredService& service, ArgTransformer& ArgTransformer,
- UserInputManager& userInputManager);
+ UserInputManager& userInputManager, UniversalRemoteShell& universalRemoteShell);
// Entry point for Infraredcommand dispatch
void handleCommand(const TerminalCommand& command);
@@ -34,6 +35,7 @@ private:
GlobalState& state = GlobalState::getInstance();
ArgTransformer& argTransformer;
UserInputManager& userInputManager;
+ UniversalRemoteShell& universalRemoteShell;
bool configured = false;
// Configure IR settings
@@ -51,6 +53,9 @@ private:
// Set IR protocol
void handleSetProtocol();
+ // Universal remote shell
+ void handleRemote();
+
// Show help text
void handleHelp();
};