From 4dceb5b597ae98ec224cc60e4bb09abf9deefda2 Mon Sep 17 00:00:00 2001 From: aOK Date: Tue, 2 Jan 2024 19:37:23 +0300 Subject: [PATCH] first commit --- .cargo/config.toml | 13 + .gitignore | 1 + Cargo.lock | 1291 +++++++++++++++++++++++++++++++ Cargo.toml | 59 ++ README.md | 0 build.rs | 5 + rust-toolchain-stable.toml | 13 + rust-toolchain.toml | 15 + src/common/general/mod.rs | 34 + src/common/general/responses.rs | 30 + src/common/general/urc.rs | 4 + src/common/mod.rs | 18 + src/lib.rs | 87 +++ src/main.rs | 309 ++++++++ 14 files changed, 1879 insertions(+) create mode 100644 .cargo/config.toml create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 README.md create mode 100644 build.rs create mode 100644 rust-toolchain-stable.toml create mode 100644 rust-toolchain.toml create mode 100644 src/common/general/mod.rs create mode 100644 src/common/general/responses.rs create mode 100644 src/common/general/urc.rs create mode 100644 src/common/mod.rs create mode 100644 src/lib.rs create mode 100644 src/main.rs diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..839dd56 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,13 @@ +[target.'cfg(all(target_arch = "arm", target_os = "none"))'] +# replace STM32F429ZITx with your chip as listed in `probe-rs chip list` +runner = "probe-rs run --chip STM32F429ZITx --speed 10000000" + +[build] +target = "thumbv7em-none-eabi" + +[env] +DEFMT_LOG = "trace" + + +[unstable] +build-std = ["alloc", "core"] diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..587efeb --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1291 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "as-slice" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45403b49e3954a4b8428a0ac21a4b7afadccf92bfd96273f1a58cd4812496ae0" +dependencies = [ + "generic-array 0.12.4", + "generic-array 0.13.3", + "generic-array 0.14.7", + "stable_deref_trait", +] + +[[package]] +name = "as-slice" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "516b6b4f0e40d50dcda9365d53964ec74560ad4284da2e7fc97122cd83174516" +dependencies = [ + "stable_deref_trait", +] + +[[package]] +name = "atat" +version = "0.20.0" +source = "git+https://github.com/BlackbirdHQ/atat?branch=master#fe971a4d17b6dd5ef9edb14fe2e68cb9925a2865" +dependencies = [ + "atat_derive 0.20.0 (git+https://github.com/BlackbirdHQ/atat?branch=master)", + "embassy-sync", + "embassy-time", + "embedded-io", + "embedded-io-async", + "futures", + "heapless 0.8.0", + "heapless-bytes", + "log", + "nom", + "serde_at 0.20.0 (git+https://github.com/BlackbirdHQ/atat?branch=master)", + "serde_bytes", +] + +[[package]] +name = "atat" +version = "0.20.0" +source = "git+https://github.com/BlackbirdHQ/atat?rev=fe971a4#fe971a4d17b6dd5ef9edb14fe2e68cb9925a2865" +dependencies = [ + "atat_derive 0.20.0 (git+https://github.com/BlackbirdHQ/atat?rev=fe971a4)", + "embassy-sync", + "embassy-time", + "embedded-io", + "embedded-io-async", + "futures", + "heapless 0.8.0", + "heapless-bytes", + "nom", + "serde_at 0.20.0 (git+https://github.com/BlackbirdHQ/atat?rev=fe971a4)", + "serde_bytes", +] + +[[package]] +name = "atat_derive" +version = "0.20.0" +source = "git+https://github.com/BlackbirdHQ/atat?branch=master#fe971a4d17b6dd5ef9edb14fe2e68cb9925a2865" +dependencies = [ + "proc-macro2", + "quote", + "serde_at 0.20.0 (git+https://github.com/BlackbirdHQ/atat?branch=master)", + "syn 2.0.46", +] + +[[package]] +name = "atat_derive" +version = "0.20.0" +source = "git+https://github.com/BlackbirdHQ/atat?rev=fe971a4#fe971a4d17b6dd5ef9edb14fe2e68cb9925a2865" +dependencies = [ + "proc-macro2", + "quote", + "serde_at 0.20.0 (git+https://github.com/BlackbirdHQ/atat?rev=fe971a4)", + "syn 2.0.46", +] + +[[package]] +name = "atomic-polyfill" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4" +dependencies = [ + "critical-section", +] + +[[package]] +name = "atomic-pool" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58c5fc22e05ec2884db458bf307dc7b278c9428888d2b6e6fad9c0ae7804f5f6" +dependencies = [ + "as-slice 0.1.5", + "as-slice 0.2.1", + "atomic-polyfill", + "stable_deref_trait", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bare-metal" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3" +dependencies = [ + "rustc_version 0.2.3", +] + +[[package]] +name = "bit_field" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" + +[[package]] +name = "bitfield" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bxcan" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ac3d0c0a542d0ab5521211f873f62706a7136df415676f676d347e5a41dd80" +dependencies = [ + "bitflags", + "defmt", + "embedded-hal 0.2.7", + "nb 1.1.0", + "vcell", +] + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +dependencies = [ + "num-traits", +] + +[[package]] +name = "cortex-m" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ec610d8f49840a5b376c69663b6369e71f4b34484b9b2eb29fb918d92516cb9" +dependencies = [ + "bare-metal", + "bitfield", + "critical-section", + "embedded-hal 0.2.7", + "volatile-register", +] + +[[package]] +name = "cortex-m-rt" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee84e813d593101b1723e13ec38b6ab6abbdbaaa4546553f5395ed274079ddb1" +dependencies = [ + "cortex-m-rt-macros", +] + +[[package]] +name = "cortex-m-rt-macros" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f6f3e36f203cfedbc78b357fb28730aa2c6dc1ab060ee5c2405e843988d3c7" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "critical-section" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" + +[[package]] +name = "darling" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.46", +] + +[[package]] +name = "darling_macro" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.46", +] + +[[package]] +name = "defmt" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8a2d011b2fee29fb7d659b83c43fce9a2cb4df453e16d441a51448e448f3f98" +dependencies = [ + "bitflags", + "defmt-macros", +] + +[[package]] +name = "defmt-macros" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54f0216f6c5acb5ae1a47050a6645024e6edafc2ee32d421955eccfef12ef92e" +dependencies = [ + "defmt-parser", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.46", +] + +[[package]] +name = "defmt-parser" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "269924c02afd7f94bc4cecbfa5c379f6ffcf9766b3408fe63d22c728654eccd0" +dependencies = [ + "thiserror", +] + +[[package]] +name = "defmt-rtt" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "609923761264dd99ed9c7d209718cda4631c5fe84668e0f0960124cbb844c49f" +dependencies = [ + "critical-section", + "defmt", +] + +[[package]] +name = "document-features" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef5282ad69563b5fc40319526ba27e0e7363d552a896f0297d54f767717f9b95" +dependencies = [ + "litrs", +] + +[[package]] +name = "embassy-embedded-hal" +version = "0.1.0" +source = "git+https://github.com/embassy-rs/embassy?branch=main#9c2d2ff64d302437e2e0568372c76bf37bbfacf4" +dependencies = [ + "defmt", + "embassy-futures", + "embassy-sync", + "embassy-time", + "embedded-hal 0.2.7", + "embedded-hal 1.0.0-rc.3", + "embedded-hal-async", + "embedded-storage", + "embedded-storage-async", + "nb 1.1.0", +] + +[[package]] +name = "embassy-executor" +version = "0.4.0" +source = "git+https://github.com/embassy-rs/embassy?branch=main#9c2d2ff64d302437e2e0568372c76bf37bbfacf4" +dependencies = [ + "cortex-m", + "critical-section", + "defmt", + "document-features", + "embassy-executor-macros", + "embassy-time", +] + +[[package]] +name = "embassy-executor-macros" +version = "0.4.0" +source = "git+https://github.com/embassy-rs/embassy?branch=main#9c2d2ff64d302437e2e0568372c76bf37bbfacf4" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.46", +] + +[[package]] +name = "embassy-futures" +version = "0.1.1" +source = "git+https://github.com/embassy-rs/embassy?branch=main#9c2d2ff64d302437e2e0568372c76bf37bbfacf4" + +[[package]] +name = "embassy-hal-internal" +version = "0.1.0" +source = "git+https://github.com/embassy-rs/embassy?branch=main#9c2d2ff64d302437e2e0568372c76bf37bbfacf4" +dependencies = [ + "cortex-m", + "critical-section", + "defmt", + "num-traits", +] + +[[package]] +name = "embassy-net" +version = "0.2.1" +source = "git+https://github.com/embassy-rs/embassy?branch=main#9c2d2ff64d302437e2e0568372c76bf37bbfacf4" +dependencies = [ + "as-slice 0.2.1", + "atomic-pool", + "defmt", + "document-features", + "embassy-net-driver", + "embassy-sync", + "embassy-time", + "embedded-io-async", + "embedded-nal-async", + "futures", + "generic-array 0.14.7", + "heapless 0.8.0", + "managed", + "smoltcp", + "stable_deref_trait", +] + +[[package]] +name = "embassy-net-driver" +version = "0.2.0" +source = "git+https://github.com/embassy-rs/embassy?branch=main#9c2d2ff64d302437e2e0568372c76bf37bbfacf4" +dependencies = [ + "defmt", +] + +[[package]] +name = "embassy-net-driver-channel" +version = "0.2.0" +source = "git+https://github.com/embassy-rs/embassy?branch=main#9c2d2ff64d302437e2e0568372c76bf37bbfacf4" +dependencies = [ + "embassy-futures", + "embassy-net-driver", + "embassy-sync", +] + +[[package]] +name = "embassy-stm32" +version = "0.1.0" +source = "git+https://github.com/embassy-rs/embassy?branch=main#9c2d2ff64d302437e2e0568372c76bf37bbfacf4" +dependencies = [ + "bit_field", + "bxcan", + "cfg-if", + "chrono", + "cortex-m", + "cortex-m-rt", + "critical-section", + "defmt", + "document-features", + "embassy-embedded-hal", + "embassy-futures", + "embassy-hal-internal", + "embassy-net-driver", + "embassy-sync", + "embassy-time", + "embassy-usb-driver", + "embedded-hal 0.2.7", + "embedded-hal 1.0.0-rc.3", + "embedded-hal-async", + "embedded-hal-nb", + "embedded-io", + "embedded-io-async", + "embedded-storage", + "embedded-storage-async", + "futures", + "nb 1.1.0", + "proc-macro2", + "quote", + "rand_core", + "sdio-host", + "stm32-fmc", + "stm32-metapac", + "vcell", +] + +[[package]] +name = "embassy-sync" +version = "0.5.0" +source = "git+https://github.com/embassy-rs/embassy?branch=main#9c2d2ff64d302437e2e0568372c76bf37bbfacf4" +dependencies = [ + "cfg-if", + "critical-section", + "defmt", + "embedded-io-async", + "futures-util", + "heapless 0.8.0", +] + +[[package]] +name = "embassy-time" +version = "0.2.0" +source = "git+https://github.com/embassy-rs/embassy?branch=main#9c2d2ff64d302437e2e0568372c76bf37bbfacf4" +dependencies = [ + "cfg-if", + "critical-section", + "defmt", + "document-features", + "embedded-hal 0.2.7", + "embedded-hal 1.0.0-rc.3", + "embedded-hal-async", + "futures-util", + "heapless 0.8.0", +] + +[[package]] +name = "embassy-usb" +version = "0.1.0" +source = "git+https://github.com/embassy-rs/embassy?branch=main#9c2d2ff64d302437e2e0568372c76bf37bbfacf4" +dependencies = [ + "defmt", + "embassy-futures", + "embassy-net-driver-channel", + "embassy-sync", + "embassy-usb-driver", + "heapless 0.8.0", + "ssmarshal", + "usbd-hid", +] + +[[package]] +name = "embassy-usb-driver" +version = "0.1.0" +source = "git+https://github.com/embassy-rs/embassy?branch=main#9c2d2ff64d302437e2e0568372c76bf37bbfacf4" +dependencies = [ + "defmt", +] + +[[package]] +name = "embedded-alloc" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddae17915accbac2cfbc64ea0ae6e3b330e6ea124ba108dada63646fd3c6f815" +dependencies = [ + "critical-section", + "linked_list_allocator", +] + +[[package]] +name = "embedded-hal" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35949884794ad573cf46071e41c9b60efb0cb311e3ca01f7af807af1debc66ff" +dependencies = [ + "nb 0.1.3", + "void", +] + +[[package]] +name = "embedded-hal" +version = "1.0.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc402f79e1fd22731ca945b4f97b5ff37e7b3f379312595c42bb2e8811c29920" + +[[package]] +name = "embedded-hal-async" +version = "1.0.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa1fba2ef2ffb35d614acc6fb323ddf7facc45c069f24544d49ea54e5043626d" +dependencies = [ + "embedded-hal 1.0.0-rc.3", +] + +[[package]] +name = "embedded-hal-nb" +version = "1.0.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cde58312a0675b6c0389eb0dceb2bf8c735a697b0b5baa1f23bbaf030636deb" +dependencies = [ + "embedded-hal 1.0.0-rc.3", + "nb 1.1.0", +] + +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" +dependencies = [ + "defmt", +] + +[[package]] +name = "embedded-io-async" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ff09972d4073aa8c299395be75161d582e7629cd663171d62af73c8d50dba3f" +dependencies = [ + "defmt", + "embedded-io", +] + +[[package]] +name = "embedded-nal" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8a943fad5ed3d3f8a00f1e80f6bba371f1e7f0df28ec38477535eb318dc19cc" +dependencies = [ + "nb 1.1.0", + "no-std-net", +] + +[[package]] +name = "embedded-nal-async" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72229137a4fc12d239b0b7f50f04b30790678da6d782a0f3f1909bf57ec4b759" +dependencies = [ + "embedded-io-async", + "embedded-nal", + "no-std-net", +] + +[[package]] +name = "embedded-storage" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21dea9854beb860f3062d10228ce9b976da520a73474aed3171ec276bc0c032" + +[[package]] +name = "embedded-storage-async" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1763775e2323b7d5f0aa6090657f5e21cfa02ede71f5dc40eead06d64dcd15cc" +dependencies = [ + "embedded-storage", +] + +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-intrusive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" +dependencies = [ + "futures-core", + "lock_api", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.46", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-core", + "futures-macro", + "futures-sink", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f797e67af32588215eaaab8327027ee8e71b9dd0b2b26996aedf20c030fce309" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "hash32" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67" +dependencies = [ + "byteorder", +] + +[[package]] +name = "hash32" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" +dependencies = [ + "byteorder", +] + +[[package]] +name = "heapless" +version = "0.7.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f" +dependencies = [ + "atomic-polyfill", + "hash32 0.2.1", + "rustc_version 0.4.0", + "spin", + "stable_deref_trait", +] + +[[package]] +name = "heapless" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" +dependencies = [ + "defmt", + "hash32 0.3.1", + "serde", + "stable_deref_trait", +] + +[[package]] +name = "heapless-bytes" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7285eba272c6af3e9f15fb9e1c1b6e7d35aa70580ffe0d47af017e97dfb6f48b" +dependencies = [ + "heapless 0.7.17", + "serde", + "typenum", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "linked_list_allocator" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" +dependencies = [ + "spinning_top", +] + +[[package]] +name = "litrs" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" + +[[package]] +name = "lock_api" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "managed" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ca88d725a0a943b096803bd34e73a4437208b6077654cc4ecb2947a5f91618d" + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "micromath" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c8dda44ff03a2f238717214da50f65d5a53b45cd213a7370424ffdb6fae815" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nb" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" +dependencies = [ + "nb 1.1.0", +] + +[[package]] +name = "nb" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" + +[[package]] +name = "no-std-net" +version = "0.6.0" +source = "git+https://github.com/rushmorem/no-std-net?branch=issue-15#c57e56ff4ee4653bf17f8bd35dc2fd0f56dc74e7" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "panic-probe" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa6fa5645ef5a760cd340eaa92af9c1ce131c8c09e7f8926d8a24b59d26652b9" +dependencies = [ + "cortex-m", + "defmt", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "portable-atomic" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver 0.9.0", +] + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver 1.0.20", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "sdio-host" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93c025f9cfe4c388c328ece47d11a54a823da3b5ad0370b22d95ad47137f85a" + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "serde" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b114498256798c94a0689e1a15fec6005dee8ac1f41de56404b67afc2a4b773" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_at" +version = "0.20.0" +source = "git+https://github.com/BlackbirdHQ/atat?branch=master#fe971a4d17b6dd5ef9edb14fe2e68cb9925a2865" +dependencies = [ + "num-traits", + "serde", +] + +[[package]] +name = "serde_at" +version = "0.20.0" +source = "git+https://github.com/BlackbirdHQ/atat?rev=fe971a4#fe971a4d17b6dd5ef9edb14fe2e68cb9925a2865" +dependencies = [ + "num-traits", + "serde", +] + +[[package]] +name = "serde_bytes" +version = "0.11.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bb1879ea93538b78549031e2d54da3e901fd7e75f2e4dc758d760937b123d10" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3385e45322e8f9931410f01b3031ec534c3947d0e94c18049af4d9f9907d4e0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.46", +] + +[[package]] +name = "simcom-gprs-driver" +version = "0.1.0" +source = "git+https://github.com/rmja/chip-drivers.git?branch=master#6f85699ba9e724f958434ca5ee7e9c4cbc338285" +dependencies = [ + "atat 0.20.0 (git+https://github.com/BlackbirdHQ/atat?rev=fe971a4)", + "embassy-sync", + "embassy-time", + "embedded-hal 1.0.0-rc.3", + "embedded-io", + "embedded-io-async", + "embedded-nal-async", + "futures", + "futures-intrusive", + "heapless 0.8.0", + "heapless-bytes", + "serde", +] + +[[package]] +name = "smoltcp" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a1a996951e50b5971a2c8c0fa05a381480d70a933064245c4a223ddc87ccc97" +dependencies = [ + "bitflags", + "byteorder", + "cfg-if", + "defmt", + "heapless 0.8.0", + "managed", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + +[[package]] +name = "spinning_top" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0" +dependencies = [ + "lock_api", +] + +[[package]] +name = "ssmarshal" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3e6ad23b128192ed337dfa4f1b8099ced0c2bf30d61e551b65fda5916dbb850" +dependencies = [ + "encode_unicode", + "serde", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "static_cell" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa6ba4cf83bf80d3eb25f098ea5e790a0a1fcb5e357442259b231e412c2d3ca0" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "stm32-fmc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830ed60f33e6194ecb377f5d6ab765dc0e37e7b65e765f1fa87df13336658d63" +dependencies = [ + "embedded-hal 0.2.7", +] + +[[package]] +name = "stm32-metapac" +version = "14.0.0" +source = "git+https://github.com/embassy-rs/stm32-data-generated?tag=stm32-data-8caf2f0bda28baf4393899dc67ba57f058087f5a#84082dac601f365d2d3deed9b460b88877ef9120" +dependencies = [ + "cortex-m", + "cortex-m-rt", +] + +[[package]] +name = "stmspeedgovdevice" +version = "0.1.0" +dependencies = [ + "atat 0.20.0 (git+https://github.com/BlackbirdHQ/atat?branch=master)", + "chrono", + "cortex-m", + "cortex-m-rt", + "critical-section", + "defmt", + "defmt-rtt", + "embassy-executor", + "embassy-net", + "embassy-stm32", + "embassy-sync", + "embassy-time", + "embassy-usb", + "embedded-alloc", + "embedded-hal 0.2.7", + "embedded-hal 1.0.0-rc.3", + "embedded-io", + "embedded-io-async", + "embedded-storage", + "futures", + "heapless 0.8.0", + "linked_list_allocator", + "micromath", + "nb 1.1.0", + "panic-probe", + "simcom-gprs-driver", + "static_cell", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.46", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "usb-device" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f6cc3adc849b5292b4075fc0d5fdcf2f24866e88e336dd27a8943090a520508" + +[[package]] +name = "usbd-hid" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "975bd411f4a939986751ea09992a24fa47c4d25c6ed108d04b4c2999a4fd0132" +dependencies = [ + "serde", + "ssmarshal", + "usb-device", + "usbd-hid-macros", +] + +[[package]] +name = "usbd-hid-descriptors" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcbee8c6735e90894fba04770bc41e11fd3c5256018856e15dc4dd1e6c8a3dd1" +dependencies = [ + "bitfield", +] + +[[package]] +name = "usbd-hid-macros" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261079a9ada015fa1acac7cc73c98559f3a92585e15f508034beccf6a2ab75a2" +dependencies = [ + "byteorder", + "proc-macro2", + "quote", + "serde", + "syn 1.0.109", + "usbd-hid-descriptors", +] + +[[package]] +name = "vcell" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + +[[package]] +name = "volatile-register" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de437e2a6208b014ab52972a27e59b33fa2920d3e00fe05026167a1c509d19cc" +dependencies = [ + "vcell", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..a246980 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,59 @@ +[package] +name = "stmspeedgovdevice" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +# Change stm32f429zi to your chip name, if necessary. +embassy-stm32 = { version = "0.1.0", features = [ "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti", "chrono"] } +embassy-sync = { version = "0.5.0", features = ["defmt"] } +embassy-executor = { version = "0.4.0", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } +embassy-time = { version = "=0.2.*", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-usb = { version = "0.1.0", features = ["defmt" ] } +embassy-net = { version = "0.2", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } +atat = { version="0.20.0", features = ["async", "log"] } + +defmt = "0.3" +defmt-rtt = "0.4" + +cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } +cortex-m-rt = "0.7.0" +embedded-hal = "0.2.7" +embedded-alloc = "0.5.1" +critical-section = "1.1.2" +linked_list_allocator = "0.10.5" +embedded-hal-hal = { package = "embedded-hal", version = "1.0.0-rc.2"} +embedded-io = { version = "0.6.0" } +embedded-io-async = { version = "0.6.1" } +panic-probe = { version = "0.3", features = ["print-defmt"] } +futures = { version = "0.3.17", default-features = false, features = ["async-await"] } +heapless = { version = "0.8", default-features = false } +nb = "1.0.0" +embedded-storage = "0.3.1" +micromath = "2.0.0" +# static_cell = "2" +static_cell = { version = "2.0.0", features = ["nightly"] } + +chrono = { version = "^0.4", default-features = false} +# simcom = { package = "simcom-gprs-driver", path = "../../exprojects/chip-drivers/cellular/simcom-gprs", features = [] } +simcom = { package = "simcom-gprs-driver",git = "https://github.com/rmja/chip-drivers.git", branch = "master", features = ["sim900"] } + +[patch.crates-io] +# ublox-sockets = { git = "https://github.com/BlackbirdHQ/ublox-sockets", branch = "feature/async-borrowed-sockets" } +atat = { git = "https://github.com/BlackbirdHQ/atat", branch = "master" } +no-std-net = { git = "https://github.com/rushmorem/no-std-net", branch = "issue-15" } +embassy-stm32 = { git = "https://github.com/embassy-rs/embassy", branch = "main" } +embassy-time = { git = "https://github.com/embassy-rs/embassy", branch = "main" } +embassy-sync = { git = "https://github.com/embassy-rs/embassy", branch = "main" } +embassy-futures = { git = "https://github.com/embassy-rs/embassy", branch = "main" } +embassy-executor = { git = "https://github.com/embassy-rs/embassy", branch = "main" } +embassy-usb = { git = "https://github.com/embassy-rs/embassy", branch = "main" } +embassy-net = { git = "https://github.com/embassy-rs/embassy", branch = "main" } + + + + +[profile.release] +debug = 2 diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..8cd32d7 --- /dev/null +++ b/build.rs @@ -0,0 +1,5 @@ +fn main() { + println!("cargo:rustc-link-arg-bins=--nmagic"); + println!("cargo:rustc-link-arg-bins=-Tlink.x"); + println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); +} diff --git a/rust-toolchain-stable.toml b/rust-toolchain-stable.toml new file mode 100644 index 0000000..455f2cc --- /dev/null +++ b/rust-toolchain-stable.toml @@ -0,0 +1,13 @@ +[toolchain] +channel = "1.75" +# channel = "1.74" +components = [ "rust-src", "rustfmt", "llvm-tools" ] +targets = [ + "thumbv7em-none-eabi", + "thumbv7m-none-eabi", + "thumbv6m-none-eabi", + "thumbv7em-none-eabihf", + "thumbv8m.main-none-eabihf", + "riscv32imac-unknown-none-elf", + "wasm32-unknown-unknown", +] diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..035cd72 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,15 @@ +[toolchain] +channel = "nightly-2023-12-29" +# channel = "nightly-2023-12-20" +# 2023-12-29 +# 2023-12-20 +components = [ "rust-src", "rustfmt", "llvm-tools", "miri" ] +targets = [ + "thumbv7em-none-eabi", + "thumbv7m-none-eabi", + "thumbv6m-none-eabi", + "thumbv7em-none-eabihf", + "thumbv8m.main-none-eabihf", + "riscv32imac-unknown-none-elf", + "wasm32-unknown-unknown", +] diff --git a/src/common/general/mod.rs b/src/common/general/mod.rs new file mode 100644 index 0000000..0342690 --- /dev/null +++ b/src/common/general/mod.rs @@ -0,0 +1,34 @@ +//! ### 4 - General Commands +pub mod responses; +pub mod urc; + +use atat::atat_derive::AtatCmd; +use responses::*; + +/// 4.1 Manufacturer identification +CGMI +/// +/// Text string identifying the manufacturer. +#[derive(Clone, AtatCmd)] +#[at_cmd("+CGMI", ManufacturerId)] +pub struct GetManufacturerId; + +/// Model identification +CGMM +/// +/// Read a text string that identifies the device model. +#[derive(Clone, AtatCmd)] +#[at_cmd("+CGMM", ModelId)] +pub struct GetModelId; + +/// Software version identification +CGMR +/// +/// Read a text string that identifies the software version of the module +#[derive(Clone, AtatCmd)] +#[at_cmd("+CGMR", SoftwareVersion)] +pub struct GetSoftwareVersion; + +/// 7.12 Wi-Fi MAC address +UWAPMACADDR +/// +/// Lists the currently used MAC address. +#[derive(Clone, AtatCmd)] +#[at_cmd("+UWAPMACADDR", WifiMac)] +pub struct GetWifiMac; diff --git a/src/common/general/responses.rs b/src/common/general/responses.rs new file mode 100644 index 0000000..3394d74 --- /dev/null +++ b/src/common/general/responses.rs @@ -0,0 +1,30 @@ +//! Responses for General Commands +use atat::atat_derive::AtatResp; +use atat::heapless::String; + +/// 4.1 Manufacturer identification +/// Text string identifying the manufacturer. +#[derive(Clone, Debug, AtatResp)] +pub struct ManufacturerId { + pub id: String<64>, +} + +/// Model identification +/// Text string identifying the manufacturer. +#[derive(Clone, Debug, AtatResp)] +pub struct ModelId { + pub id: String<64>, +} + +/// Software version identification +/// Read a text string that identifies the software version of the module. +#[derive(Clone, Debug, AtatResp)] +pub struct SoftwareVersion { + pub id: String<64>, +} + +/// 7.11 Wi-Fi Access point station list +UWAPSTALIST +#[derive(Clone, AtatResp)] +pub struct WifiMac { + pub mac_addr: atat::heapless_bytes::Bytes<12>, +} diff --git a/src/common/general/urc.rs b/src/common/general/urc.rs new file mode 100644 index 0000000..46efa7a --- /dev/null +++ b/src/common/general/urc.rs @@ -0,0 +1,4 @@ +use atat::atat_derive::AtatResp; + +#[derive(Clone, AtatResp)] +pub struct MessageWaitingIndication; diff --git a/src/common/mod.rs b/src/common/mod.rs new file mode 100644 index 0000000..7b37cfc --- /dev/null +++ b/src/common/mod.rs @@ -0,0 +1,18 @@ +pub mod general; + +use atat::atat_derive::AtatUrc; + +use atat::atat_derive::{AtatCmd, AtatResp}; + +#[derive(Clone, AtatResp)] +pub struct NoResponse; + +#[derive(Clone, AtatCmd)] +#[at_cmd("", NoResponse, timeout_ms = 1000)] +pub struct AT; + +#[derive(Clone, AtatUrc)] +pub enum Urc { + #[at_urc("+UMWI")] + MessageWaitingIndication(general::urc::MessageWaitingIndication), +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..d5df218 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,87 @@ +#![no_std] +pub mod common; + +use core::{ + alloc::{GlobalAlloc, Layout}, + cell::RefCell, + ptr::{self, NonNull}, +}; + +use critical_section::Mutex; +use linked_list_allocator::Heap; + +pub struct EspHeap { + heap: Mutex>, +} + +impl EspHeap { + /// Crate a new UNINITIALIZED heap allocator + /// + /// You must initialize this heap using the + /// [`init`](struct.EspHeap.html#method.init) method before using the + /// allocator. + pub const fn empty() -> EspHeap { + EspHeap { + heap: Mutex::new(RefCell::new(Heap::empty())), + } + } + + /// Initializes the heap + /// + /// This function must be called BEFORE you run any code that makes use of + /// the allocator. + /// + /// `heap_bottom` is a pointer to the location of the bottom of the heap. + /// + /// `size` is the size of the heap in bytes. + /// + /// Note that: + /// + /// - The heap grows "upwards", towards larger addresses. Thus `end_addr` + /// must be larger than `start_addr` + /// + /// - The size of the heap is `(end_addr as usize) - (start_addr as usize)`. + /// The allocator won't use the byte at `end_addr`. + /// + /// # Safety + /// + /// Obey these or Bad Stuff will happen. + /// + /// - This function must be called exactly ONCE. + /// - `size > 0` + pub unsafe fn init(&self, heap_bottom: *mut u8, size: usize) { + critical_section::with(|cs| self.heap.borrow(cs).borrow_mut().init(heap_bottom, size)); + } + + /// Returns an estimate of the amount of bytes in use. + pub fn used(&self) -> usize { + critical_section::with(|cs| self.heap.borrow(cs).borrow_mut().used()) + } + + /// Returns an estimate of the amount of bytes available. + pub fn free(&self) -> usize { + critical_section::with(|cs| self.heap.borrow(cs).borrow_mut().free()) + } +} + +unsafe impl GlobalAlloc for EspHeap { + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + critical_section::with(|cs| { + self.heap + .borrow(cs) + .borrow_mut() + .allocate_first_fit(layout) + .ok() + .map_or(ptr::null_mut(), |allocation| allocation.as_ptr()) + }) + } + + unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { + critical_section::with(|cs| { + self.heap + .borrow(cs) + .borrow_mut() + .deallocate(NonNull::new_unchecked(ptr), layout) + }); + } +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..6b4e6ce --- /dev/null +++ b/src/main.rs @@ -0,0 +1,309 @@ +#![no_std] +#![no_main] +#![allow(stable_features)] +#![feature(type_alias_impl_trait)] + +extern crate alloc; +use atat::asynch::Client; +use atat::ResponseSlot; +use atat::UrcChannel; +use core::cell::RefCell; +use cortex_m_rt::entry; +use defmt::*; +use embassy_executor::{Executor, Spawner}; +use embassy_stm32::gpio::{AnyPin, Input, Level, Output, OutputOpenDrain, Pin, Pull, Speed}; +use embassy_stm32::peripherals::PD12; +use embassy_stm32::peripherals::USART3; +use embassy_stm32::time::Hertz; +use embassy_stm32::time::{khz, mhz}; +use embassy_stm32::usart::UartTx; +use embassy_stm32::usart::{BufferedUart, BufferedUartRx, BufferedUartTx}; +use embassy_stm32::{bind_interrupts, interrupt, peripherals, usart, Config}; +use embassy_time::{Duration, Timer}; +use static_cell::StaticCell; +use {defmt_rtt as _, panic_probe as _}; + +use atat::asynch::AtatClient; +use atat::{AtDigester, AtatIngress, DefaultDigester, Ingress, Parser}; + +use core::mem::MaybeUninit; +use simcom::{ + services::network::NetworkError, DriverError, SimcomConfig, SimcomDevice, SimcomIngress, + SimcomResponseSlot, SimcomUrcChannel, +}; +use stmspeedgovdevice::common; +use {defmt_rtt as _, panic_probe as _}; + +bind_interrupts!(struct Irqs { + USART3 => embassy_stm32::usart::BufferedInterruptHandler; +}); +// bind_interrupts!(struct Irqs { +// USART3 => embassy_stm32::usart::BufferedInterruptHandler; +// }); +const INGRESS_BUF_SIZE: usize = 1024; +const URC_CAPACITY: usize = 2; +const URC_SUBSCRIBERS: usize = 2; + +static EXECUTOR: StaticCell = StaticCell::new(); + +#[global_allocator] +static ALLOCATOR: stmspeedgovdevice::EspHeap = stmspeedgovdevice::EspHeap::empty(); + +fn init_heap() { + const HEAP_SIZE: usize = 32 * 1024; + static mut HEAP: MaybeUninit<[u8; HEAP_SIZE]> = MaybeUninit::uninit(); + + unsafe { + ALLOCATOR.init(HEAP.as_mut_ptr() as *mut u8, HEAP_SIZE); + } +} + +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + init_heap(); + + info!("Hello World!"); + + let executor = EXECUTOR.init(Executor::new()); + + executor.run(|spawner| { + unwrap!(spawner.spawn(test_uart_device_setup(spawner))); + }) + + // info!("Hello World!"); + + // let (ingress, devc, rx14) = test_uart_device_setup(p.PC10, p.PC11, p.USART3); + + // spawner.spawn(ingress_task(ingress, reader)).unwrap(); + + // unwrap!(spawner.spawn(ingress_task(ingress, rx14))); + // unwrap!(spawner.spawn(testsetup(devc))); +} + +// #[embassy_executor::task] +// async fn buf_u(mut buf_usart: BufferedUart<'static, embassy_stm32::peripherals::USART3>) { +// loop { +// let buf = buf_usart.fill_buf().await.unwrap(); +// info!("Received: {}", buf); + +// // Read bytes have to be explicitly consumed, otherwise fill_buf() will return them again +// let n = buf.len(); +// buf_usart.consume(n); +// } +// } + +// #[embassy_executor::task] +// pub async fn ingress_task( +// mut ingress: SimcomIngress<'static, INGRESS_BUF_SIZE>, +// mut rx: BufferedUartRx<'static, USART3>, +// ) { +// defmt::info!("reading in ingress_task..."); +// ingress.read_from(&mut rx).await; +// } +#[embassy_executor::task(pool_size = 3)] +async fn blinky(mut led: AnyPin) { + let mut output = Output::new(led, Level::High, Speed::Low).degrade(); + loop { + output.set_high(); + Timer::after(Duration::from_millis(1000)).await; + output.set_low(); + Timer::after(Duration::from_millis(1000)).await; + } +} + +#[embassy_executor::task] +async fn led_blink(p: PD12) { + let mut led = Output::new(p, Level::High, Speed::Low); + + loop { + info!("high"); + led.set_high(); + Timer::after(Duration::from_millis(300)).await; + + info!("low"); + led.set_low(); + Timer::after(Duration::from_millis(300)).await; + } +} + +// -> ( +// // atat::asynch::Client<'static, UartTx<'static, hal::peripherals::UART1>, INGRESS_BUF_SIZE>, +// // SimcomDevice<'static, 'static, atat::asynch::Client<'static, UartTx<'static, UART1>, INGRESS_BUF_SIZE> +// SimcomIngress<'static, INGRESS_BUF_SIZE>, +// SimcomDevice< +// 'static, +// 'static, +// atat::asynch::Client<'static, UartTx<'static, UART1>, INGRESS_BUF_SIZE>, +// TestConfig, +// >, +// UartRx<'static, UART1>, +// ) +#[embassy_executor::task] +pub async fn test_uart_device_setup(spawner: Spawner) { + let mut config = Config::default(); + { + use embassy_stm32::rcc::*; + config.rcc.hse = Some(Hse { + freq: Hertz(8_000_000), + mode: HseMode::Bypass, + }); + config.rcc.pll_src = PllSource::HSE; + config.rcc.pll = Some(Pll { + prediv: PllPreDiv::DIV4, + mul: PllMul::MUL180, + divp: Some(PllPDiv::DIV2), // 8mhz / 4 * 180 / 2 = 180Mhz. + divq: None, + divr: None, + }); + config.rcc.ahb_pre = AHBPrescaler::DIV1; + config.rcc.apb1_pre = APBPrescaler::DIV4; + config.rcc.apb2_pre = APBPrescaler::DIV2; + config.rcc.sys = Sysclk::PLL1_P; + } + let p = embassy_stm32::init(config); + + static tx_buf: StaticCell<[u8; 16]> = StaticCell::new(); + static rx_buf: StaticCell<[u8; 16]> = StaticCell::new(); + + let (tx_pin, rx_pin, uart) = (p.PC10, p.PC11, p.USART3); + let mut uart_config = embassy_stm32::usart::Config::default(); + { + uart_config.baudrate = 115200; + // uart_config.baudrate = 9600; + uart_config.parity = embassy_stm32::usart::Parity::ParityNone; + uart_config.stop_bits = embassy_stm32::usart::StopBits::STOP1; + uart_config.data_bits = embassy_stm32::usart::DataBits::DataBits8; + } + + let uart = BufferedUart::new( + uart, + Irqs, + rx_pin, + tx_pin, + tx_buf.init([0u8; 16]), + rx_buf.init([0u8; 16]), + uart_config, + ); + let (txPC10, rxPC11) = uart.unwrap().split(); + + // static BUFFERS: Buffers = + // Buffers::::new(); + + static RES_SLOT: SimcomResponseSlot = SimcomResponseSlot::new(); + static URC_CHANNEL: SimcomUrcChannel = SimcomUrcChannel::new(); + let ingress = SimcomIngress::new(&RES_SLOT, &URC_CHANNEL); + + // static buf: StaticCell<[u8; INGRESS_BUF_SIZE]> = StaticCell::new(); + + let buf = static_cell::make_static!([0; 1024]); + let config = TestConfig(ResetPin(true)); + let device = SimcomDevice::new(txPC10, &RES_SLOT, &URC_CHANNEL, buf, config); + + // let mut client = Client::new(tx, &RES_SLOT, buf, atat::Config::default()); + // + + // (ingress, device, rx) + // unwrap!(spawner.spawn(ingress_task(ingress, rxPC11))); + // unwrap!(spawner.spawn(testsetup(device))); + unwrap!(spawner.spawn(led_blink(p.PD12))); +} + +// #[embassy_executor::task] +// pub async fn testsetup( +// mut device: SimcomDevice< +// 'static, +// 'static, +// atat::asynch::Client<'static, BufferedUartTx<'static, USART3>, INGRESS_BUF_SIZE>, +// TestConfig, +// >, +// ) { +// // let m = device.handle; + +// // let tcp = device.data("internet".into()).await.unwrap(); +// match device.data("internet".into()).await { +// Ok(tcp) => { +// defmt::info!("{:?}", tcp.local_ip); +// } +// Err(e) => match e { +// DriverError::Atat(atat::Error::Timeout) => { +// defmt::error!("[DriverError - Timeout]: {:?}", e); +// } +// _ => {} +// }, +// } + +// // defmt::info!("{:?}", tcp.local_ip); +// // defmt::info!("Logger is setup"); + +// // match device.network().attach(None).await { +// // Ok(d) => { +// // defmt::info!("network().attach Sent: {:?}", d) +// // } +// // Err(e) => match e { +// // NetworkError::Atat(atat::Error::Timeout) => { +// // defmt::error!("[network().attach] - Timeout Error: {:?}", e) +// // } +// // _ => {} +// // }, +// // } +// // match device.reset().await { +// // Ok(d) => { +// // defmt::info!("device.reset() Sent: {:?}", d) +// // } +// // Err(e) => match e { +// // DriverError::Atat(atat::Error::Timeout) => { +// // defmt::error!("[device.reset()] - Timeout Error: {:?}", e) +// // } +// // _ => {} +// // }, +// // } +// // match device.setup().await { +// // Ok(d) => { +// // defmt::info!("device.setup() Sent: {:?}", d) +// // } +// // Err(e) => match e { +// // DriverError::Atat(atat::Error::Timeout) => { +// // defmt::error!("[device.setup()] - Timeout Error: {:?}", e) +// // } +// // DriverError::BaudDetection => { +// // defmt::error!("[device.setup()] - BaudDetection Error: {:?}", e) +// // } +// // _ => {} +// // }, +// // } + +// // let mut network = device.network(); +// // network.attach(None).await.unwrap(); +// } +use core::convert::Infallible; + +use embedded_hal_hal::digital::{ErrorType, OutputPin}; +// use embedded_hal::digital::v2::OutputPin; +// use embedded_nal_async::{IpAddr, Ipv4Addr, SocketAddr}; + +pub struct TestConfig(ResetPin); +pub struct ResetPin(bool); + +impl SimcomConfig for TestConfig { + type ResetPin = ResetPin; + + fn reset_pin(&mut self) -> &mut Self::ResetPin { + &mut self.0 + } +} + +impl OutputPin for ResetPin { + fn set_low(&mut self) -> Result<(), Self::Error> { + self.0 = false; + Ok(()) + } + + fn set_high(&mut self) -> Result<(), Self::Error> { + self.0 = true; + Ok(()) + } +} + +impl ErrorType for ResetPin { + type Error = Infallible; +}