Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .devcontainer/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,22 @@ WORK_DIR=/workspace/$1
echo "Compiling $1"

cd /workspace/$1

if [ -f cfg.toml.example ]; then
# Rename file to cfg.toml
mv cfg.toml.example cfg.toml
# Replace defaults
sed -i 's/wifi_ssid = "FBI Surveillance Van"/wifi_ssid = "ssid"/g' cfg.toml
sed -i 's/wifi_psk = "hunter2"/wifi_psk = "pass"/g' cfg.toml
sed -i 's/mqtt_user = "horse"/mqtt_user = "user"/g' cfg.toml
sed -i 's/mqtt_pass = "CorrectHorseBatteryStaple"/mqtt_pass = "pass"/g' cfg.toml
sed -i 's/mqtt_host = "yourpc.local"/mqtt_host = "host"/g' cfg.toml
fi

$HOME/.cargo/bin/cargo clean
$HOME/.cargo/bin/cargo build

# Check examples
if [[ "$1" == advanced/button-interrupt ]]; then
$HOME/.cargo/bin/cargo build --example solution
$HOME/.cargo/bin/cargo build --example solution_led
Expand Down
1 change: 1 addition & 0 deletions intro/hardware-check/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ ignore = "=0.4.11"
[build-dependencies]
embuild = "0.28"
anyhow = "1"
toml-cfg = "0.1"
20 changes: 19 additions & 1 deletion intro/hardware-check/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
#[toml_cfg::toml_config]
pub struct Config {
#[default("")]
wifi_ssid: &'static str,
#[default("")]
wifi_psk: &'static str,
}

fn main() -> anyhow::Result<()> {
// Necessary because of this issue: https://github.com/rust-lang/cargo/issues/9641
// Check if the `cfg.toml` file exists and has been filled out.
if !std::path::Path::new("cfg.toml").exists() {
anyhow::bail!("You need to create a `cfg.toml` file with your Wi-Fi credentials! Use `cfg.toml.example` as a template.");
}

// The constant `CONFIG` is auto-generated by `toml_config`.
let app_config = CONFIG;
if app_config.wifi_ssid == "FBI Surveillance Van" || app_config.wifi_psk == "hunter2" {
anyhow::bail!("You need to set the Wi-Fi credentials in `cfg.toml`!");
}

// 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")
}
4 changes: 2 additions & 2 deletions intro/http-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ resolver = "2"
opt-level = "s"

[profile.dev]
debug = true # Symbols are nice and they don't increase the size on Flash
debug = true # Symbols are nice and they don't increase the size on Flash
opt-level = "z"

[features]
Expand All @@ -28,4 +28,4 @@ ignore = "=0.4.11"
[build-dependencies]
embuild = "0.28"
anyhow = "1"

toml-cfg = "0.1"
20 changes: 19 additions & 1 deletion intro/http-client/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
#[toml_cfg::toml_config]
pub struct Config {
#[default("")]
wifi_ssid: &'static str,
#[default("")]
wifi_psk: &'static str,
}

fn main() -> anyhow::Result<()> {
// Necessary because of this issue: https://github.com/rust-lang/cargo/issues/9641
// Check if the `cfg.toml` file exists and has been filled out.
if !std::path::Path::new("cfg.toml").exists() {
anyhow::bail!("You need to create a `cfg.toml` file with your Wi-Fi credentials! Use `cfg.toml.example` as a template.");
}

// The constant `CONFIG` is auto-generated by `toml_config`.
let app_config = CONFIG;
if app_config.wifi_ssid == "FBI Surveillance Van" || app_config.wifi_psk == "hunter2" {
anyhow::bail!("You need to set the Wi-Fi credentials in `cfg.toml`!");
}

// 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")
}
3 changes: 2 additions & 1 deletion intro/http-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ resolver = "2"
opt-level = "s"

[profile.dev]
debug = true # Symbols are nice and they don't increase the size on Flash
debug = true # Symbols are nice and they don't increase the size on Flash
opt-level = "z"

[features]
Expand All @@ -29,3 +29,4 @@ ignore = "=0.4.11"
[build-dependencies]
embuild = "0.28"
anyhow = "1"
toml-cfg = "0.1"
20 changes: 19 additions & 1 deletion intro/http-server/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
#[toml_cfg::toml_config]
pub struct Config {
#[default("")]
wifi_ssid: &'static str,
#[default("")]
wifi_psk: &'static str,
}

fn main() -> anyhow::Result<()> {
// Necessary because of this issue: https://github.com/rust-lang/cargo/issues/9641
// Check if the `cfg.toml` file exists and has been filled out.
if !std::path::Path::new("cfg.toml").exists() {
anyhow::bail!("You need to create a `cfg.toml` file with your Wi-Fi credentials! Use `cfg.toml.example` as a template.");
}

// The constant `CONFIG` is auto-generated by `toml_config`.
let app_config = CONFIG;
if app_config.wifi_ssid == "FBI Surveillance Van" || app_config.wifi_psk == "hunter2" {
anyhow::bail!("You need to set the Wi-Fi credentials in `cfg.toml`!");
}

// 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")
}
5 changes: 3 additions & 2 deletions intro/mqtt/exercise/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ resolver = "2"
opt-level = "s"

[profile.dev]
debug = true # Symbols are nice and they don't increase the size on Flash
debug = true # Symbols are nice and they don't increase the size on Flash
opt-level = "z"

[features]
Expand All @@ -18,7 +18,7 @@ native = ["esp-idf-sys/native"]

[dependencies]
esp-idf-sys = { version = "=0.31.5", features = ["binstart"] }
esp-idf-svc = { version="=0.41.4", features = ["experimental", "alloc"] }
esp-idf-svc = { version = "=0.41.4", features = ["experimental", "alloc"] }
embedded-svc = "=0.21"
esp32-c3-dkc02-bsc = { path = "../../../common/lib/esp32-c3-dkc02-bsc" }
log = "0.4"
Expand All @@ -33,3 +33,4 @@ ignore = "=0.4.11"
[build-dependencies]
embuild = "0.28"
anyhow = "1"
toml-cfg = "0.1"
28 changes: 28 additions & 0 deletions intro/mqtt/exercise/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
#[toml_cfg::toml_config]
pub struct Config {
#[default("localhost")]
mqtt_host: &'static str,
#[default("")]
mqtt_user: &'static str,
#[default("")]
mqtt_pass: &'static str,
#[default("")]
wifi_ssid: &'static str,
#[default("")]
wifi_psk: &'static str,
}

fn main() -> anyhow::Result<()> {
// Check if the `cfg.toml` file exists and has been filled out.
if !std::path::Path::new("cfg.toml").exists() {
anyhow::bail!("You need to create a `cfg.toml` file with your Wi-Fi credentials! Use `cfg.toml.example` as a template.");
}

// The constant `CONFIG` is auto-generated by `toml_config`.
let app_config = CONFIG;
if app_config.wifi_ssid == "FBI Surveillance Van" || app_config.wifi_psk == "hunter2" {
anyhow::bail!("You need to set the Wi-Fi credentials in `cfg.toml`!");
}
if app_config.mqtt_host == "yourpc.local" || app_config.mqtt_user == "horse" || app_config.mqtt_pass == "CorrectHorseBatteryStaple" {
anyhow::bail!("You need to set the MQTT credentials in `cfg.toml`!");
}

// 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")
Expand Down