Advanced Automation

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

digraph { graph [bgcolor="transparent" fontname="Inter" rankdir=LR pad=0.4] node [fontname="Inter" fontsize=12 fontcolor="#e2e8f0" style=filled fillcolor="#1a1033" color="#8b5cf6" penwidth=1.5 margin="0.3,0.2" shape=box] edge [color="#8b5cf6" fontcolor="#a78bfa" fontname="Inter" fontsize=10 arrowsize=0.8] __start [label="" shape=circle width=0.3 fixedsize=true style=filled fillcolor="#8b5cf6" color="#8b5cf6"] scanning [label="Scanning\n\nIncrement_Frequency\nListen for ADS-B"] surveillance [label="Surveillance\n\nStop Sweeping\nEnable JSON Logging\nSave IQ to Disk"] __start -> scanning scanning -> surveillance [label="Target Detected\n(ICAO: ABCDEF)"] surveillance -> scanning [label="Reset Signal"] }

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