Skip to content

Commit

Permalink
feat: modem interface with AT command parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
akosnad committed Nov 14, 2024
1 parent 29501e9 commit 65b2480
Show file tree
Hide file tree
Showing 12 changed files with 655 additions and 145 deletions.
158 changes: 149 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ embassy-net = { version = "0.4.0", features = ["dhcpv4", "dhcpv4-hostname", "dns
static_cell = { version = "2.1.0", features = ["nightly"] }
embedded-io-async = { version = "0.6.1", features = ["alloc"] }
embassy-sync = "0.6.0"
embassy-futures = "0.1.1"
atat = { version = "0.23.0", features = ["heapless", "log"] }

[profile.dev]
# Rust debug is too slow.
Expand All @@ -57,6 +59,10 @@ lto = 'fat'
opt-level = 's'
overflow-checks = false

[build-dependencies]
serde = { version = "1.0.210", features = ["derive"] }
serde_yaml = "0.9.34"

[package.metadata.espflash]
partition_table = "partitions.csv"

20 changes: 20 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
#[derive(serde::Deserialize)]
struct Config {
wifi_ssid: String,
wifi_password: String,
}

impl Config {
fn export_vars(&self) {
println!("cargo:rustc-env=WIFI_SSID={}", self.wifi_ssid);
println!("cargo:rustc-env=WIFI_PASSWORD={}", self.wifi_password);
}
}

fn main() {
println!("cargo:rustc-link-arg-bins=-Tlinkall.x");

println!("cargo:rustc-link-arg-bins=-Trom_functions.x");

println!("cargo:rerun-if-changed=config.yml");
let config = {
let config_string = std::fs::read_to_string("config.yml").expect("config.yml not found");
serde_yaml::from_str::<Config>(&config_string).expect("config.yml is not valid")
};
config.export_vars();
}
16 changes: 12 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
craneLib = crane.mkLib pkgs;
craneToolchain = craneLib.overrideToolchain rustToolchain;
src = craneLib.cleanCargoSource ./.;
commonArgs = rec {
commonArgs = {
inherit src;
cargoVendorDir = craneLib.vendorMultipleCargoDeps {
cargoLockList = [
Expand Down Expand Up @@ -87,9 +87,17 @@
buildInputs = with pkgs; [
openssl
pkg-config
esp-idf-esp32
esp-idf-esp32-with-clang
];
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (buildInputs ++ [ rustToolchain ]);

# FIXME: this is a hack for cargo to find our linker
CARGO_TARGET_XTENSA_ESP32_NONE_ELF_LINKER =
let
deps = pkgs.esp-idf-esp32-with-clang.propagatedBuildInputs;
idfName = pkgs.esp-idf-esp32-with-clang.name;
targetPkg = builtins.head (builtins.filter (p: p.name == "esp-clang-${idfName}") deps);
in
"${targetPkg}/bin/xtensa-esp32-elf-ld";
};

cargoArtifacts = craneToolchain.buildDepsOnly commonArgs;
Expand All @@ -108,7 +116,7 @@
buildInputs = [
openssl
pkg-config
esp-idf-esp32
esp-idf-esp32-with-clang

rustToolchain

Expand Down
Loading

0 comments on commit 65b2480

Please sign in to comment.