A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol
C arduinobluetoothcan-busdebuggingeepromesp32flipperzerogpiohardware-hackingi2cjtagopenocdprotocolspwmradiorfidspisubghzuartwifi
rework ir file send to work with raw data
Geo1dd0940276f8
diff --git a/src/Controllers/InfraredController.cpp b/src/Controllers/InfraredController.cppindex 7c75012c..b4b716bf 100644--- a/src/Controllers/InfraredController.cpp+++ b/src/Controllers/InfraredController.cpp@@ -341,27 +341,27 @@ void InfraredController::handleLoad(TerminalCommand const& command) {int MAX_FILE_SIZE = 32 * 1024; // 32 KBauto fileSize = littleFsService.getFileSize("/" + chosen);if (fileSize == 0 || fileSize > MAX_FILE_SIZE) {- terminalView.println("INFRARED: File size invalid (>32KB): " + chosen);+ terminalView.println("\nINFRARED: File size invalid (>32KB): " + chosen);return;}// Load file contentstd::string text;if (!littleFsService.readAll("/" + chosen, text)) {- terminalView.println("INFRARED: Failed to read file: " + chosen);+ terminalView.println("\nINFRARED: Failed to read file: " + chosen);return;}// Verify formatif (!infraredRemoteTransformer.isValidInfraredFile(text)) {- terminalView.println("INFRARED: Unrecognized .ir format or empty: " + chosen);+ terminalView.println("\nINFRARED: Unrecognized .ir format or empty: " + chosen);return;}// Extract commandsauto cmds = infraredRemoteTransformer.transformFromFileFormat(text);if (cmds.empty()) {- terminalView.println("INFRARED: No commands found in: " + chosen);+ terminalView.println("\nINFRARED: No commands found in: " + chosen);return;}@@ -378,24 +378,12 @@ void InfraredController::handleLoad(TerminalCommand const& command) {break;}- // Convert- const auto& ir = cmds[idxCmd];- uint8_t device = static_cast<uint8_t>(ir.address & 0xFF);- uint8_t sub = static_cast<uint8_t>((ir.address >> 8) & 0xFF);- auto finalCmd = InfraredCommand(- ir.protocol,- device,- sub,- ir.function- );-// Send- infraredService.sendInfraredCommand(finalCmd);- terminalView.println("\n ✅ Sent command '" + ir.functionName + "' from file '" + chosen + "'");+ infraredService.sendInfraredFileCommand(cmds[idxCmd]);+ terminalView.println("\n ✅ Sent command '" + cmds[idxCmd].functionName + "' from file '" + chosen + "'");}}-/*Config*/diff --git a/src/Services/InfraredService.cpp b/src/Services/InfraredService.cppindex f9f098cf..de2914e0 100644--- a/src/Services/InfraredService.cpp+++ b/src/Services/InfraredService.cpp@@ -69,6 +69,25 @@ void InfraredService::sendInfraredCommand(InfraredCommand command) {}}+void InfraredService::sendInfraredFileCommand(InfraredFileRemoteCommand command) {++ if (command.protocol == InfraredProtocolEnum::RAW) {+ IrSender.sendRaw(command.rawData, command.rawDataSize, command.frequency);+ return;+ }++ uint8_t device = static_cast<uint8_t>(command.address & 0xFF);+ uint8_t sub = static_cast<uint8_t>((command.address >> 8) & 0xFF);+ auto finalCmd = InfraredCommand(+ command.protocol,+ device,+ sub,+ command.function+ );++ sendInfraredCommand(finalCmd);+}+InfraredCommand InfraredService::receiveInfraredCommand() {InfraredCommand command;diff --git a/src/Services/InfraredService.h b/src/Services/InfraredService.hindex 9a15f290..56801bb4 100644--- a/src/Services/InfraredService.h+++ b/src/Services/InfraredService.h@@ -2,6 +2,7 @@#include <vector>#include <Models/InfraredCommand.h>+#include <Models/InfraredFileRemoteCommand.h>#include <Vendors/MakeHex.h>#include "Enums/InfraredProtocolEnum.h"@@ -11,6 +12,7 @@ public:void startReceiver();void stopReceiver();void sendInfraredCommand(InfraredCommand command);+ void sendInfraredFileCommand(InfraredFileRemoteCommand command);InfraredCommand receiveInfraredCommand();bool receiveRaw(std::vector<uint16_t>& timings, uint32_t& khz);void sendRaw(const std::vector<uint16_t>& timings, uint32_t khz);diff --git a/src/Transformers/InfraredRemoteTransformer.cpp b/src/Transformers/InfraredRemoteTransformer.cppindex bac41a63..423d3987 100644--- a/src/Transformers/InfraredRemoteTransformer.cpp+++ b/src/Transformers/InfraredRemoteTransformer.cpp@@ -117,26 +117,17 @@ std::vector<std::string> InfraredRemoteTransformer::extractFunctionNames(uint16_t InfraredRemoteTransformer::convertHexToUint16(const std::string& hexString, size_t byteLimit) {std::istringstream iss(hexString);- std::string byteStr;+ std::string tok;uint16_t result = 0;- int byteCount = 0;-- // Vector to hold the bytes in reverse order- std::vector<uint8_t> bytes;-- // Read each byte from the string and store in the vector- while (iss >> byteStr && byteCount < byteLimit) {- // Convert the byte string to an integer and store it in the vector- uint8_t byte = std::stoul(byteStr, nullptr, 16);- bytes.push_back(byte);- byteCount++;+ unsigned shift = 0;+ size_t count = 0;++ while (iss >> tok && count < byteLimit) {+ unsigned v = std::stoul(tok, nullptr, 16) & 0xFFu;+ result |= static_cast<uint16_t>(v) << shift;+ shift += 8;+ ++count;}-- // Combine the bytes in reverse order- for (int i = byteCount - 1; i >= 0; --i) {- result = (result << 8) | bytes[i];- }-return result;}