Skip to content

Commit 0f2f427

Browse files
committed
feat: Add SBS-1/BaseStation format output module
- Implement complete SBS-1/BaseStation CSV format on port 30004 - Add --sbs1 and --sbs1-port command line arguments - Support MSG types 1,3,4,5 for identification, position, and velocity - Include proper timestamp formatting and ICAO address parsing - Add comprehensive documentation with protocol references - Maintain compatibility with BaseStation and Virtual Radar Server - Integrate with existing dynamic output module architecture References: - BaseStation Protocol: http://woodair.net/sbs/article/barebones42_socket_data.htm - SBS-1 Data Format: http://www.homepages.mcb.net/bones/SBS/Article/Barebones42_Socket_Data.htm
1 parent 5a40786 commit 0f2f427

File tree

5 files changed

+604
-8
lines changed

5 files changed

+604
-8
lines changed

CLAUDE.md

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ AviAware is an ADS-B (Automatic Dependent Surveillance–Broadcast) decoder writ
99
## Build and Run Commands
1010

1111
```bash
12-
# Build and run in release mode (recommended for actual use)
13-
cargo run --release
12+
# Development build and run (recommended for actual use)
13+
cargo run
1414

1515
# Build only
16-
cargo build --release
16+
cargo build
1717

18-
# Development build and run
19-
cargo run
18+
# Build and run in release mode
19+
cargo run --release
2020

2121
# Run with custom parameters (see listen-adsb binary for all options)
22-
cargo run --release -- --gain 40.0 --preamble-threshold 12.0
22+
cargo run -- --gain 40.0 --preamble-threshold 12.0
2323
```
2424

2525
## Architecture
@@ -76,4 +76,55 @@ For testing/replay:
7676
cargo run --release -- --file samples.cf32
7777
```
7878

79-
Input files should be Complex32 format at any sample rate ≥ 2 MHz.
79+
Input files should be Complex32 format at any sample rate ≥ 2 MHz.
80+
81+
## Output Formats
82+
83+
AviAware supports multiple output formats for compatibility with various ADS-B tools and applications:
84+
85+
### BEAST Format (Port 30005)
86+
- **Default**: Enabled by default
87+
- **Description**: Binary format compatible with dump1090's BEAST mode
88+
- **Usage**: `--beast` / `--no-beast`, `--beast-port <PORT>`
89+
- **Protocol**: Binary messages with timestamps and signal levels
90+
- **Compatibility**: dump1090, tar1090, FlightRadar24 feeders
91+
92+
### Raw Format (Port 30002)
93+
- **Default**: Enabled by default
94+
- **Description**: Simple hex format compatible with dump1090's raw output
95+
- **Usage**: `--raw` / `--no-raw`, `--raw-port <PORT>`
96+
- **Protocol**: `*{hexdata};\n` format
97+
- **Compatibility**: dump1090 port 30002, simple monitoring tools
98+
99+
### AVR Format (Port 30003)
100+
- **Default**: Disabled by default
101+
- **Description**: Text format with timestamps and signal levels
102+
- **Usage**: `--avr`, `--avr-port <PORT>`
103+
- **Protocol**: `@{timestamp}\n*{hexdata};\n` format
104+
- **Compatibility**: dump1090 AVR format, debugging tools
105+
106+
### SBS-1/BaseStation Format (Port 30004)
107+
- **Default**: Disabled by default
108+
- **Description**: CSV format compatible with BaseStation and SBS-1 receivers
109+
- **Usage**: `--sbs1`, `--sbs1-port <PORT>`
110+
- **Protocol**: Comma-separated values with aircraft data
111+
- **Compatibility**: BaseStation, Virtual Radar Server, PlanePlotter
112+
- **References**:
113+
- [BaseStation Protocol](http://woodair.net/sbs/article/barebones42_socket_data.htm)
114+
- [SBS-1 Data Format](http://www.homepages.mcb.net/bones/SBS/Article/Barebones42_Socket_Data.htm)
115+
116+
## Example Usage
117+
118+
```bash
119+
# Run with defaults (BEAST + Raw)
120+
cargo run
121+
122+
# Enable all output formats
123+
cargo run -- --avr --sbs1
124+
125+
# Custom ports to avoid conflicts
126+
cargo run -- --beast-port 40005 --raw-port 40002 --sbs1-port 40004
127+
128+
# Enable only SBS-1 output
129+
cargo run -- --no-beast --no-raw --sbs1
130+
```

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ soapy = ["futuresdr/soapy"]
2525
adsb_deku = "0.7"
2626
anyhow = "1.0"
2727
async-trait = "0.1"
28+
chrono = "0.4"
2829
clap = { version = "4", features = ["derive"] }
2930
futuresdr = { version = "0.0.38", features = ["seify"] }
3031
serde = { version = "1", features = ["derive"] }

src/bin/listen_adsb.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use adsb_demod::DEMOD_SAMPLE_RATE;
22
use adsb_demod::{OutputModuleConfig, OutputModuleManager};
3-
use adsb_demod::{BeastOutput, AvrOutput, RawOutput};
3+
use adsb_demod::{BeastOutput, AvrOutput, RawOutput, Sbs1Output};
44
use adsb_demod::Decoder;
55
use adsb_demod::Demodulator;
66
use adsb_demod::PreambleDetector;
@@ -68,6 +68,12 @@ struct Args {
6868
/// Port for raw format output
6969
#[arg(long, default_value_t = 30002)]
7070
raw_port: u16,
71+
/// Enable SBS-1/BaseStation format output (port 30004 compatible)
72+
#[arg(long)]
73+
sbs1: bool,
74+
/// Port for SBS-1/BaseStation format output
75+
#[arg(long, default_value_t = 30004)]
76+
sbs1_port: u16,
7177
}
7278

7379
fn sample_rate_parser(sample_rate_str: &str) -> Result<f64, String> {
@@ -196,6 +202,19 @@ async fn main() -> Result<()> {
196202
}
197203
}
198204

205+
if args.sbs1 {
206+
let config = OutputModuleConfig::new("sbs1", args.sbs1_port).with_buffer_capacity(1024);
207+
match Sbs1Output::new(config).await {
208+
Ok(module) => {
209+
println!("SBS-1/BaseStation format server started on port {}", args.sbs1_port);
210+
output_manager.add_module(Box::new(module));
211+
}
212+
Err(e) => {
213+
eprintln!("Failed to start SBS-1 server: {}", e);
214+
}
215+
}
216+
}
217+
199218
// Create tracker with dynamic output module system
200219
let prune_after = args.lifetime.map(Duration::from_secs);
201220
let tracker = Tracker::new_with_modules(prune_after, output_manager);

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ pub use avr_output::{AvrBroadcaster, AvrMessage, AvrServer, AvrOutput, AvrOutput
3737
mod raw_output;
3838
pub use raw_output::{RawBroadcaster, RawMessage, RawServer, RawOutput, RawOutputBuilder};
3939

40+
mod sbs1_output;
41+
pub use sbs1_output::{Sbs1Broadcaster, Sbs1Message, Sbs1Server, Sbs1Output, Sbs1OutputBuilder};
42+
4043
mod output_module;
4144
pub use output_module::{OutputModule, OutputModuleBuilder, OutputModuleConfig, OutputModuleManager, OutputModuleRegistry};
4245

0 commit comments

Comments
 (0)