How karlcswanson/spectrum-capture works
Recognize the Project’s Nature and Purpose
• This project is a standalone Go application that acts as a wrapper around external utilities (like soapy_power) to capture spectrum scan data and stream it to an MQTT broker.
• Its main function is to take configuration input (via an environment variable), invoke external commands that output rtl_power–formatted data, parse that data, and then publish incremental and complete scan details to an MQTT broker.
Main Components
a. Configuration Loader:
– Reads the SPECTRUM_CFG JSON (provided via the environment) that includes parameters such as name, description, command, and server details.
b. Command Execution Module (Embedded in main.go):
– Responsible for invoking the external process (soapy_power or similar utilities) and capturing its output over stdio.
c. Data Parsing and Handling Component:
– Processes the streamed output (stdout) from the external command and prepares data (both incremental and complete scans) for transmission.
d. MQTT Manager (mqtt_manager.go):
– Manages the connection to the MQTT broker and takes care of the publishing of scan data.
e. Deployment/Build Tool:
– Though not part of the runtime architecture, deploy.sh indicates remote deployment capability (cross-compilation for arm64 and remote startup) that can be annotated as part of the build/deployment pipeline.
Mapping Relationships and Interactions
• The Configuration component feeds settings (including command and MQTT server details) into the main process.
• The main process uses these settings to execute the external utility (soapy_power) and receive standard output.
• The Data Parsing component converts this raw output into a format suitable for the MQTT Manager.
• The MQTT Manager connects to the MQTT broker as defined in the configuration and streams the processed scan data.
• That the deploy.sh script is used to compile and deploy the binary to a remote device where it runs, ensuring that the containerized soapySDR environment is utilized.
Architectural Patterns and Key Technologies
• The system is built around a simple pipeline: configuration → execution (of an external command) → data parsing → message publishing.
• Modularity with clear separation between configuration, command execution, data parsing, and MQTT communication.
• The usage of MQTT messaging for data streaming is an important architectural point.
• Go’s native modules (go.mod, go.sum) underline dependency management and language-specific patterns.
[Configuration Loader] → [Command Executor] → [Data Parser] → [MQTT Manager] → [MQTT Broker]