Formatting
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use clap::Parser;
|
||||
use std::io::{Read, Write};
|
||||
use std::net::{TcpListener, TcpStream};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use clap::Parser;
|
||||
|
||||
// Framing tags
|
||||
const TAG_CONTROL_OUT: u8 = 0x10;
|
||||
@@ -10,8 +10,7 @@ const TAG_CONTROL_IN: u8 = 0x11;
|
||||
const TAG_BULK: u8 = 0x20;
|
||||
|
||||
const ADSB_MESSAGE: [u8; 14] = [
|
||||
0x8D, 0x48, 0x40, 0xD6, 0x20, 0x2C, 0xC3,
|
||||
0x71, 0xC3, 0x2C, 0xE0, 0x57, 0x60, 0x98,
|
||||
0x8D, 0x48, 0x40, 0xD6, 0x20, 0x2C, 0xC3, 0x71, 0xC3, 0x2C, 0xE0, 0x57, 0x60, 0x98,
|
||||
];
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
@@ -84,13 +83,13 @@ fn handle_client_connection(mut connection: TcpStream) {
|
||||
payload_buffer[0],
|
||||
payload_buffer[1],
|
||||
payload_buffer[2],
|
||||
payload_buffer[3]
|
||||
payload_buffer[3],
|
||||
]);
|
||||
println!("SET_FREQ -> {} Hz", current_frequency_hz);
|
||||
}
|
||||
// Acknowledge with a single byte = 0 (OK)
|
||||
connection.write_all(&[0u8]).ok();
|
||||
},
|
||||
}
|
||||
TAG_CONTROL_IN => {
|
||||
dbg!(message_tag);
|
||||
// Simulate a CONTROL_IN reply with a fixed pattern
|
||||
@@ -105,7 +104,7 @@ fn handle_client_connection(mut connection: TcpStream) {
|
||||
// Payload (0x42 repeated)
|
||||
let reply = vec![0x42; payload_length];
|
||||
let _ = connection.write_all(&reply).ok();
|
||||
},
|
||||
}
|
||||
TAG_BULK => {
|
||||
dbg!(message_tag);
|
||||
// Generate a ADS-B IQ burst
|
||||
@@ -123,11 +122,11 @@ fn handle_client_connection(mut connection: TcpStream) {
|
||||
|
||||
// Throttle a bit to simulate real USB/bulk behavior
|
||||
thread::sleep(Duration::from_millis(10));
|
||||
},
|
||||
}
|
||||
_unknown_tag => {
|
||||
// On any unrecognized tag, break out
|
||||
break
|
||||
},
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,8 +157,7 @@ fn generate_adsb_iq_samples() -> Vec<u8> {
|
||||
}
|
||||
|
||||
// Concatenate preamble + data
|
||||
let mut full_bitstream = Vec::with_capacity(
|
||||
preamble_bits.len() * 2 + manchester_bits.len());
|
||||
let mut full_bitstream = Vec::with_capacity(preamble_bits.len() * 2 + manchester_bits.len());
|
||||
|
||||
// Preamble: each '1' or '0' is one microsecond = 2 samples
|
||||
for &pb in preamble_bits.iter() {
|
||||
@@ -175,11 +173,7 @@ fn generate_adsb_iq_samples() -> Vec<u8> {
|
||||
// I = 128 + 127*(bit), Q = 128
|
||||
let mut iq = Vec::with_capacity(full_bitstream.len() * 2);
|
||||
for &level in full_bitstream.iter() {
|
||||
let i_sample = if level == 1 {
|
||||
255u8
|
||||
} else {
|
||||
128u8
|
||||
};
|
||||
let i_sample = if level == 1 { 255u8 } else { 128u8 };
|
||||
let q_sample = 128u8;
|
||||
iq.push(i_sample);
|
||||
iq.push(q_sample);
|
||||
|
||||
Reference in New Issue
Block a user