@@ -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)
120129cargo 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```
0 commit comments