-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a76c1a5
Showing
9 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[build] | ||
target = "xtensa-esp32-espidf" | ||
|
||
[target.xtensa-esp32-espidf] | ||
linker = "ldproxy" | ||
# runner = "espflash --monitor" # Select this runner for espflash v1.x.x | ||
runner = "espflash flash --monitor" # Select this runner for espflash v2.x.x | ||
rustflags = [ "--cfg", "espidf_time64"] # Extending time_t for ESP IDF 5: https://github.com/esp-rs/rust/issues/110 | ||
|
||
[unstable] | ||
build-std = ["std", "panic_abort"] | ||
|
||
[env] | ||
MCU="esp32" | ||
# Note: this variable is not used by the pio builder (`cargo build --features pio`) | ||
ESP_IDF_VERSION = "v5.1.2" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Continuous Integration | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- "**/README.md" | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
rust-checks: | ||
name: Rust Checks | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
action: | ||
- command: build | ||
args: --release | ||
- command: fmt | ||
args: --all -- --check --color always | ||
- command: clippy | ||
args: --all-targets --all-features --workspace -- -D warnings | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Enable caching | ||
uses: Swatinem/rust-cache@v2 | ||
- name: Setup Rust | ||
uses: esp-rs/xtensa-toolchain@v1.5 | ||
with: | ||
default: true | ||
buildtargets: esp32 | ||
ldproxy: true | ||
- name: Run command | ||
run: cargo ${{ matrix.action.command }} ${{ matrix.action.args }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/.vscode | ||
/.embuild | ||
/target | ||
/Cargo.lock | ||
/cfg.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[package] | ||
name = "sensesp-rs" | ||
version = "0.1.0" | ||
authors = ["Carl Middleton <dev@carlcodes.com>"] | ||
edition = "2021" | ||
resolver = "2" | ||
rust-version = "1.71" | ||
|
||
[profile.release] | ||
opt-level = "s" | ||
|
||
[profile.dev] | ||
debug = true # Symbols are nice and they don't increase the size on Flash | ||
opt-level = "z" | ||
|
||
[features] | ||
default = ["std", "embassy", "esp-idf-svc/native"] | ||
pio = ["esp-idf-svc/pio"] | ||
std = ["alloc", "esp-idf-svc/binstart", "esp-idf-svc/std"] | ||
alloc = ["esp-idf-svc/alloc"] | ||
nightly = ["esp-idf-svc/nightly"] | ||
experimental = ["esp-idf-svc/experimental"] | ||
embassy = ["esp-idf-svc/embassy-sync", "esp-idf-svc/critical-section", "esp-idf-svc/embassy-time-driver"] | ||
|
||
[dependencies] | ||
anyhow = "=1.0.75" | ||
esp-idf-svc = { version = "0.48", default-features = false } | ||
log = { version = "0.4", default-features = false } | ||
#rgb-led = { path = "../../common/lib/rgb-led" } | ||
#wifi = { path = "../../common/lib/wifi" } | ||
toml-cfg = "=0.1.3" | ||
|
||
[build-dependencies] | ||
embuild = "0.31.3" | ||
toml-cfg = "=0.1.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#[toml_cfg::toml_config] | ||
pub struct Config { | ||
#[default("")] | ||
wifi_ssid: &'static str, | ||
#[default("")] | ||
wifi_psk: &'static str, | ||
} | ||
|
||
fn main() { | ||
// Check if the `cfg.toml` file exists and has been filled out. | ||
if !std::path::Path::new("cfg.toml").exists() { | ||
panic!("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" { | ||
panic!("You need to set the Wi-Fi credentials in `cfg.toml`!"); | ||
} | ||
|
||
embuild::espidf::sysenv::output(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[hardware-check] | ||
wifi_ssid = "FBI Surveillance Van" | ||
wifi_psk = "hunter1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[toolchain] | ||
channel = "esp" | ||
components = ["rustfmt", "rustc-dev"] | ||
targets = ["xtensa-esp32-none-elf"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Rust often needs a bit of an extra main task stack size compared to C (the default is 3K) | ||
CONFIG_ESP_MAIN_TASK_STACK_SIZE=8000 | ||
|
||
# Use this to set FreeRTOS kernel tick frequency to 1000 Hz (100 Hz by default). | ||
# This allows to use 1 ms granuality for thread sleeps (10 ms by default). | ||
#CONFIG_FREERTOS_HZ=1000 | ||
|
||
# Workaround for https://github.com/espressif/esp-idf/issues/7631 | ||
#CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n | ||
#CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use anyhow::{bail, Result}; | ||
use esp_idf_svc::eventloop::EspSystemEventLoop; | ||
use esp_idf_svc::hal::prelude::Peripherals; | ||
use log::info; | ||
use esp_idf_svc::wifi; | ||
|
||
#[toml_cfg::toml_config] | ||
pub struct Config { | ||
#[default("")] | ||
wifi_ssid: &'static str, | ||
#[default("")] | ||
wifi_psk: &'static str, | ||
} | ||
|
||
fn main() { | ||
// It is necessary to call this function once. Otherwise some patches to the runtime | ||
// implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71 | ||
esp_idf_svc::sys::link_patches(); | ||
|
||
// Bind the log crate to the ESP Logging facilities | ||
esp_idf_svc::log::EspLogger::initialize_default(); | ||
|
||
log::info!("Hello, world!"); | ||
} |