Skip to content

Commit 951e8ff

Browse files
committed
feat: Add WebSocket output format
1 parent 0f2f427 commit 951e8ff

File tree

11 files changed

+9663
-5
lines changed

11 files changed

+9663
-5
lines changed

.cargo/config.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[build]
2+
rustc-wrapper = "sccache"
3+
# .cargo/config.toml
4+
[target.x86_64-apple-darwin]
5+
rustflags = [
6+
"-C", "link-arg=-fuse-ld=lld",
7+
"-C", "target-cpu=native"
8+
]
9+
10+

CLAUDE.md

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,67 @@ AviAware supports multiple output formats for compatibility with various ADS-B t
113113
- [BaseStation Protocol](http://woodair.net/sbs/article/barebones42_socket_data.htm)
114114
- [SBS-1 Data Format](http://www.homepages.mcb.net/bones/SBS/Article/Barebones42_Socket_Data.htm)
115115

116+
### WebSocket Format (Port 8080)
117+
- **Default**: Disabled by default
118+
- **Description**: Real-time WebSocket streaming with BEAST format messages
119+
- **Usage**: `--websocket`, `--websocket-port <PORT>`
120+
- **Protocol**: Binary WebSocket messages containing BEAST-encoded ADS-B data
121+
- **Compatibility**: Web browsers, JavaScript applications, real-time web dashboards
122+
- **Message Format**: Each WebSocket message contains a complete BEAST-format packet
123+
- **Use Cases**: Real-time web applications, live flight tracking interfaces, custom dashboards
124+
116125
## Example Usage
117126

118127
```bash
119128
# Run with defaults (BEAST + Raw)
120129
cargo run
121130

122131
# Enable all output formats
123-
cargo run -- --avr --sbs1
132+
cargo run -- --avr --sbs1 --websocket
124133

125134
# Custom ports to avoid conflicts
126-
cargo run -- --beast-port 40005 --raw-port 40002 --sbs1-port 40004
135+
cargo run -- --beast-port 40005 --raw-port 40002 --sbs1-port 40004 --websocket-port 9090
136+
137+
# Enable only WebSocket output for web applications
138+
cargo run -- --no-beast --no-raw --websocket
139+
140+
# Enable SBS-1 and WebSocket for comprehensive coverage
141+
cargo run -- --sbs1 --websocket
142+
```
127143

128-
# Enable only SBS-1 output
129-
cargo run -- --no-beast --no-raw --sbs1
144+
## WebSocket Usage Example
145+
146+
For web applications connecting to the WebSocket output:
147+
148+
```javascript
149+
// Connect to AviAware WebSocket server
150+
const ws = new WebSocket('ws://localhost:8080');
151+
152+
// Handle binary BEAST messages
153+
ws.onmessage = function(event) {
154+
// event.data is an ArrayBuffer containing BEAST format data
155+
const data = new Uint8Array(event.data);
156+
157+
// BEAST format: [0x1A, type, timestamp(6), signal, payload...]
158+
if (data[0] === 0x1A) { // BEAST escape character
159+
const messageType = data[1]; // 0x31=short, 0x32=long
160+
const timestamp = data.slice(2, 8); // 6 bytes
161+
const signal = data[8]; // Signal strength
162+
const payload = data.slice(9); // ADS-B message
163+
164+
console.log('ADS-B Message:', {
165+
type: messageType === 0x31 ? 'short' : 'long',
166+
signal: signal,
167+
data: Array.from(payload).map(b => b.toString(16).padStart(2, '0')).join('')
168+
});
169+
}
170+
};
171+
172+
ws.onopen = function() {
173+
console.log('Connected to AviAware WebSocket stream');
174+
};
175+
176+
ws.onerror = function(error) {
177+
console.error('WebSocket error:', error);
178+
};
130179
```

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,6 @@ serde = { version = "1", features = ["derive"] }
3232
serde_json = "1"
3333
serde_with = "3"
3434
tokio = { version = "1", features = ["net", "io-util", "rt", "sync", "macros", "rt-multi-thread"] }
35+
tokio-tungstenite = "0.20"
36+
futures-util = "0.3"
3537
tracing = "0.1"

WARP.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CLAUDE.md

0 commit comments

Comments
 (0)