Skip to content

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

improve infrared controller

Geoad8ba2a60958
diff --git a/src/Controllers/InfraredController.cpp b/src/Controllers/InfraredController.cpp
index 1820de4d..f91f7097 100644
--- a/src/Controllers/InfraredController.cpp
+++ b/src/Controllers/InfraredController.cpp
@@ -60,7 +60,10 @@ void InfraredController::handleSend(const TerminalCommand& command) {
infraredCommand.setFunction(function);
infraredCommand.setProtocol(state.getInfraredProtocol());
- infraredService.sendInfraredCommand(infraredCommand);
+ for (int i = 0; i < 3; ++i) {
+ infraredService.sendInfraredCommand(infraredCommand);
+ delay(150);
+ }
terminalView.println("IR command sent with protocol " + InfraredProtocolMapper::toString(state.getInfraredProtocol()));
}
@@ -91,7 +94,6 @@ void InfraredController::handleReceive() {
terminalView.println(" Command : " + std::to_string(cmd.getFunction()));
terminalView.println("");
terminalView.println("INFRARED Receive: Waiting for next signal or press ENTER to exit.");
- delay(200);
}
}
}
@@ -100,17 +102,27 @@ void InfraredController::handleReceive() {
DeviceBgone
*/
void InfraredController::handleDeviceBgone() {
- terminalView.println("Sending Device-B-Gone commands...");
+ terminalView.println("Sending Device-B-Gone commands... Press ENTER to stop");
for (const auto& cmd : deviceBgoneCommands) {
- infraredService.sendInfraredCommand(cmd);
+
+ char c = terminalInput.readChar();
+ if (c == '\r' || c == '\n') {
+ terminalView.println("Infrared Devicebgone: Interrupted by user.");
+ return;
+ }
+
+ for (int i = 0; i < 2; ++i) { // send 2x per command
+ infraredService.sendInfraredCommand(cmd);
+ delay(150);
+ }
+
terminalView.println(
"Sent On/Off to protocol=" + InfraredProtocolMapper::toString(cmd.getProtocol()) +
" device=" + std::to_string(cmd.getDevice()) +
" sub=" + std::to_string(cmd.getSubdevice()) +
" cmd=" + std::to_string(cmd.getFunction())
);
- delay(40); // small delay between signals
}
terminalView.println("Device-B-Gone sequence completed.");
diff --git a/src/Data/DeviceBgoneCommands.h b/src/Data/DeviceBgoneCommands.h
index ffad5d6a..29b8fe13 100644
--- a/src/Data/DeviceBgoneCommands.h
+++ b/src/Data/DeviceBgoneCommands.h
@@ -7,6 +7,9 @@
inline const std::vector<InfraredCommand> deviceBgoneCommands = {
{NECX2, 7, 7, 2},
{NECX2, 7, -1, 2},
+ {SAMSUNG32, 7, 7, 2},
+ {SAMSUNG20, 7, -1, 2},
+ {SAMSUNG36, 7, 7, 2},
{NECX2, 4, -1, 8},
{_RC5, 0, 0, 12},
{SONY20, 1, 0, 21},
@@ -97,6 +100,7 @@ inline const std::vector<InfraredCommand> deviceBgoneCommands = {
{ _NEC, 0, -1, 135 },
{ F12, 0, -1, 128 },
+
// NEC‑based universal power codes
{ _NEC2, 0, -1, 16 }, // NEC generic power
{ _NEC2, 32, -1, 65 }, // NEC power variant
diff --git a/src/Dispatchers/ActionDispatcher.cpp b/src/Dispatchers/ActionDispatcher.cpp
index 50131644..0bfa4d06 100644
--- a/src/Dispatchers/ActionDispatcher.cpp
+++ b/src/Dispatchers/ActionDispatcher.cpp
@@ -123,7 +123,7 @@ void ActionDispatcher::dispatchCommand(const TerminalCommand& cmd) {
}
// Config was handled in specific mode, we need to rerender the pinout view
- if (cmd.getRoot() == "config") {
+ if (cmd.getRoot() == "config" || "setprotocol") {
setCurrentMode(state.getCurrentMode());
}
}
@@ -293,6 +293,7 @@ void ActionDispatcher::setCurrentMode(ModeEnum newMode) {
PinoutConfig config;
config.setMode(ModeEnumMapper::toString(newMode));
+ auto proto = InfraredProtocolMapper::toString(state.getInfraredProtocol());
switch (newMode) {
case ModeEnum::OneWire:
@@ -311,7 +312,9 @@ void ActionDispatcher::setCurrentMode(ModeEnum newMode) {
case ModeEnum::HDUART:
config.setMappings({
"RX/TX GPIO " + std::to_string(state.getHdUartPin()),
- "BAUD " + std::to_string(state.getHdUartBaudRate())
+ "BAUD " + std::to_string(state.getHdUartBaudRate()),
+ "BITS " + std::to_string(state.getHdUartDataBits()),
+ "PARITY " + state.getHdUartParity(),
});
provider.getHdUartController().ensureConfigured();
break;
@@ -347,7 +350,8 @@ void ActionDispatcher::setCurrentMode(ModeEnum newMode) {
provider.getInfraredController().ensureConfigured();
config.setMappings(
{"IR TX GPIO " + std::to_string(state.getInfraredTxPin()),
- "IR RX GPIO " + std::to_string(state.getInfraredRxPin())
+ "IR RX GPIO " + std::to_string(state.getInfraredRxPin()),
+ proto
});
break;
case ModeEnum::USB:
diff --git a/src/Services/InfraredService.cpp b/src/Services/InfraredService.cpp
index 59ca398f..6b603ab3 100644
--- a/src/Services/InfraredService.cpp
+++ b/src/Services/InfraredService.cpp
@@ -124,12 +124,18 @@ InfraredCommand InfraredService::receiveInfraredCommand() {
return InfraredCommand();
}
- // Extraction device et subdevice selon protocole
+ // Panasonic and derived
if (data.protocol == PANASONIC || data.protocol == KASEIKYO || data.protocol == KASEIKYO_JVC ||
data.protocol == KASEIKYO_SHARP || data.protocol == KASEIKYO_MITSUBISHI || data.protocol == KASEIKYO_DENON) {
// PANASONIC: 16 bits = 8b subdevice + 8b device
command.setDevice((data.address >> 8) & 0xFF);
command.setSubdevice(data.address & 0xFF);
+
+ // Samsung
+ } else if (data.protocol == SAMSUNG || data.protocol == SAMSUNGLG) {
+ command.setDevice(data.address & 0xFF);
+ command.setSubdevice((data.address >> 8) & 0xFF);
+
} else {
// que l'adresse
int device = data.address & 0xFF;