Skip to content

Commit

Permalink
Add debug output and no ephemeris option (#221)
Browse files Browse the repository at this point in the history
A companion PR to swift-nav/pings#7 which adds
the same two options:
* `--debug` is similar to `--verbose` but includes the cURL info type.
This makes it a bit easier to decipher what the verbose data represents
* `--no-eph` which includes a header requesting that no ephemeris is
sent down on connection
  • Loading branch information
jbangelo authored Mar 13, 2024
1 parent 2c0bc5e commit e956faa
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,14 @@ struct Cli {
)]
client_id: String,

/// Enable verbose curl output
#[arg(short, long)]
verbose: bool,

/// Enable curl debug output. This implicitly enables verbose output
#[arg(short, long)]
debug: bool,

/// Receiver time to report, as a Unix time
#[arg(long)]
epoch: Option<u32>,
Expand Down Expand Up @@ -104,6 +109,10 @@ struct Cli {
/// Path to a YAML file containing a list of messages to send to the caster
#[arg(long)]
input: Option<PathBuf>,

/// Request that no ephemeris is sent on connection
#[arg(long)]
no_eph: bool,
}

#[derive(Debug, Clone, Copy, serde::Deserialize)]
Expand Down Expand Up @@ -293,6 +302,10 @@ fn run() -> Result<()> {
}
}

if opt.no_eph {
headers.append("X-No-Ephemerides-On-Connection: True")?;
}

curl.http_headers(headers)?;
curl.useragent("NTRIP ntrip-client/1.0")?;
curl.url(&opt.url)?;
Expand All @@ -302,10 +315,18 @@ fn run() -> Result<()> {
curl.http_version(HttpVersion::Any)?;
curl.http_09_allowed(true)?;

if opt.verbose {
if opt.verbose || opt.debug {
curl.verbose(true)?;
}

if opt.debug {
curl.debug_function(|info, data| {
eprintln!("\n-----\nDEBUG - infotype = {:?}\n-----", info);
let _ = io::stderr().write_all(data);
eprintln!("-----");
})?;
}

if let Some(username) = &opt.username {
curl.username(username)?;
}
Expand Down

0 comments on commit e956faa

Please sign in to comment.