A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol
C arduinobluetoothcan-busdebuggingeepromesp32flipperzerogpiohardware-hackingi2cjtagopenocdprotocolspwmradiorfidspisubghzuartwifi
rework subghz sniffer profile to drain the rmt buffer if overflow occurs
Geo6053ff083e67
diff --git a/src/Controllers/SubGhzController.cpp b/src/Controllers/SubGhzController.cppindex ded2b0eb..a2e07187 100644--- a/src/Controllers/SubGhzController.cpp+++ b/src/Controllers/SubGhzController.cpp@@ -48,6 +48,11 @@ void SubGhzController::handleSniff(const TerminalCommand&) {count += pulseCount;terminalView.println(line);}++ if (subGhzService.isSnifferOverflowing()) {+ terminalView.println("\n[WARNING] SUBGHZ Sniffer: Overflow detected! Draining buffer...\n");+ subGhzService.drainSniffer();+ }}subGhzService.stopRawSniffer();@@ -206,6 +211,11 @@ void SubGhzController::handleReplay(const TerminalCommand&) {}frames.push_back(std::move(items));terminalView.println(" [Frame " + std::to_string(frames.size()) + " captured]");++ if (subGhzService.isSnifferOverflowing()) {+ terminalView.println("\n[WARNING] SUBGHZ Sniffer: Overflow detected! Draining buffer...\n");+ subGhzService.drainSniffer();+ }}subGhzService.stopRawSniffer();@@ -399,6 +409,11 @@ void SubGhzController::handleDecode(const TerminalCommand&) {auto result = subGhzAnalyzeManager.analyzeFrame(frame);terminalView.println(result);}++ if (subGhzService.isSnifferOverflowing()) {+ terminalView.println("\n[WARNING] SUBGHZ Sniffer: Overflow detected! Draining buffer...\n");+ subGhzService.drainSniffer();+ }}subGhzService.stopRawSniffer();diff --git a/src/Services/SubGhzService.cpp b/src/Services/SubGhzService.cppindex ad2c23d8..e2aaf174 100644--- a/src/Services/SubGhzService.cpp+++ b/src/Services/SubGhzService.cpp@@ -150,8 +150,25 @@ bool SubGhzService::startRawSniffer(int pin) {return true;}+bool SubGhzService::isSnifferOverflowing() const {+ if (!rb_) return false;+ size_t freeBytes = xRingbufferGetCurFreeSize(rb_);+ return freeBytes < 128;+}++void SubGhzService::drainSniffer() {+ if (!rb_) return;+ while (true) {+ size_t rx_size = 0;+ rmt_item32_t* item = (rmt_item32_t*) xRingbufferReceive(rb_, &rx_size, 0);+ if (!item) break;+ vRingbufferReturnItem(rb_, (void*)item);+ }+}+void SubGhzService::stopRawSniffer() {rmt_rx_stop(RMT_RX_CHANNEL);+ drainSniffer();rmt_driver_uninstall(RMT_RX_CHANNEL);rb_ = nullptr;ELECHOUSE_cc1101.setSidle();@@ -185,6 +202,7 @@ std::pair<std::string, size_t> SubGhzService::readRawPulses() {}oss << "\n\r";+ vRingbufferReturnItem(rb_, (void*)item); // Free memoryreturn {oss.str(), n};}diff --git a/src/Services/SubGhzService.h b/src/Services/SubGhzService.hindex db719a22..d0954cb7 100644--- a/src/Services/SubGhzService.h+++ b/src/Services/SubGhzService.h@@ -15,6 +15,7 @@#define RMT_CLK_DIV 80#define RMT_1US_TICKS (80000000 / RMT_CLK_DIV / 1000000)#define RMT_1MS_TICKS (RMT_1US_TICKS * 1000)+#define RMT_BUFFER_SIZE 8192#define TEMBED_CC1101_SW0 48#define TEMBED_CC1101_SW1 47@@ -37,6 +38,8 @@ public:bool startRawSniffer(int pin);std::pair<std::string, size_t> readRawPulses();std::vector<rmt_item32_t> readRawFrame();+ bool isSnifferOverflowing() const;+ void drainSniffer();void stopRawSniffer();// Raw send