From bb81182daa97f1d38c3a6443595133cb6c57d96f Mon Sep 17 00:00:00 2001 From: Matt Spencer Date: Sat, 17 Oct 2026 15:21:58 +0100 Subject: [PATCH] feat: bootstrap esp32-c6 embassy lighting controller --- .cargo/config.toml | 15 + .gitignore | 2 + .gitmodules | 4 + Cargo.lock | 2177 +++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 53 ++ rust-toolchain.toml | 4 + src/config.rs | 22 + src/encoder.rs | 107 +++ src/light.rs | 129 +++ src/main.rs | 116 +++ src/ws2812.rs | 85 ++ src/zigbee_stack.rs | 211 +++++ vendor/zigbee-rs | 1 + 13 files changed, 2926 insertions(+) create mode 100644 .cargo/config.toml create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 rust-toolchain.toml create mode 100644 src/config.rs create mode 100644 src/encoder.rs create mode 100644 src/light.rs create mode 100644 src/main.rs create mode 100644 src/ws2812.rs create mode 100644 src/zigbee_stack.rs create mode 160000 vendor/zigbee-rs diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..6fd40dd --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,15 @@ +[build] +target = "riscv32imac-unknown-none-elf" + +[target.riscv32imac-unknown-none-elf] +runner = "espflash flash --monitor" +rustflags = [ + "-C", "link-arg=-Tlinkall.x", + "-C", "force-frame-pointers", +] + +[env] +ESP_LOG = "info" + +[unstable] +build-std = ["core", "alloc"] diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4e65899 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +/vendor/zigbee-rs/target diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..cd5d47e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "vendor/zigbee-rs"] + path = vendor/zigbee-rs + url = https://github.com/zigbee-rs/zigbee-rs.git + branch = smart-light diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..1a0a4e4 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2177 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aead" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" +dependencies = [ + "generic-array", +] + +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common", + "generic-array", +] + +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if", + "cipher 0.4.4", + "cpufeatures", +] + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c583acf993cf4245c4acb0a2cc2ab1f9cc097de73411bb6d3647ff6af2b1013d" + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "bitfield" +version = "0.19.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45721c9db4c7a20899d05efb7ad9235f50b256e980db30ffb229abf732934c3" +dependencies = [ + "bitfield-macros", +] + +[[package]] +name = "bitfield-macros" +version = "0.19.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0cb6f3d4773a2107b94cbeccaa5b5f0b35a88389b5d522d13d659f64317b22d" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "byte" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21c7ab3e4ae80853c7f8dcdcd904dfa25c02cc373534b8d165194325a088a7cc" + +[[package]] +name = "bytemuck" +version = "1.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cc" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6651c9ed80effdc7db0ff72512157f901af5e3549e341e24b1dd4887d836d838" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "ccm" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a9cf981c7e62b6fb02225592ee7ebf221e0b0b5317984a57a1e9d21af20e317" +dependencies = [ + "aead 0.4.3", + "cipher 0.3.0", + "ctr 0.8.0", + "subtle", +] + +[[package]] +name = "ccm" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ae3c82e4355234767756212c570e29833699ab63e6ffd161887314cc5b43847" +dependencies = [ + "aead 0.5.2", + "cipher 0.4.4", + "ctr 0.9.2", + "subtle", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + +[[package]] +name = "const-default" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b396d1f76d455557e1218ec8066ae14bba60b4b36ecd55577ba979f5db7ecaa" + +[[package]] +name = "cordyceps" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b9ab7e0ca1d179628fa0172b2b97203c7fa0cd81be2448bd446fb9559ca9261" +dependencies = [ + "loom", + "tracing", +] + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "critical-section" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "ctr" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" +dependencies = [ + "cipher 0.3.0", +] + +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher 0.4.4", +] + +[[package]] +name = "darling" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +dependencies = [ + "darling_core 0.20.11", + "darling_macro 0.20.11", +] + +[[package]] +name = "darling" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" +dependencies = [ + "darling_core 0.21.3", + "darling_macro 0.21.3", +] + +[[package]] +name = "darling" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec" +dependencies = [ + "darling_core 0.24.1", + "darling_macro 0.24.1", +] + +[[package]] +name = "darling_core" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.119", +] + +[[package]] +name = "darling_core" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "darling_core" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff" +dependencies = [ + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 3.0.9", +] + +[[package]] +name = "darling_macro" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +dependencies = [ + "darling_core 0.20.11", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "darling_macro" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" +dependencies = [ + "darling_core 0.21.3", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "darling_macro" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785" +dependencies = [ + "darling_core 0.24.1", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "defmt" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a0795ac740cb54d7b3775c9c17345f6aaecf884c01733b39d6017738e0e3e1" +dependencies = [ + "bitflags 1.3.2", + "defmt-macros", +] + +[[package]] +name = "defmt-macros" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "840bb056bd99c495c9188198a258ab787c79f306d864db3e6e8451442d6d8366" +dependencies = [ + "defmt-parser", + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "defmt-parser" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71958f69fb2de856c5dd51ac9377e986ca1aa5919f931bf5395a807277f889a0" +dependencies = [ + "thiserror", +] + +[[package]] +name = "delegate" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "780eb241654bf097afb00fc5f054a09b687dad862e485fdcf8399bb056565370" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "docsplay" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8547ea80db62c5bb9d7796fcce5e6e07d1136bdc1a02269095061e806758fab4" +dependencies = [ + "docsplay-macros", +] + +[[package]] +name = "docsplay-macros" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11772ed3eb3db124d826f3abeadf5a791a557f62c19b123e3f07288158a71fdd" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "document-features" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61" +dependencies = [ + "litrs", +] + +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" + +[[package]] +name = "embassy-embedded-hal" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "554e3e840696f54b4c9afcf28a0f24da431c927f4151040020416e7393d6d0d8" +dependencies = [ + "embassy-futures", + "embassy-hal-internal 0.3.0", + "embassy-sync 0.7.2", + "embedded-hal 0.2.7", + "embedded-hal 1.0.0", + "embedded-hal-async", + "embedded-storage", + "embedded-storage-async", + "nb 1.1.0", +] + +[[package]] +name = "embassy-embedded-hal" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0641612053b2f34fc250bb63f6630ae75de46e02ade7f457268447081d709ce" +dependencies = [ + "embassy-futures", + "embassy-hal-internal 0.4.0", + "embassy-sync 0.8.0", + "embedded-hal 0.2.7", + "embedded-hal 1.0.0", + "embedded-hal-async", + "embedded-storage", + "embedded-storage-async", + "nb 1.1.0", +] + +[[package]] +name = "embassy-executor" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0d3b15c9d7dc4fec1d8cb77112472fb008b3b28c51ad23838d83587a6d2f1e" +dependencies = [ + "cordyceps", + "critical-section", + "document-features", + "embassy-executor-macros", + "embassy-executor-timer-queue", +] + +[[package]] +name = "embassy-executor-macros" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d11a246f53de5f97a387f40ac24726817cd0b6f833e7603baac784f29d6ff276" +dependencies = [ + "darling 0.20.11", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "embassy-executor-timer-queue" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fc328bf943af66b80b98755db9106bf7e7471b0cf47dc8559cd9a6be504cc9c" + +[[package]] +name = "embassy-futures" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc2d050bdc5c21e0862a89256ed8029ae6c290a93aecefc73084b3002cdebb01" + +[[package]] +name = "embassy-hal-internal" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95285007a91b619dc9f26ea8f55452aa6c60f7115a4edc05085cd2bd3127cd7a" +dependencies = [ + "num-traits", +] + +[[package]] +name = "embassy-hal-internal" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f10ce10a4dfdf6402d8e9bd63128986b96a736b1a0a6680547ed2ac55d55dba" +dependencies = [ + "num-traits", +] + +[[package]] +name = "embassy-sync" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d2c8cdff05a7a51ba0087489ea44b0b1d97a296ca6b1d6d1a33ea7423d34049" +dependencies = [ + "cfg-if", + "critical-section", + "embedded-io-async 0.6.1", + "futures-sink", + "futures-util", + "heapless 0.8.0", +] + +[[package]] +name = "embassy-sync" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73974a3edbd0bd286759b3d483540f0ebef705919a5f56f4fc7709066f71689b" +dependencies = [ + "cfg-if", + "critical-section", + "embedded-io-async 0.6.1", + "futures-core", + "futures-sink", + "heapless 0.8.0", +] + +[[package]] +name = "embassy-sync" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bbd85cf5a5ae56bdf26f618364af642d1d0a4e245cdd75cd9aabda382f65a81" +dependencies = [ + "cfg-if", + "critical-section", + "embedded-io-async 0.7.0", + "futures-core", + "futures-sink", + "heapless 0.9.3", +] + +[[package]] +name = "embassy-time" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "592b0c143ec626e821d4d90da51a2bd91d559d6c442b7c74a47d368c9e23d97a" +dependencies = [ + "cfg-if", + "critical-section", + "document-features", + "embassy-time-driver", + "embedded-hal 0.2.7", + "embedded-hal 1.0.0", + "embedded-hal-async", + "futures-core", +] + +[[package]] +name = "embassy-time-driver" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ee71af1b3a0deaa53eaf2d39252f83504c853646e472400b763060389b9fcc9" +dependencies = [ + "document-features", +] + +[[package]] +name = "embassy-time-queue-utils" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168297bf80aaf114b3c9ad589bf38b01b3009b9af7f97cd18086c5bbf96f5693" +dependencies = [ + "embassy-executor-timer-queue", + "heapless 0.9.3", +] + +[[package]] +name = "embedded-can" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9d2e857f87ac832df68fa498d18ddc679175cf3d2e4aa893988e5601baf9438" +dependencies = [ + "nb 1.1.0", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "361a90feb7004eca4019fb28352a9465666b24f840f5c3cddf0ff13920590b89" + +[[package]] +name = "embedded-hal-async" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4c685bbef7fe13c3c6dd4da26841ed3980ef33e841cddfa15ce8a8fb3f1884" +dependencies = [ + "embedded-hal 1.0.0", +] + +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + +[[package]] +name = "embedded-io" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eb1aa714776b75c7e67e1da744b81a129b3ff919c8712b5e1b32252c1f07cc7" + +[[package]] +name = "embedded-io-async" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ff09972d4073aa8c299395be75161d582e7629cd663171d62af73c8d50dba3f" +dependencies = [ + "embedded-io 0.6.1", +] + +[[package]] +name = "embedded-io-async" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2564b9f813c544241430e147d8bc454815ef9ac998878d30cc3055449f7fd4c0" +dependencies = [ + "embedded-io 0.7.1", +] + +[[package]] +name = "embedded-storage" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c815b3ed4213d85d6cfd274b871f430c0681084e28dfd4a537877f47f844ec83" + +[[package]] +name = "embedded-storage-async" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69aa7787b8ba0cf4e626c95839f811d853b75e24a0f7312a1eef324fedc13b21" +dependencies = [ + "embedded-storage", +] + +[[package]] +name = "enumset" +version = "1.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccc5801fd11762e24d1e420d01d2ac518f2a2ca4329d4fbb6639f2412b6204e0" +dependencies = [ + "enumset_derive", +] + +[[package]] +name = "enumset_derive" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bd536557b58c682b217b8fb199afdff47cd3eff260623f19e77074eb073d63a" +dependencies = [ + "darling 0.21.3", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "esp-alloc" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46ced060d4085858283df950b80a4da2348e1707d7d07b1e966308582dae79f5" +dependencies = [ + "allocator-api2", + "cfg-if", + "document-features", + "enumset", + "esp-config", + "esp-sync", + "linked_list_allocator", + "rlsf", +] + +[[package]] +name = "esp-backtrace" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37950e24b2dfd98f1581102d1798281d4d9547af881e6bffc2c2b534c026ec8f" +dependencies = [ + "cfg-if", + "document-features", + "esp-config", + "esp-metadata-generated", + "esp-println", + "heapless 0.9.3", + "riscv", + "xtensa-lx", +] + +[[package]] +name = "esp-bootloader-esp-idf" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35ffc117c3a9859835d89d0e90f5ee9886ce2264a71a849a7a22ab5308f6653c" +dependencies = [ + "cfg-if", + "document-features", + "embedded-storage", + "esp-config", + "esp-hal-procmacros", + "esp-metadata-generated", + "esp-rom-sys", + "jiff", + "strum", +] + +[[package]] +name = "esp-config" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d9b92fd9cfb0b4f8f1b6219b9763269a335571e307b014903b8201619374b80" +dependencies = [ + "document-features", + "esp-metadata-generated", + "serde", + "serde_yaml", + "somni-expr", +] + +[[package]] +name = "esp-hal" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e2874462a2a0faca8b6318a10b0db87d2b7cd74dded82b3dfd780c07a319038" +dependencies = [ + "bitfield", + "bitflags 2.13.2", + "bytemuck", + "cfg-if", + "critical-section", + "delegate", + "digest", + "document-features", + "embassy-embedded-hal 0.6.0", + "embassy-futures", + "embassy-sync 0.8.0", + "embedded-can", + "embedded-hal 1.0.0", + "embedded-hal-async", + "embedded-io 0.6.1", + "embedded-io 0.7.1", + "embedded-io-async 0.6.1", + "embedded-io-async 0.7.0", + "enumset", + "esp-config", + "esp-hal-procmacros", + "esp-metadata-generated", + "esp-riscv-rt", + "esp-rom-sys", + "esp-sync", + "esp32", + "esp32c2", + "esp32c3", + "esp32c6", + "esp32h2", + "esp32s2", + "esp32s3", + "fugit", + "instability", + "log", + "nb 1.1.0", + "paste", + "portable-atomic", + "rand_core 0.10.1", + "rand_core 0.6.4", + "rand_core 0.9.5", + "riscv", + "strum", + "ufmt-write", + "xtensa-lx", + "xtensa-lx-rt", +] + +[[package]] +name = "esp-hal-procmacros" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6aebfabb2c21bec45e575e4f6cb6bb7aa8e1b33e7ac45b5dffa0f9d33ff59105" +dependencies = [ + "document-features", + "object", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.119", + "termcolor", +] + +[[package]] +name = "esp-metadata-generated" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42c2ee95b945a4780796e4359e72c033aed3b45073880e8029458f538532db8a" + +[[package]] +name = "esp-phy" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c0a29815cd105ae1a02f3d0c6e7aafda9504a41effae17fac4c3f827719228" +dependencies = [ + "cfg-if", + "document-features", + "embassy-sync 0.8.0", + "esp-config", + "esp-hal", + "esp-metadata-generated", + "esp-sync", + "esp-wifi-sys-esp32c6", + "esp32c6", +] + +[[package]] +name = "esp-println" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42dee1e9ac7c3539bf6464db1707b0edd7557168f98278cf3c84fe70e63c6ce6" +dependencies = [ + "document-features", + "esp-metadata-generated", + "esp-sync", + "log", + "portable-atomic", +] + +[[package]] +name = "esp-radio" +version = "1.0.0-beta.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f25cc4e3ce27476b42c4a68943f10a92f9dec3c24bb001269958f0318fef02c" +dependencies = [ + "allocator-api2", + "byte", + "cfg-if", + "docsplay", + "document-features", + "embassy-sync 0.8.0", + "embedded-io 0.6.1", + "embedded-io 0.7.1", + "embedded-io-async 0.6.1", + "embedded-io-async 0.7.0", + "esp-alloc", + "esp-config", + "esp-hal", + "esp-hal-procmacros", + "esp-metadata-generated", + "esp-phy", + "esp-radio-rtos-driver", + "esp-rom-sys", + "esp-sync", + "esp-wifi-sys-esp32c6", + "esp32c6", + "heapless 0.9.3", + "ieee802154", + "instability", + "num-derive", + "num-traits", + "portable-atomic", + "portable_atomic_enum", +] + +[[package]] +name = "esp-radio-rtos-driver" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bd75cd9073a90ffaa53db0bf17df7dc14164f2407a6ff36c725d2d1f78ff494" +dependencies = [ + "cfg-if", + "esp-sync", + "portable-atomic", +] + +[[package]] +name = "esp-riscv-rt" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66a814ae91452de56a5e74f69aebfee40579511756837d3774a56fd24cf0ab79" +dependencies = [ + "document-features", + "riscv", + "riscv-rt", +] + +[[package]] +name = "esp-rom-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae852ccb08971155023d1371c96d5490cbc26860f06aee2d629ef73f1a890c3" +dependencies = [ + "cfg-if", + "document-features", + "esp-metadata-generated", + "esp32c6", +] + +[[package]] +name = "esp-rtos" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "551f90766e1527edaa0c91e8d559e9e2a60397b545e93357ac61fb31845e5712" +dependencies = [ + "cfg-if", + "document-features", + "embassy-executor", + "embassy-sync 0.8.0", + "embassy-time-driver", + "embassy-time-queue-utils", + "esp-config", + "esp-hal", + "esp-hal-procmacros", + "esp-metadata-generated", + "esp-rom-sys", + "esp-sync", + "log", + "portable-atomic", + "riscv", + "xtensa-lx", +] + +[[package]] +name = "esp-storage" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cf2b3f00c9f94b27c62a4f5296b19470c3a083c687c8146e554a459f9bee596" +dependencies = [ + "document-features", + "embedded-storage", + "esp-hal", + "esp-hal-procmacros", + "esp-metadata-generated", + "esp-rom-sys", + "esp-sync", +] + +[[package]] +name = "esp-sync" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4736bfbbb9e3f6353344e14fc61b6d18d3b877c3286914cf8c0a037be0ed224" +dependencies = [ + "cfg-if", + "document-features", + "embassy-sync 0.6.2", + "embassy-sync 0.7.2", + "embassy-sync 0.8.0", + "esp-metadata-generated", + "riscv", + "xtensa-lx", +] + +[[package]] +name = "esp-wifi-sys-esp32c6" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57649401fc2f906a16e2268de88693724a125adcd0eba89b594a157affcee2d5" + +[[package]] +name = "esp32" +version = "0.40.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5726e07689249d1a2cb7c492077bc424837fb68a64f7eb5d46569325352e9428" +dependencies = [ + "vcell", +] + +[[package]] +name = "esp32c2" +version = "0.29.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ef0b623533bbaa37e348c18b6b41cfd5b47c3cb64a4b9e44f0295941d62aa2e" +dependencies = [ + "vcell", +] + +[[package]] +name = "esp32c3" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21e89ed62cf6c043a6d29c520b02a13b359ec8a75d67b65d4330ed717d15fe97" +dependencies = [ + "vcell", +] + +[[package]] +name = "esp32c6" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c58f34ff2633968c12125efc7f4f8f101078d5d34c7cb60eab82268db20986f9" +dependencies = [ + "vcell", +] + +[[package]] +name = "esp32h2" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5bab026020ed4606ce113b6fde598dbc48f7eefcc46e9469ece77cc2b1aa4be" +dependencies = [ + "vcell", +] + +[[package]] +name = "esp32s2" +version = "0.31.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0ad6f21cdf6ec7b06b7f7e0fbe51f0d975fd6a5fa67c3f8a5a910d3981af531" +dependencies = [ + "vcell", +] + +[[package]] +name = "esp32s3" +version = "0.35.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b4b8c4e4d9f187553ecdb7173edec7b2deb2beea106eedefecdb1654b8ee25a" +dependencies = [ + "vcell", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "fugit" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e639847d312d9a82d2e75b0edcc1e934efcc64e6cb7aa94f0b1fbec0bc231d6" +dependencies = [ + "gcd", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-sink" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", +] + +[[package]] +name = "gcd" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d758ba1b47b00caf47f24925c0074ecb20d6dfcffe7f6d53395c0465674841a" + +[[package]] +name = "generator" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1be81b31c9ce4caf7f3178eeb90662bb1864d3ad363ec6bdada3201adff19c37" +dependencies = [ + "cc", + "cfg-if", + "libc", + "log", + "rustversion", + "windows-link", + "windows-result", +] + +[[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 = "hash32-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59d2aba832b60be25c1b169146b27c64115470981b128ed84c8db18c1b03c6ff" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "heapless" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" +dependencies = [ + "hash32 0.3.1", + "stable_deref_trait", +] + +[[package]] +name = "heapless" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25ba4bd83f9415b58b4ed8dc5714c76e626a105be4646c02630ad730ad3b5aa4" +dependencies = [ + "hash32 0.3.1", + "stable_deref_trait", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "ieee802154" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fcb6de62f20180795db19ae2ab338852a66f8576581554fa8a730e437b450a5" +dependencies = [ + "byte", + "ccm 0.4.4", + "cipher 0.3.0", + "hash32 0.2.1", + "hash32-derive", +] + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "indoc" +version = "2.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a37b2691796cffeb8a8cd305ac66e65841559f147f4e63231d0eafa4db5384d1" +dependencies = [ + "rustversion", +] + +[[package]] +name = "inout" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" +dependencies = [ + "generic-array", +] + +[[package]] +name = "instability" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c3b5acc1e2fd9375041a388da33d1eb8aed5f7a8c0dd3543e3ea2805adfbe20" +dependencies = [ + "darling 0.24.1", + "indoc", + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "jiff" +version = "0.2.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b005715dcbeb0089a3c0dab99f2ff1cc3b2525323552703d648585d342a383" +dependencies = [ + "defmt", + "jiff-core", + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", +] + +[[package]] +name = "jiff-core" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e52fe76043ccecc9005d2305ebaadf7d7fc0cc89ca6baa10a94d6bc68c7128c" +dependencies = [ + "defmt", + "log", +] + +[[package]] +name = "jiff-static" +version = "0.2.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cc9817253cf7c7ee4684451bd327e88d6f3658014e54a29198625590650695c" +dependencies = [ + "jiff-core", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "lazy_static" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "linked_list_allocator" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b23ac50abb8261cb38c6e2a7192d3302e0836dac1628f6a93b82b4fad185897" + +[[package]] +name = "litrs" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4744e383959f0db86ede514b809b1c53251889093803c05267acc7d4e7030d70" + +[[package]] +name = "log" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" + +[[package]] +name = "loom" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "419e0dc8046cb947daa77eb95ae174acfbddb7673b4151f56d1eed8e93fbfaca" +dependencies = [ + "cfg-if", + "generator", + "scoped-tls", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "matchers" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[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 = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.37.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "portable-atomic" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" + +[[package]] +name = "portable-atomic-util" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "portable_atomic_enum" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30d48f60c43e0120bb2bb48589a16d4bed2f4b911be41e299f2d0fc0e0e20885" +dependencies = [ + "portable-atomic", + "portable_atomic_enum_macros", +] + +[[package]] +name = "portable_atomic_enum_macros" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a33fa6ec7f2047f572d49317cca19c87195de99c6e5b6ee492da701cfe02b053" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "proc-macro-crate" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" +dependencies = [ + "toml_edit", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +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 = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" + +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "riscv" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05cfa3f7b30c84536a9025150d44d26b8e1cc20ddf436448d74cd9591eefb25" +dependencies = [ + "critical-section", + "embedded-hal 1.0.0", + "paste", + "riscv-macros", + "riscv-pac", +] + +[[package]] +name = "riscv-macros" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d323d13972c1b104aa036bc692cd08b822c8bbf23d79a27c526095856499799" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "riscv-pac" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8188909339ccc0c68cfb5a04648313f09621e8b87dc03095454f1a11f6c5d436" + +[[package]] +name = "riscv-rt" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d07b9f3a0eff773fc4df11f44ada4fa302e529bff4b7fe7e6a4b98a65ce9174" +dependencies = [ + "riscv", + "riscv-pac", + "riscv-rt-macros", + "riscv-target-parser", +] + +[[package]] +name = "riscv-rt-macros" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def519ddeeb5e43c2b4fc3952c27b3a86782fc05192f322b2309125cd85b1fc3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "riscv-target-parser" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1376b15f3ff160e9b1e8ea564ce427f2f6fcf77528cc0a8bf405cb476f9cea7" + +[[package]] +name = "rlsf" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07393724337be2ee43a9d86164df4505746874a3fa65913374bc6d6a92314362" +dependencies = [ + "cfg-if", + "const-default", + "libc", + "rustversion", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "sequential-storage" +version = "7.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "574e5a379bf43653079b34cb4cf32958404b5f42e0ed5b5adcdff02c2de04d4d" +dependencies = [ + "embedded-storage-async", +] + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "serde_yaml" +version = "0.9.34+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +dependencies = [ + "indexmap", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "smallvec" +version = "1.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b3dc8af474f516a851ff4bd12db780f948b9250ad37211e4eec0bccea54e01b" + +[[package]] +name = "smart-light" +version = "0.1.0" +dependencies = [ + "embassy-embedded-hal 0.5.0", + "embassy-executor", + "embassy-futures", + "embassy-sync 0.8.0", + "embassy-time", + "esp-alloc", + "esp-backtrace", + "esp-bootloader-esp-idf", + "esp-hal", + "esp-println", + "esp-radio", + "esp-rtos", + "esp-storage", + "log", + "static_cell", + "zigbee", + "zigbee-cluster-library", + "zigbee-mac", + "zigbee-types", +] + +[[package]] +name = "somni-expr" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed9b7648d5e8b2df6c5e49940c54bcdd2b4dd71eafc6e8f1c714eb4581b0f53" +dependencies = [ + "somni-parser", +] + +[[package]] +name = "somni-parser" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0f368519fc6c85fc1afdb769fb5a51123f6158013e143656e25a3485a0d401c" + +[[package]] +name = "spin" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "023a211cb3138dbc438680b32560ad89f699977624c9f8dbb95a47d5b4c07dd3" + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "static_cell" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0530892bb4fa575ee0da4b86f86c667132a94b74bb72160f58ee5a4afec74c23" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "strum" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[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.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "thread_local" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "toml_datetime" +version = "1.1.2+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b86d767906c6c42421dcba507eb9d203e779497710a47782a224bb871653053" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_edit" +version = "0.25.17+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3641d5bbb5349a79e1020a242d251efbc546ad8048d133958323ce9c40a9c9c" +dependencies = [ + "indexmap", + "toml_datetime", + "toml_parser", + "winnow", +] + +[[package]] +name = "toml_parser" +version = "1.1.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" +dependencies = [ + "winnow", +] + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex-automata", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "ufmt-write" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69" + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[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.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "winnow" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" +dependencies = [ + "memchr", +] + +[[package]] +name = "xtensa-lx" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e012d667b0aa6d2592ace8ef145a98bff3e76cca7a644f4181ecd7a916ed289b" +dependencies = [ + "critical-section", +] + +[[package]] +name = "xtensa-lx-rt" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "409a9b4629d429e995cde4dfbd9fe562ccae66f7624514e200733fc5d0ea8905" +dependencies = [ + "document-features", + "xtensa-lx", + "xtensa-lx-rt-proc-macros", +] + +[[package]] +name = "xtensa-lx-rt-proc-macros" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96fb42cd29c42f8744c74276e9f5bee7b06685bbe5b88df891516d72cb320450" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zigbee" +version = "0.1.0" +dependencies = [ + "embedded-hal-async", + "log", + "zigbee-base-device-behavior", + "zigbee-cluster-library", + "zigbee-core", + "zigbee-mac", + "zigbee-types", +] + +[[package]] +name = "zigbee-base-device-behavior" +version = "0.1.0" +dependencies = [ + "embedded-hal-async", + "log", + "spin", + "thiserror", + "zigbee-core", + "zigbee-mac", + "zigbee-types", +] + +[[package]] +name = "zigbee-cluster-library" +version = "0.1.0" +dependencies = [ + "byte", + "embedded-hal-async", + "heapless 0.9.3", + "spin", + "zigbee-core", + "zigbee-mac", + "zigbee-macros", +] + +[[package]] +name = "zigbee-core" +version = "0.1.0" +dependencies = [ + "aead 0.5.2", + "aes", + "byte", + "ccm 0.5.0", + "embedded-hal-async", + "embedded-storage-async", + "heapless 0.9.3", + "itertools", + "log", + "sequential-storage", + "spin", + "thiserror", + "zigbee-mac", + "zigbee-macros", + "zigbee-types", +] + +[[package]] +name = "zigbee-mac" +version = "0.1.0" +dependencies = [ + "byte", + "embassy-futures", + "embassy-sync 0.8.0", + "embassy-time", + "esp-alloc", + "esp-hal", + "esp-radio", + "esp-sync", + "heapless 0.9.3", + "ieee802154", + "log", + "thiserror", + "zigbee-macros", + "zigbee-types", +] + +[[package]] +name = "zigbee-macros" +version = "0.1.0" + +[[package]] +name = "zigbee-types" +version = "0.1.0" +dependencies = [ + "atomic-waker", + "byte", + "embedded-storage", + "heapless 0.9.3", + "itertools", + "spin", + "zigbee-macros", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..8946ad1 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,53 @@ +[package] +name = "smart-light" +version = "0.1.0" +edition = "2024" + +[features] +default = ["esp32c6"] +esp32c6 = [ + "esp-alloc/esp32c6", + "esp-backtrace/esp32c6", + "esp-bootloader-esp-idf/esp32c6", + "esp-hal/esp32c6", + "esp-println/esp32c6", + "esp-radio/esp32c6", + "esp-rtos/esp32c6", + "esp-storage/esp32c6", + "zigbee-mac/esp32c6", +] + +[dependencies] +esp-alloc = "0.10.0" +esp-backtrace = { version = "0.19.0", features = ["panic-handler", "println"] } +esp-bootloader-esp-idf = "0.5.0" +esp-hal = { version = "1.1.0", features = ["log-04", "unstable"] } +esp-println = { version = "0.17.0", features = ["log-04"] } +esp-radio = { version = "1.0.0-beta.0", features = ["ieee802154", "unstable"] } +esp-rtos = { version = "0.3.0", features = ["embassy", "log-04"] } +esp-storage = "0.9.0" + +embassy-executor = "0.10.0" +embassy-futures = "0.1" +embassy-sync = "0.8" +embassy-time = "0.5.0" +embassy-embedded-hal = "0.5.0" +static_cell = "2.1" +log = "0.4" + +# vendored upstream: the lighting cluster is not implemented there yet, so the +# path dependency lets us add it in-tree and upstream it later +zigbee = { path = "vendor/zigbee-rs/zigbee", features = ["storage"] } +zigbee-cluster-library = { path = "vendor/zigbee-rs/zigbee-cluster-library" } +zigbee-mac = { path = "vendor/zigbee-rs/zigbee-mac" } +zigbee-types = { path = "vendor/zigbee-rs/zigbee-types" } + +[profile.release] +debug = true +debug-assertions = false +lto = "fat" +codegen-units = 1 +opt-level = "s" + +[profile.dev] +opt-level = "s" diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..7b6c061 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "nightly" +components = ["rust-src", "rustfmt", "clippy"] +targets = ["riscv32imac-unknown-none-elf"] diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..c3c6498 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,22 @@ +//! Board wiring and strip geometry. +//! +//! Everything that changes when the hardware changes lives here. + +/// Number of WS2812B pixels on the strip. +pub const LED_COUNT: usize = 60; + +/// Ceiling on the duty cycle applied to every channel, as a fraction of 255. +/// +/// Keeps the supply current within what the dev board's regulator can source +/// when every pixel is driven white. +pub const MAX_DUTY: u8 = 200; + +/// Rotary encoder detents per full revolution, used to scale a turn into a +/// brightness step. +pub const STEPS_PER_BRIGHTNESS_UNIT: i32 = 1; + +/// Hold time that separates a click from a long press. +pub const LONG_PRESS_MS: u64 = 600; + +/// Contact settle time for the encoder push button. +pub const DEBOUNCE_MS: u64 = 15; diff --git a/src/encoder.rs b/src/encoder.rs new file mode 100644 index 0000000..3e0e761 --- /dev/null +++ b/src/encoder.rs @@ -0,0 +1,107 @@ +//! Interrupt-driven rotary encoder with a push button. +//! +//! Both tasks park on GPIO edge interrupts; nothing here polls. Quadrature is +//! decoded from the transition between the previous and current A/B pair, so a +//! bounce that returns to the previous state cancels itself out instead of +//! registering a step. + +use embassy_futures::select::Either; +use embassy_futures::select::select; +use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; +use embassy_sync::channel::Channel; +use embassy_time::Duration; +use embassy_time::Timer; +use embassy_time::with_timeout; +use esp_hal::gpio::Input; + +use crate::config::DEBOUNCE_MS; +use crate::config::LONG_PRESS_MS; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub enum EncoderEvent { + /// One detent; positive is clockwise. + Rotate(i8), + Click, + LongPress, +} + +/// Depth 8 absorbs a fast spin while the consumer is mid-frame; overflowing +/// drops the oldest step, which is preferable to blocking the interrupt task. +pub static EVENTS: Channel = Channel::new(); + +/// Valid quadrature transitions, indexed by `(previous << 2) | current` where +/// each pair is `(a << 1) | b`. Zero marks either no movement or an illegal +/// jump of two states, which means a transition was missed. +#[rustfmt::skip] +const TRANSITIONS: [i8; 16] = [ + 0, -1, 1, 0, + 1, 0, 0, -1, + -1, 0, 0, 1, + 0, 1, -1, 0, +]; + +#[embassy_executor::task] +pub async fn encoder_task(mut a: Input<'static>, mut b: Input<'static>) { + let mut previous = state(&a, &b); + // a full detent is four quadrature transitions; only whole detents are + // reported so a resting-point jitter never moves the light + let mut substeps: i8 = 0; + + loop { + match select(a.wait_for_any_edge(), b.wait_for_any_edge()).await { + Either::First(()) | Either::Second(()) => {} + } + + let current = state(&a, &b); + if current == previous { + continue; + } + + let delta = TRANSITIONS[usize::from((previous << 2) | current)]; + previous = current; + if delta == 0 { + continue; + } + + substeps += delta; + if substeps.abs() >= 4 { + let detents = substeps / 4; + substeps -= detents * 4; + // full is fine: a dropped step during a spin is invisible + let _ = EVENTS.try_send(EncoderEvent::Rotate(detents)); + } + } +} + +#[embassy_executor::task] +pub async fn button_task(mut button: Input<'static>) { + loop { + // active low: the switch shorts to ground when pressed + button.wait_for_falling_edge().await; + Timer::after(Duration::from_millis(DEBOUNCE_MS)).await; + if button.is_high() { + continue; + } + + let long_press = with_timeout( + Duration::from_millis(LONG_PRESS_MS), + button.wait_for_rising_edge(), + ) + .await + .is_err(); + + if long_press { + let _ = EVENTS.try_send(EncoderEvent::LongPress); + // swallow the release so it is not read as a second press + button.wait_for_rising_edge().await; + } else { + let _ = EVENTS.try_send(EncoderEvent::Click); + } + + Timer::after(Duration::from_millis(DEBOUNCE_MS)).await; + } +} + +fn state(a: &Input<'static>, b: &Input<'static>) -> usize { + usize::from(a.is_high()) << 1 | usize::from(b.is_high()) +} diff --git a/src/light.rs b/src/light.rs new file mode 100644 index 0000000..182c721 --- /dev/null +++ b/src/light.rs @@ -0,0 +1,129 @@ +//! Shared light state and the task that pushes it to the strip. +//! +//! The state is a few atomics plus a wake signal rather than a mutex, so the +//! encoder task and the Zigbee stack can both touch it without either waiting +//! on a frame to finish rendering. + +use core::sync::atomic::AtomicBool; +use core::sync::atomic::AtomicU8; +use core::sync::atomic::AtomicU16; +use core::sync::atomic::Ordering; + +use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; +use embassy_sync::signal::Signal; + +use crate::config::LED_COUNT; +use crate::config::MAX_DUTY; +use crate::ws2812::Rgb; +use crate::ws2812::Ws2812; + +/// What a turn of the encoder adjusts. +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub enum Mode { + Brightness, + Hue, +} + +static ON: AtomicBool = AtomicBool::new(false); +static BRIGHTNESS: AtomicU8 = AtomicU8::new(128); +static HUE: AtomicU16 = AtomicU16::new(0); +static HUE_MODE: AtomicBool = AtomicBool::new(false); +static DIRTY: Signal = Signal::new(); + +pub fn is_on() -> bool { + ON.load(Ordering::Relaxed) +} + +pub fn set_on(on: bool) { + ON.store(on, Ordering::Relaxed); + DIRTY.signal(()); +} + +pub fn toggle() -> bool { + let on = !is_on(); + set_on(on); + on +} + +pub fn brightness() -> u8 { + BRIGHTNESS.load(Ordering::Relaxed) +} + +/// Clamps rather than wraps: running past full should stay at full instead of +/// dropping the light to near-black. +pub fn adjust_brightness(delta: i16) { + let level = (i16::from(brightness()) + delta).clamp(1, 254) as u8; + BRIGHTNESS.store(level, Ordering::Relaxed); + DIRTY.signal(()); +} + +pub fn hue() -> u16 { + HUE.load(Ordering::Relaxed) +} + +/// Hue is a circle, so this one wraps. +pub fn adjust_hue(delta: i16) { + let hue = (i32::from(hue()) + i32::from(delta)).rem_euclid(360) as u16; + HUE.store(hue, Ordering::Relaxed); + DIRTY.signal(()); +} + +pub fn mode() -> Mode { + if HUE_MODE.load(Ordering::Relaxed) { + Mode::Hue + } else { + Mode::Brightness + } +} + +pub fn toggle_mode() -> Mode { + HUE_MODE.fetch_xor(true, Ordering::Relaxed); + mode() +} + +#[embassy_executor::task] +pub async fn render_task(mut strip: Ws2812<'static>) { + let mut frame = [Rgb::BLACK; LED_COUNT]; + + loop { + let colour = if is_on() { + let level = (u16::from(brightness()) * u16::from(MAX_DUTY) / 255) as u8; + hsv_to_rgb(hue(), 255, 255).scaled(level) + } else { + Rgb::BLACK + }; + frame.fill(colour); + + if let Err(e) = strip.write(&frame).await { + log::warn!("strip write failed: {e:?}"); + } + + DIRTY.wait().await; + } +} + +/// `hue` in degrees, `saturation` and `value` as 0..=255. +fn hsv_to_rgb(hue: u16, saturation: u8, value: u8) -> Rgb { + if saturation == 0 { + return Rgb::new(value, value, value); + } + + let sector = u32::from(hue % 360) / 60; + let offset = u32::from(hue % 360) % 60; + let v = u32::from(value); + let s = u32::from(saturation); + + let p = (v * (255 - s) / 255) as u8; + let q = (v * (255 - s * offset / 60) / 255) as u8; + let t = (v * (255 - s * (60 - offset) / 60) / 255) as u8; + let v = value; + + match sector { + 0 => Rgb::new(v, t, p), + 1 => Rgb::new(q, v, p), + 2 => Rgb::new(p, v, t), + 3 => Rgb::new(p, q, v), + 4 => Rgb::new(t, p, v), + _ => Rgb::new(v, p, q), + } +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..adb9733 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,116 @@ +#![no_std] +#![no_main] + +mod config; +mod encoder; +mod light; +mod ws2812; +mod zigbee_stack; + +use embassy_embedded_hal::adapter::BlockingAsync; +use esp_alloc as _; +use esp_backtrace as _; +use esp_hal::gpio::Input; +use esp_hal::gpio::InputConfig; +use esp_hal::gpio::Pull; +use esp_hal::interrupt::software::SoftwareInterruptControl; +use esp_hal::rmt::Rmt; +use esp_hal::rmt::TxChannelConfig; +use esp_hal::rmt::TxChannelCreator; +use esp_hal::time::Rate; +use esp_hal::timer::timg::TimerGroup; +use esp_radio::ieee802154::Ieee802154; +use esp_storage::FlashStorage; +use static_cell::StaticCell; +use zigbee_mac::esp::EspMlme; + +use crate::config::STEPS_PER_BRIGHTNESS_UNIT; +use crate::encoder::EVENTS; +use crate::encoder::EncoderEvent; +use crate::light::Mode; +use crate::ws2812::Ws2812; +use crate::zigbee_stack::Stack; + +esp_bootloader_esp_idf::esp_app_desc!(); + +static STACK: StaticCell = StaticCell::new(); + +/// Brightness units per detent. +const BRIGHTNESS_STEP: i16 = 8; + +/// Degrees of hue per detent. +const HUE_STEP: i16 = 6; + +#[esp_rtos::main] +async fn main(spawner: embassy_executor::Spawner) -> ! { + esp_println::logger::init_logger_from_env(); + let peripherals = esp_hal::init(esp_hal::Config::default()); + + let sw_int = SoftwareInterruptControl::new(peripherals.SW_INTERRUPT); + let timg0 = TimerGroup::new(peripherals.TIMG0); + esp_rtos::start(timg0.timer0, sw_int.software_interrupt0); + + esp_alloc::heap_allocator!(size: 32 * 1024); + + // 80 MHz with a divider of 1 gives the 12.5 ns tick the WS2812B bit + // timings in `ws2812` are expressed in + let rmt = Rmt::new(peripherals.RMT, Rate::from_mhz(80)) + .expect("init RMT") + .into_async(); + let rmt_channel = rmt + .channel0 + .configure_tx(&TxChannelConfig::default().with_clk_divider(1)) + .expect("configure RMT TX") + .with_pin(peripherals.GPIO2); + let strip = Ws2812::new(rmt_channel); + + // the encoder's common pin is grounded, so both phases and the switch idle + // high and are driven low; the pull-ups make an open contact well defined + let pull_up = InputConfig::default().with_pull(Pull::Up); + let encoder_a = Input::new(peripherals.GPIO4, pull_up); + let encoder_b = Input::new(peripherals.GPIO5, pull_up); + let button = Input::new(peripherals.GPIO6, pull_up); + + // the stack owns persistence: the information bases are restored here and + // written back whenever the stack changes them + let flash = BlockingAsync::new(FlashStorage::new(peripherals.FLASH)); + let storage = zigbee::storage::init_with_flash(flash, zigbee_stack::FLASH_RANGE).await; + + let ieee802154 = Ieee802154::new(peripherals.IEEE802154); + let mac = EspMlme::new(ieee802154, esp_radio::ieee802154::Config::default()); + log::info!("device IEEE address: {:#018x}", mac.ieee_address()); + + let stack: &'static Stack = STACK.init(Stack::new( + mac, + zigbee_stack::config(), + zigbee_stack::handler(), + storage, + )); + + spawner.spawn(light::render_task(strip).expect("spawn render_task")); + spawner.spawn(encoder::encoder_task(encoder_a, encoder_b).expect("spawn encoder_task")); + spawner.spawn(encoder::button_task(button).expect("spawn button_task")); + spawner.spawn(zigbee_stack::stack_task(stack).expect("spawn stack_task")); + spawner.spawn(zigbee_stack::on_off_task().expect("spawn on_off_task")); + spawner.spawn(zigbee_stack::identify_task().expect("spawn identify_task")); + + loop { + match EVENTS.receive().await { + EncoderEvent::Rotate(detents) => { + let steps = i16::from(detents) * STEPS_PER_BRIGHTNESS_UNIT as i16; + match light::mode() { + Mode::Brightness => light::adjust_brightness(steps * BRIGHTNESS_STEP), + Mode::Hue => light::adjust_hue(steps * HUE_STEP), + } + } + EncoderEvent::Click => { + let on = light::toggle(); + log::info!("light {}", if on { "on" } else { "off" }); + } + EncoderEvent::LongPress => { + let mode = light::toggle_mode(); + log::info!("encoder now adjusts {mode:?}"); + } + } + } +} diff --git a/src/ws2812.rs b/src/ws2812.rs new file mode 100644 index 0000000..29b6db2 --- /dev/null +++ b/src/ws2812.rs @@ -0,0 +1,85 @@ +//! WS2812B driver over the RMT peripheral. +//! +//! The RMT clock is divided to 12.5 ns per tick, so each of the 24 colour bits +//! becomes one `PulseCode` whose high and low durations encode a 0 or a 1. + +use esp_hal::Async; +use esp_hal::gpio::Level; +use esp_hal::rmt::Channel; +use esp_hal::rmt::PulseCode; +use esp_hal::rmt::Tx; + +use crate::config::LED_COUNT; + +/// Bit timings in RMT ticks at 80 MHz with a divider of 1 (12.5 ns/tick). +const T0H: u16 = 32; // 0.40 us +const T0L: u16 = 68; // 0.85 us +const T1H: u16 = 64; // 0.80 us +const T1L: u16 = 36; // 0.45 us + +/// Pulse codes for a whole frame, plus the terminating end marker. +const PULSE_COUNT: usize = LED_COUNT * 24 + 1; + +/// A colour in the order the application thinks about it; the wire order +/// (green first) is applied when encoding. +#[derive(Clone, Copy, PartialEq, Eq, Default, Debug)] +pub struct Rgb { + pub r: u8, + pub g: u8, + pub b: u8, +} + +impl Rgb { + pub const BLACK: Self = Self { r: 0, g: 0, b: 0 }; + + pub const fn new(r: u8, g: u8, b: u8) -> Self { + Self { r, g, b } + } + + /// Scales every channel by `level / 255`, rounding so that a non-zero + /// channel at a non-zero level never collapses to off. + #[must_use] + pub const fn scaled(self, level: u8) -> Self { + const fn scale(channel: u8, level: u8) -> u8 { + ((channel as u16 * level as u16 + 127) / 255) as u8 + } + Self { + r: scale(self.r, level), + g: scale(self.g, level), + b: scale(self.b, level), + } + } +} + +pub struct Ws2812<'d> { + channel: Channel<'d, Async, Tx>, + pulses: [PulseCode; PULSE_COUNT], +} + +impl<'d> Ws2812<'d> { + pub fn new(channel: Channel<'d, Async, Tx>) -> Self { + let mut pulses = [PulseCode::default(); PULSE_COUNT]; + pulses[PULSE_COUNT - 1] = PulseCode::end_marker(); + Self { channel, pulses } + } + + /// Encodes `pixels` and clocks the frame out. + /// + /// A frame shorter than the strip leaves the remaining pixels dark. + pub async fn write(&mut self, pixels: &[Rgb]) -> Result<(), esp_hal::rmt::Error> { + for (led, slot) in self.pulses[..LED_COUNT * 24].chunks_exact_mut(24).enumerate() { + let colour = pixels.get(led).copied().unwrap_or(Rgb::BLACK); + // WS2812B latches GRB, most significant bit first + let word = u32::from(colour.g) << 16 | u32::from(colour.r) << 8 | u32::from(colour.b); + for (bit, code) in slot.iter_mut().enumerate() { + *code = if word & (1 << (23 - bit)) != 0 { + PulseCode::new(Level::High, T1H, Level::Low, T1L) + } else { + PulseCode::new(Level::High, T0H, Level::Low, T0L) + }; + } + } + + self.channel.transmit(&self.pulses).await + } +} diff --git a/src/zigbee_stack.rs b/src/zigbee_stack.rs new file mode 100644 index 0000000..9d4176d --- /dev/null +++ b/src/zigbee_stack.rs @@ -0,0 +1,211 @@ +//! Zigbee end device: commissioning, the stack task, and the clusters served. +//! +//! The device is announced as an On/Off Light. Level Control and Color Control +//! (ZCL chapter 5) are deliberately absent: the vendored upstream does not +//! implement the lighting clusters yet, so for now brightness and hue are +//! local-only and the network sees on/off. + +use core::ops::Range; + +use embassy_embedded_hal::adapter::BlockingAsync; +use embassy_time::Duration; +use embassy_time::Timer; +use esp_storage::FlashStorage; +use zigbee::CurrentPowerMode; +use zigbee::CurrentPowerSourceLevel; +use zigbee::DeviceConfig; +use zigbee::LogicalType; +use zigbee::NetworkConfig; +use zigbee::PowerSource; +use zigbee::TimingConfig; +use zigbee::config::StackConfig; +use zigbee::nwk::nib::CapabilityInformation; +use zigbee::zdo::config::DiscoveryType; +use zigbee::zdo::descriptor::DeviceDescriptorConfig; +use zigbee::zdo::descriptor::EndpointDescriptor; +use zigbee::zdo::descriptor::NodeDescriptorConfig; +use zigbee::zdo::descriptor::PowerDescriptorConfig; +use zigbee_cluster_library::clusters::general::basic; +use zigbee_cluster_library::clusters::general::basic::BasicServer; +use zigbee_cluster_library::clusters::general::identify; +use zigbee_cluster_library::clusters::general::identify::IdentifyServer; +use zigbee_cluster_library::clusters::general::on_off; +use zigbee_cluster_library::clusters::general::on_off::OnOffServer; +use zigbee_cluster_library::profile; +use zigbee_cluster_library::reporting::ReportingTable; +use zigbee_cluster_library::server::UnsupportedClusterResponder; +use zigbee_mac::esp::EspMlme; +use zigbee_types::IeeeAddress; + +use crate::light; + +/// Flash region reserved for Zigbee persistence. +/// +/// MUST match the partition table: erase-sector aligned (4 KiB) and at least +/// two sectors so sequential-storage has a spare for garbage collection. The +/// address assumes the 4 MiB flash of the ESP32-C6-DevKitC-1. +pub const FLASH_RANGE: Range = 0x3f_0000..0x3f_4000; + +/// Extended PAN ID of the network to join. +/// +/// Placeholder: replace with the Extended PAN ID of your own coordinator. +const EXTENDED_PAN_ID: u64 = 0xabcd_ef01_2345_6789; + +/// Channel to scan on; must match the coordinator. +const CHANNEL: u8 = 11; + +/// Scan duration exponent (beacon order). +const SCAN_DURATION: u8 = 5; + +/// The application endpoint this light is served on. +const LIGHT_ENDPOINT: u8 = 1; + +/// Mains powered and always listening: allocate address (bit 7) and +/// rx-on-when-idle (bit 3), so the coordinator can push commands at any time +/// rather than waiting for a poll. +const CAPABILITY: u8 = 0x8e; + +static INPUT_CLUSTERS: [u16; 3] = [ + basic::CLUSTER_ID, + identify::CLUSTER_ID, + on_off::CLUSTER_ID, +]; +static OUTPUT_CLUSTERS: [u16; 0] = []; + +static ENDPOINTS: [EndpointDescriptor; 1] = [EndpointDescriptor { + endpoint: LIGHT_ENDPOINT, + profile_id: profile::HOME_AUTOMATION, + // HA device id 0x0100: On/Off Light. Becomes 0x0101 (Dimmable Light) once + // Level Control is implemented. + device_id: 0x0100, + device_version: 1, + input_clusters: &INPUT_CLUSTERS, + output_clusters: &OUTPUT_CLUSTERS, +}]; + +static BASIC: BasicServer = BasicServer { + zcl_version: 8, + application_version: 1, + stack_version: 0, + hw_version: 1, + manufacturer_name: "smart-light", + model_identifier: "smart-light.ws2812", + // 0x01: mains (single phase) + power_source: 0x01, +}; + +pub static IDENTIFY: IdentifyServer = IdentifyServer::new(); + +static REPORTING: ReportingTable<4> = ReportingTable::new(); + +static ON_OFF: OnOffServer = OnOffServer::new().with_reporting(&REPORTING); + +type ZigbeeFlash = zigbee::storage::FlashStorage>>; + +/// Cluster servers in the order they are offered a request. The responder is +/// last so an unclaimed cluster draws UNSUPPORTED_CLUSTER rather than silence +/// (ZCL 2.5.12.2). +type Handler = ( + BasicServer<'static>, + &'static IdentifyServer, + &'static OnOffServer<'static>, + UnsupportedClusterResponder<'static>, +); + +pub type Stack = zigbee::Stack<'static, EspMlme<'static>, Handler, ZigbeeFlash>; + +pub fn handler() -> Handler { + ( + BASIC, + &IDENTIFY, + &ON_OFF, + UnsupportedClusterResponder::new(&INPUT_CLUSTERS), + ) +} + +pub fn config() -> StackConfig<'static> { + StackConfig::new( + NetworkConfig { + extended_pan_id: IeeeAddress(EXTENDED_PAN_ID), + channels: CHANNEL..CHANNEL + 1, + scan_duration: SCAN_DURATION, + }, + DeviceConfig { + logical_type: LogicalType::EndDevice, + capability_information: CapabilityInformation(CAPABILITY), + discovery_type: DiscoveryType::default(), + tc_link_key_exchange: true, + }, + TimingConfig::default(), + DeviceDescriptorConfig { + node: NodeDescriptorConfig { + // bit 3: 2400 MHz band + frequency_band: 0x08, + manufacturer_code: 0x1037, + maximum_buffer_size: 80, + maximum_incoming_transfer_size: 128, + server_mask: 0, + maximum_outgoing_transfer_size: 128, + descriptor_capability_field: 0, + ..NodeDescriptorConfig::default() + }, + power: PowerDescriptorConfig { + current_power_mode: CurrentPowerMode::Synchronized, + available_power_sources: &[PowerSource::ConstantMainPower], + current_power_source: PowerSource::ConstantMainPower, + current_power_source_level: CurrentPowerSourceLevel::Full, + }, + endpoints: &ENDPOINTS, + }, + ) +} + +/// Drives the stack: commissioning, discovery, cluster reads and writes, the +/// parent link, and persistence. +#[embassy_executor::task] +pub async fn stack_task(stack: &'static Stack) { + // returns only once no rejoin can get us back: the network is gone or our + // keys are stale, so drop it and re-commission from scratch + let outcome = stack.run(embassy_time::Delay).await; + log::warn!("off the network ({outcome:?}), forgetting it and rebooting"); + stack.forget_network().await; + esp_hal::system::software_reset(); +} + +/// Mirrors the On/Off attribute onto the strip, both ways. +/// +/// The cluster server writes its attribute from the APS receive path without +/// any notification hook, so this samples it. The reverse direction keeps the +/// attribute truthful after a local button press. +#[embassy_executor::task] +pub async fn on_off_task() { + let mut last = ON_OFF.on_off(); + loop { + Timer::after(Duration::from_millis(50)).await; + + let remote = ON_OFF.on_off(); + if remote != last { + last = remote; + light::set_on(remote); + continue; + } + + let local = light::is_on(); + if local != last { + last = local; + ON_OFF.set_on_off(local); + } + } +} + +/// Counts the Identify state down once a second (ZCL 3.5.2.2.1). +#[embassy_executor::task] +pub async fn identify_task() { + loop { + Timer::after(Duration::from_secs(1)).await; + if IDENTIFY.is_identifying() { + let remaining = IDENTIFY.tick(1); + log::info!("identifying ({remaining}s remaining)"); + } + } +} diff --git a/vendor/zigbee-rs b/vendor/zigbee-rs new file mode 160000 index 0000000..c2f2436 --- /dev/null +++ b/vendor/zigbee-rs @@ -0,0 +1 @@ +Subproject commit c2f2436e76921a57480bff364051ff442b81c95c