refactor: internal refactoring and optimization of Brucegotchi - #2724
Merged
Conversation
15 tasks
0Zane
pushed a commit
to 0Zane/firmware
that referenced
this pull request
Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
This PR cleans up and improves the Brucegotchi feature (Pwnagotchi) to make the code easier to maintain while reducing unnecessary memory usage on ESP32 devices.
pwnagotchi.cpp
Broke the large
brucegotchi_start()function into three smaller functions:reconPhase()interactPhase()advertisePhase()Added a
BruceStatestruct to keep related state variables organized.Replaced the long chain of
ifstatements with aswitchstatement to make the flow easier to follow.Removed
brucegotchi_update()since it is no longer used anywhere in the project.pwngrid.cpp
pwnSnifferCallback()to avoid repeated memory reallocations and improve efficiency.#include <algorithm>for the STL functions used in the new implementation.No functional changes were made. The feature behaves the same as before, with all existing timing and logic preserved.
Types of Changes
Verification
reapertarget (ESP32-S3): SUCCESSTesting
Tested on my device, and everything worked as expected with no issues observed.
Linked Issues
N/A
User-Facing Change
Further Comments
The main goal of this refactoring is to make the Brucegotchi code easier to read, understand, and maintain. Splitting the main function into smaller parts makes future changes and debugging much simpler. The memory optimizations also help reduce unnecessary allocations during long-running Brucegotchi sessions.