29 lines
947 B
Rust
29 lines
947 B
Rust
use std::error::Error;
|
|
|
|
#[toml_cfg::toml_config]
|
|
pub struct Config {
|
|
#[default("")]
|
|
wifi_ssid: &'static str,
|
|
#[default("")]
|
|
wifi_psk: &'static str,
|
|
}
|
|
|
|
fn main() -> Result<(), Box<dyn Error>> {
|
|
// Check if the `cfg.toml` file exists and has been filled out.
|
|
if !std::path::Path::new("cfg.toml").exists() {
|
|
return Err("You need to create a `cfg.toml` file with your Wi-Fi credentials! Start from `cfg.toml.template`.".into());
|
|
}
|
|
|
|
// The constant `CONFIG` is auto-generated by `toml_config`.
|
|
let app_config = CONFIG;
|
|
if app_config.wifi_ssid == "SET_ME" || app_config.wifi_psk == "SET_ME" {
|
|
return Err("You need to set the Wi-Fi credentials in `cfg.toml`!".into());
|
|
}
|
|
|
|
// Necessary because of this issue: https://github.com/rust-lang/cargo/issues/9641
|
|
embuild::build::CfgArgs::output_propagated("ESP_IDF")?;
|
|
embuild::build::LinkArgs::output_propagated("ESP_IDF")?;
|
|
|
|
Ok(())
|
|
}
|