Building Logic-Driven RF State Machines
Standard SDR tools are typically "one-mode" programs: they are either a scanner, a receiver, or a recorder. Mycelium breaks this limitation by allowing you to build stateful workflows that change behavior based on real-time RF events. By leveraging global variables and dynamic directive toggling, you can build a single tool that evolves its logic as it runs.
The Concept: A Conditional Monitoring Station
We want to build a tool that starts in **Scanning Mode**, but once it identifies a specific aircraft address (ICAO) via ADS-B, it switches to **Surveillance Mode**—automatically narrowing its bandwidth, enabling a high-fidelity recorder, and logging metadata to a central server.
Phase 1: Initializing the State
We'll use a session-scope global variable to track our current state.
Phase 2: The Scanning State
While station_mode == scanning, we'll sweep a range of frequencies.
Phase 3: The Transition
Once a target is detected, we trigger a state transition. We'll use the Set_Global action to update the mode and Disable_Directive to turn off the expensive scanning logic.
Phase 4: The Surveillance State
Now we define a directive that only triggers when station_mode == target_locked.
Execution Flow
Conclusion
This stateful approach turns Mycelium from a passive listener into an active, intelligent sensor. You can build complex mission logic—like "scan for WiFi beacons, but only if GPS coordinates indicate we've entered a specific zone"—all within the unified Mycelium CLI.
← Back to Blog