Skip to content

Commit 6eb640a

Browse files
committed
Merge branch 'main' of https://github.com/gvanem/Dump1090
2 parents 26437ab + 3cf284a commit 6eb640a

File tree

5 files changed

+72
-4
lines changed

5 files changed

+72
-4
lines changed

dump1090.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ prefer-adsb-lol = false
7171
error-correct1 = true # Enable 1-bit error correction.
7272
error-correct2 = true # Enable 2-bit error correction.
7373

74-
homepos = 60.3045800,5.3046400 # Change this for your location (no default value).
74+
homepos = -1,-1 # Default unconfigured. setup.exe will run automatically on first launch.
7575
interactive-ttl = 60 # Remove aircraft in interactive-mode if not seen for 60 sec.
7676
location = no # Use `Windows Location API' to get the `$(homepos)'.
7777
logfile = %~dp0\dump1090.log # Write logs to `%~dp0\dump1090.log'.

dump1090.exe

-534 KB
Binary file not shown.

setup.exe

-48 KB
Binary file not shown.

src/dump1090.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ static bool set_if_mode (const char *arg);
118118
static bool set_interactive_ttl (const char *arg);
119119
static bool set_home_pos (const char *arg);
120120
static bool set_home_pos_from_location_API (const char *arg);
121+
static bool launch_setup_exe (void);
121122
static bool set_host_port_raw_in (const char *arg);
122123
static bool set_host_port_raw_out (const char *arg);
123124
static bool set_host_port_sbs_in (const char *arg);
@@ -751,6 +752,31 @@ static bool modeS_init (void)
751752
if (strcmp(Modes.cfg_file, "NUL") && !cfg_open_and_parse(Modes.cfg_file, config))
752753
return (false);
753754

755+
/* Check if homepos is unconfigured (-1,-1) and launch setup.exe */
756+
if (Modes.home_pos_ok && Modes.home_pos.lat == -1.0 && Modes.home_pos.lon == -1.0)
757+
{
758+
LOG_STDERR ("Home position is not configured. Launching setup.exe...\n");
759+
if (!launch_setup_exe())
760+
{
761+
LOG_STDERR ("Setup failed or was cancelled. Cannot proceed without a valid home position.\n");
762+
return (false);
763+
}
764+
/* Reload config to get the updated homepos */
765+
LOG_STDERR ("Reloading configuration...\n");
766+
if (!cfg_open_and_parse(Modes.cfg_file, config))
767+
{
768+
LOG_STDERR ("Failed to reload configuration file.\n");
769+
return (false);
770+
}
771+
/* Verify homepos was updated */
772+
if (!Modes.home_pos_ok || (Modes.home_pos.lat == -1.0 && Modes.home_pos.lon == -1.0))
773+
{
774+
LOG_STDERR ("Home position is still not configured after setup. Cannot proceed.\n");
775+
return (false);
776+
}
777+
LOG_STDERR ("Home position configured: %.6f,%.6f\n", Modes.home_pos.lat, Modes.home_pos.lon);
778+
}
779+
754780
if (Modes.http_ipv6_only)
755781
Modes.http_ipv6 = true;
756782

@@ -4208,6 +4234,46 @@ static void set_debug_bits (const char *flags)
42084234
}
42094235
}
42104236

4237+
/**
4238+
* Launch setup.exe and wait for it to complete.
4239+
* Returns true if setup.exe exits with code 0, false otherwise.
4240+
*/
4241+
static bool launch_setup_exe (void)
4242+
{
4243+
mg_file_path setup_path;
4244+
intptr_t exit_code;
4245+
4246+
/* Construct path to setup.exe in the same directory as the executable */
4247+
snprintf (setup_path, sizeof(setup_path), "%s\\setup.exe", Modes.where_am_I);
4248+
4249+
/* Check if setup.exe exists */
4250+
if (GetFileAttributesA(setup_path) == INVALID_FILE_ATTRIBUTES)
4251+
{
4252+
LOG_STDERR ("setup.exe not found at: %s\n", setup_path);
4253+
LOG_STDERR ("Please ensure setup.exe is in the same directory as dump1090.exe\n");
4254+
return (false);
4255+
}
4256+
4257+
LOG_STDERR ("Launching setup.exe...\n");
4258+
4259+
exit_code = _spawnl (_P_WAIT, setup_path, setup_path, NULL);
4260+
4261+
if (exit_code == -1)
4262+
{
4263+
LOG_STDERR ("Failed to launch setup.exe\n");
4264+
return (false);
4265+
}
4266+
4267+
if (exit_code != 0)
4268+
{
4269+
LOG_STDERR ("Setup exited with code %ld.\n", exit_code);
4270+
return (false);
4271+
}
4272+
4273+
LOG_STDERR ("Setup completed successfully.\n");
4274+
return (true);
4275+
}
4276+
42114277
static bool set_home_pos (const char *arg)
42124278
{
42134279
pos_t pos;

tools/setupwiz/src/main.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ fn query_nominatim(location_query: &str) -> Result<(f64, f64), Box<dyn std::erro
2626

2727
println!("Querying: {}", url);
2828

29-
let client = reqwest::blocking::Client::new();
29+
let client = reqwest::blocking::ClientBuilder::new()
30+
.user_agent("dump1090-setup/1.0 (https://github.com/gvanem/dump1090)")
31+
.build()?;
3032
let response = client.get(&url).send()?;
3133
let results: Vec<NominatimResult> = response.json()?;
3234

@@ -153,9 +155,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
153155
io::stdin().read_line(&mut enable_location)?;
154156
let enable_location = enable_location.trim().to_lowercase();
155157
let location_setting = if enable_location == "y" || enable_location == "yes" {
156-
"true"
158+
"yes"
157159
} else {
158-
"false"
160+
"no"
159161
};
160162

161163
// Read config file

0 commit comments

Comments
 (0)