A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol
C arduinobluetoothcan-busdebuggingeepromesp32flipperzerogpiohardware-hackingi2cjtagopenocdprotocolspwmradiorfidspisubghzuartwifi
stop and reset pin for subghz tx bitbang, related to #31
Geo6e0a1ae14afc
diff --git a/src/Controllers/SubGhzController.cpp b/src/Controllers/SubGhzController.cppindex 0e130853..086e85d1 100644--- a/src/Controllers/SubGhzController.cpp+++ b/src/Controllers/SubGhzController.cpp@@ -609,7 +609,7 @@ void SubGhzController::handleBruteforce() {// Repeatauto bruteRepeats = userInputManager.readValidatedUint8("Enter number of repeats per code:", 1);- subGhzService.setTxBitBang();+ subGhzService.startTxBitBang();// Send all codesterminalView.println("SUBGHZ BruteForce: Sending all codes for" + bruteProtocol + "... Press [ENTER] to stop.\n");@@ -642,10 +642,12 @@ void SubGhzController::handleBruteforce() {char cc = terminalInput.readChar();if (cc == '\n' || cc == '\r') {terminalView.println("\nSUBGHZ BruteForce: Stopped by user.\n");+ subGhzService.stopTxBitBang();return;}}+ subGhzService.stopTxBitBang();terminalView.println("\nSUBGHZ Bruteforce: Done.\n");}diff --git a/src/Services/SubGhzService.cpp b/src/Services/SubGhzService.cppindex 20c9aede..11e9bf19 100644--- a/src/Services/SubGhzService.cpp+++ b/src/Services/SubGhzService.cpp@@ -213,7 +213,7 @@ bool SubGhzService::sendRawFrame(int pin, const std::vector<rmt_item32_t>& itemsif (!isConfigured_ || items.empty()) return false;// Output- if (!setTxBitBang()) return false;+ if (!startTxBitBang()) return false;// tick to usauto ticks_to_us = [tick_per_us](uint32_t ticks) -> uint32_t {@@ -237,7 +237,7 @@ bool SubGhzService::sendRawFrame(int pin, const std::vector<rmt_item32_t>& itemsreturn true;}-bool SubGhzService::setTxBitBang() {+bool SubGhzService::startTxBitBang() {if (!isConfigured_) return false;gpio_config_t io{};@@ -249,6 +249,24 @@ bool SubGhzService::setTxBitBang() {return gpio_config(&io) == ESP_OK;}+bool SubGhzService::stopTxBitBang() {+ if (!isConfigured_) return false;++ // Force low+ gpio_set_direction((gpio_num_t)gdo0_, GPIO_MODE_OUTPUT);+ gpio_set_level((gpio_num_t)gdo0_, 0);+ delay(1);++ // Reset to input+ gpio_config_t io{};+ io.pin_bit_mask = (1ULL << gdo0_);+ io.mode = GPIO_MODE_INPUT;+ io.pull_up_en = GPIO_PULLUP_DISABLE;+ io.pull_down_en = GPIO_PULLDOWN_ENABLE;+ io.intr_type = GPIO_INTR_DISABLE;+ return gpio_config(&io) == ESP_OK;+}+bool SubGhzService::sendRawPulse(int pin, int duration) {if (!isConfigured_) return false;@@ -271,7 +289,7 @@ bool SubGhzService::sendRandomBurst(int pin)constexpr int JITTER_PCT = 30; // around the mean// Config pin as output- if (!setTxBitBang()) return false;+ if (!startTxBitBang()) return false;// Calcul bornes jitterint j = (MEAN_US * JITTER_PCT) / 100;diff --git a/src/Services/SubGhzService.h b/src/Services/SubGhzService.hindex dc9f3b69..06ede765 100644--- a/src/Services/SubGhzService.h+++ b/src/Services/SubGhzService.h@@ -39,7 +39,8 @@ public:void stopRawSniffer();// Raw send- bool setTxBitBang();+ bool startTxBitBang();+ bool stopTxBitBang();bool sendRawFrame(int pin,const std::vector<rmt_item32_t>& items,uint32_t tick_per_us = RMT_1US_TICKS);