├── .cargo └── config.toml ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── rust-toolchain.toml └── src ├── bmp180_async.rs └── main.rs /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.riscv32imc-unknown-none-elf] 2 | runner = "espflash flash --monitor" 3 | rustflags = ["-C", "link-arg=-Tlinkall.x"] 4 | 5 | [build] 6 | target = "riscv32imc-unknown-none-elf" 7 | 8 | [unstable] 9 | build-std = ["alloc", "core"] 10 | 11 | [env] 12 | ESP_LOG = "info" 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | debug/ 4 | target/ 5 | 6 | # These are backup files generated by rustfmt 7 | **/*.rs.bk 8 | 9 | # MSVC Windows builds of rustc generate these, which store debugging information 10 | *.pdb 11 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "anyhow" 7 | version = "1.0.97" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" 10 | 11 | [[package]] 12 | name = "autocfg" 13 | version = "1.4.0" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" 16 | 17 | [[package]] 18 | name = "basic-toml" 19 | version = "0.1.10" 20 | source = "registry+https://github.com/rust-lang/crates.io-index" 21 | checksum = "ba62675e8242a4c4e806d12f11d136e626e6c8361d6b829310732241652a178a" 22 | dependencies = [ 23 | "serde", 24 | ] 25 | 26 | [[package]] 27 | name = "bitfield" 28 | version = "0.18.1" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "4c7e6caee68becd795bfd65f1a026e4d00d8f0c2bc9be5eb568e1015f9ce3c34" 31 | dependencies = [ 32 | "bitfield-macros", 33 | ] 34 | 35 | [[package]] 36 | name = "bitfield-macros" 37 | version = "0.18.1" 38 | source = "registry+https://github.com/rust-lang/crates.io-index" 39 | checksum = "331afbb18ce7b644c0b428726d369c5dd37ca0b815d72a459fcc2896c3c8ad32" 40 | dependencies = [ 41 | "proc-macro2", 42 | "quote", 43 | "syn", 44 | ] 45 | 46 | [[package]] 47 | name = "bitflags" 48 | version = "1.3.2" 49 | source = "registry+https://github.com/rust-lang/crates.io-index" 50 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 51 | 52 | [[package]] 53 | name = "bitflags" 54 | version = "2.9.0" 55 | source = "registry+https://github.com/rust-lang/crates.io-index" 56 | checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" 57 | 58 | [[package]] 59 | name = "bytemuck" 60 | version = "1.22.0" 61 | source = "registry+https://github.com/rust-lang/crates.io-index" 62 | checksum = "b6b1fc10dbac614ebc03540c9dbd60e83887fda27794998c6528f1782047d540" 63 | 64 | [[package]] 65 | name = "byteorder" 66 | version = "1.5.0" 67 | source = "registry+https://github.com/rust-lang/crates.io-index" 68 | checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" 69 | 70 | [[package]] 71 | name = "cfg-if" 72 | version = "1.0.0" 73 | source = "registry+https://github.com/rust-lang/crates.io-index" 74 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 75 | 76 | [[package]] 77 | name = "chrono" 78 | version = "0.4.40" 79 | source = "registry+https://github.com/rust-lang/crates.io-index" 80 | checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c" 81 | dependencies = [ 82 | "num-traits", 83 | ] 84 | 85 | [[package]] 86 | name = "critical-section" 87 | version = "1.2.0" 88 | source = "registry+https://github.com/rust-lang/crates.io-index" 89 | checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" 90 | 91 | [[package]] 92 | name = "darling" 93 | version = "0.20.10" 94 | source = "registry+https://github.com/rust-lang/crates.io-index" 95 | checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" 96 | dependencies = [ 97 | "darling_core", 98 | "darling_macro", 99 | ] 100 | 101 | [[package]] 102 | name = "darling_core" 103 | version = "0.20.10" 104 | source = "registry+https://github.com/rust-lang/crates.io-index" 105 | checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" 106 | dependencies = [ 107 | "fnv", 108 | "ident_case", 109 | "proc-macro2", 110 | "quote", 111 | "strsim", 112 | "syn", 113 | ] 114 | 115 | [[package]] 116 | name = "darling_macro" 117 | version = "0.20.10" 118 | source = "registry+https://github.com/rust-lang/crates.io-index" 119 | checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" 120 | dependencies = [ 121 | "darling_core", 122 | "quote", 123 | "syn", 124 | ] 125 | 126 | [[package]] 127 | name = "delegate" 128 | version = "0.13.2" 129 | source = "registry+https://github.com/rust-lang/crates.io-index" 130 | checksum = "297806318ef30ad066b15792a8372858020ae3ca2e414ee6c2133b1eb9e9e945" 131 | dependencies = [ 132 | "proc-macro2", 133 | "quote", 134 | "syn", 135 | ] 136 | 137 | [[package]] 138 | name = "document-features" 139 | version = "0.2.11" 140 | source = "registry+https://github.com/rust-lang/crates.io-index" 141 | checksum = "95249b50c6c185bee49034bcb378a49dc2b5dff0be90ff6616d31d64febab05d" 142 | dependencies = [ 143 | "litrs", 144 | ] 145 | 146 | [[package]] 147 | name = "embassy-embedded-hal" 148 | version = "0.3.0" 149 | source = "registry+https://github.com/rust-lang/crates.io-index" 150 | checksum = "41fea5ef5bed4d3468dfd44f5c9fa4cda8f54c86d4fb4ae683eacf9d39e2ea12" 151 | dependencies = [ 152 | "embassy-futures", 153 | "embassy-sync", 154 | "embassy-time", 155 | "embedded-hal 0.2.7", 156 | "embedded-hal 1.0.0", 157 | "embedded-hal-async", 158 | "embedded-storage", 159 | "embedded-storage-async", 160 | "nb 1.1.0", 161 | ] 162 | 163 | [[package]] 164 | name = "embassy-executor" 165 | version = "0.7.0" 166 | source = "registry+https://github.com/rust-lang/crates.io-index" 167 | checksum = "90327bcc66333a507f89ecc4e2d911b265c45f5c9bc241f98eee076752d35ac6" 168 | dependencies = [ 169 | "critical-section", 170 | "document-features", 171 | "embassy-executor-macros", 172 | ] 173 | 174 | [[package]] 175 | name = "embassy-executor-macros" 176 | version = "0.6.2" 177 | source = "registry+https://github.com/rust-lang/crates.io-index" 178 | checksum = "3577b1e9446f61381179a330fc5324b01d511624c55f25e3c66c9e3c626dbecf" 179 | dependencies = [ 180 | "darling", 181 | "proc-macro2", 182 | "quote", 183 | "syn", 184 | ] 185 | 186 | [[package]] 187 | name = "embassy-futures" 188 | version = "0.1.1" 189 | source = "registry+https://github.com/rust-lang/crates.io-index" 190 | checksum = "1f878075b9794c1e4ac788c95b728f26aa6366d32eeb10c7051389f898f7d067" 191 | 192 | [[package]] 193 | name = "embassy-net" 194 | version = "0.6.0" 195 | source = "registry+https://github.com/rust-lang/crates.io-index" 196 | checksum = "ed041cc19a603d657124fddefdcbe5ef8bd60e77d972793ebb57de93394f5949" 197 | dependencies = [ 198 | "document-features", 199 | "embassy-net-driver", 200 | "embassy-sync", 201 | "embassy-time", 202 | "embedded-io-async", 203 | "embedded-nal-async", 204 | "heapless", 205 | "log", 206 | "managed", 207 | "smoltcp", 208 | ] 209 | 210 | [[package]] 211 | name = "embassy-net-driver" 212 | version = "0.2.0" 213 | source = "registry+https://github.com/rust-lang/crates.io-index" 214 | checksum = "524eb3c489760508f71360112bca70f6e53173e6fe48fc5f0efd0f5ab217751d" 215 | 216 | [[package]] 217 | name = "embassy-sync" 218 | version = "0.6.2" 219 | source = "registry+https://github.com/rust-lang/crates.io-index" 220 | checksum = "8d2c8cdff05a7a51ba0087489ea44b0b1d97a296ca6b1d6d1a33ea7423d34049" 221 | dependencies = [ 222 | "cfg-if", 223 | "critical-section", 224 | "embedded-io-async", 225 | "futures-sink", 226 | "futures-util", 227 | "heapless", 228 | ] 229 | 230 | [[package]] 231 | name = "embassy-time" 232 | version = "0.4.0" 233 | source = "registry+https://github.com/rust-lang/crates.io-index" 234 | checksum = "f820157f198ada183ad62e0a66f554c610cdcd1a9f27d4b316358103ced7a1f8" 235 | dependencies = [ 236 | "cfg-if", 237 | "critical-section", 238 | "document-features", 239 | "embassy-time-driver", 240 | "embedded-hal 0.2.7", 241 | "embedded-hal 1.0.0", 242 | "embedded-hal-async", 243 | "futures-util", 244 | ] 245 | 246 | [[package]] 247 | name = "embassy-time-driver" 248 | version = "0.2.0" 249 | source = "registry+https://github.com/rust-lang/crates.io-index" 250 | checksum = "8d45f5d833b6d98bd2aab0c2de70b18bfaa10faf661a1578fd8e5dfb15eb7eba" 251 | dependencies = [ 252 | "document-features", 253 | ] 254 | 255 | [[package]] 256 | name = "embassy-time-queue-utils" 257 | version = "0.1.0" 258 | source = "registry+https://github.com/rust-lang/crates.io-index" 259 | checksum = "dc55c748d16908a65b166d09ce976575fb8852cf60ccd06174092b41064d8f83" 260 | dependencies = [ 261 | "embassy-executor", 262 | "heapless", 263 | ] 264 | 265 | [[package]] 266 | name = "embedded-can" 267 | version = "0.4.1" 268 | source = "registry+https://github.com/rust-lang/crates.io-index" 269 | checksum = "e9d2e857f87ac832df68fa498d18ddc679175cf3d2e4aa893988e5601baf9438" 270 | dependencies = [ 271 | "nb 1.1.0", 272 | ] 273 | 274 | [[package]] 275 | name = "embedded-hal" 276 | version = "0.2.7" 277 | source = "registry+https://github.com/rust-lang/crates.io-index" 278 | checksum = "35949884794ad573cf46071e41c9b60efb0cb311e3ca01f7af807af1debc66ff" 279 | dependencies = [ 280 | "nb 0.1.3", 281 | "void", 282 | ] 283 | 284 | [[package]] 285 | name = "embedded-hal" 286 | version = "1.0.0" 287 | source = "registry+https://github.com/rust-lang/crates.io-index" 288 | checksum = "361a90feb7004eca4019fb28352a9465666b24f840f5c3cddf0ff13920590b89" 289 | 290 | [[package]] 291 | name = "embedded-hal-async" 292 | version = "1.0.0" 293 | source = "registry+https://github.com/rust-lang/crates.io-index" 294 | checksum = "0c4c685bbef7fe13c3c6dd4da26841ed3980ef33e841cddfa15ce8a8fb3f1884" 295 | dependencies = [ 296 | "embedded-hal 1.0.0", 297 | ] 298 | 299 | [[package]] 300 | name = "embedded-io" 301 | version = "0.6.1" 302 | source = "registry+https://github.com/rust-lang/crates.io-index" 303 | checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" 304 | 305 | [[package]] 306 | name = "embedded-io-async" 307 | version = "0.6.1" 308 | source = "registry+https://github.com/rust-lang/crates.io-index" 309 | checksum = "3ff09972d4073aa8c299395be75161d582e7629cd663171d62af73c8d50dba3f" 310 | dependencies = [ 311 | "embedded-io", 312 | ] 313 | 314 | [[package]] 315 | name = "embedded-nal" 316 | version = "0.9.0" 317 | source = "registry+https://github.com/rust-lang/crates.io-index" 318 | checksum = "c56a28be191a992f28f178ec338a0bf02f63d7803244add736d026a471e6ed77" 319 | dependencies = [ 320 | "nb 1.1.0", 321 | ] 322 | 323 | [[package]] 324 | name = "embedded-nal-async" 325 | version = "0.8.0" 326 | source = "registry+https://github.com/rust-lang/crates.io-index" 327 | checksum = "76959917cd2b86f40a98c28dd5624eddd1fa69d746241c8257eac428d83cb211" 328 | dependencies = [ 329 | "embedded-io-async", 330 | "embedded-nal", 331 | ] 332 | 333 | [[package]] 334 | name = "embedded-storage" 335 | version = "0.3.1" 336 | source = "registry+https://github.com/rust-lang/crates.io-index" 337 | checksum = "a21dea9854beb860f3062d10228ce9b976da520a73474aed3171ec276bc0c032" 338 | 339 | [[package]] 340 | name = "embedded-storage-async" 341 | version = "0.4.1" 342 | source = "registry+https://github.com/rust-lang/crates.io-index" 343 | checksum = "1763775e2323b7d5f0aa6090657f5e21cfa02ede71f5dc40eead06d64dcd15cc" 344 | dependencies = [ 345 | "embedded-storage", 346 | ] 347 | 348 | [[package]] 349 | name = "enum-as-inner" 350 | version = "0.6.1" 351 | source = "registry+https://github.com/rust-lang/crates.io-index" 352 | checksum = "a1e6a265c649f3f5979b601d26f1d05ada116434c87741c9493cb56218f76cbc" 353 | dependencies = [ 354 | "heck", 355 | "proc-macro2", 356 | "quote", 357 | "syn", 358 | ] 359 | 360 | [[package]] 361 | name = "enumset" 362 | version = "1.1.5" 363 | source = "registry+https://github.com/rust-lang/crates.io-index" 364 | checksum = "d07a4b049558765cef5f0c1a273c3fc57084d768b44d2f98127aef4cceb17293" 365 | dependencies = [ 366 | "enumset_derive", 367 | ] 368 | 369 | [[package]] 370 | name = "enumset_derive" 371 | version = "0.10.0" 372 | source = "registry+https://github.com/rust-lang/crates.io-index" 373 | checksum = "59c3b24c345d8c314966bdc1832f6c2635bfcce8e7cf363bd115987bba2ee242" 374 | dependencies = [ 375 | "darling", 376 | "proc-macro2", 377 | "quote", 378 | "syn", 379 | ] 380 | 381 | [[package]] 382 | name = "equivalent" 383 | version = "1.0.2" 384 | source = "registry+https://github.com/rust-lang/crates.io-index" 385 | checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" 386 | 387 | [[package]] 388 | name = "esp-alloc" 389 | version = "0.7.0" 390 | source = "registry+https://github.com/rust-lang/crates.io-index" 391 | checksum = "a78132d362cbf62ce22a1466eb9e98424f6b2d1e476e7a3cb46ca9063c5833f7" 392 | dependencies = [ 393 | "cfg-if", 394 | "critical-section", 395 | "document-features", 396 | "enumset", 397 | "linked_list_allocator", 398 | ] 399 | 400 | [[package]] 401 | name = "esp-backtrace" 402 | version = "0.15.1" 403 | source = "registry+https://github.com/rust-lang/crates.io-index" 404 | checksum = "e4cd70abe47945c9116972781b5c05277ad855a5f5569fe2afd3e2e61a103cc0" 405 | dependencies = [ 406 | "esp-build", 407 | "esp-println", 408 | ] 409 | 410 | [[package]] 411 | name = "esp-build" 412 | version = "0.2.0" 413 | source = "registry+https://github.com/rust-lang/crates.io-index" 414 | checksum = "8aa1c8f9954c9506699cf1ca10a2adcc226ff10b6ae3cb9e875cf2c6a0b9a372" 415 | dependencies = [ 416 | "quote", 417 | "syn", 418 | "termcolor", 419 | ] 420 | 421 | [[package]] 422 | name = "esp-config" 423 | version = "0.3.1" 424 | source = "registry+https://github.com/rust-lang/crates.io-index" 425 | checksum = "158dba334d3a2acd8d93873c0ae723ca1037cc78eefe5d6b4c5919b0ca28e38e" 426 | dependencies = [ 427 | "document-features", 428 | ] 429 | 430 | [[package]] 431 | name = "esp-hal" 432 | version = "1.0.0-beta.0" 433 | source = "registry+https://github.com/rust-lang/crates.io-index" 434 | checksum = "e9efaa9c1324ca20a22086aba2ce47a9bdc5bd65969af8b0cd5e879603b57bef" 435 | dependencies = [ 436 | "basic-toml", 437 | "bitfield", 438 | "bitflags 2.9.0", 439 | "bytemuck", 440 | "cfg-if", 441 | "chrono", 442 | "critical-section", 443 | "delegate", 444 | "document-features", 445 | "embassy-embedded-hal", 446 | "embassy-futures", 447 | "embassy-sync", 448 | "embedded-can", 449 | "embedded-hal 1.0.0", 450 | "embedded-hal-async", 451 | "embedded-io", 452 | "embedded-io-async", 453 | "enumset", 454 | "esp-build", 455 | "esp-config", 456 | "esp-hal-procmacros", 457 | "esp-metadata", 458 | "esp-riscv-rt", 459 | "esp32c3", 460 | "fugit", 461 | "instability", 462 | "log", 463 | "nb 1.1.0", 464 | "paste", 465 | "portable-atomic", 466 | "rand_core", 467 | "riscv", 468 | "serde", 469 | "strum 0.27.1", 470 | "ufmt-write", 471 | "void", 472 | "xtensa-lx", 473 | "xtensa-lx-rt", 474 | ] 475 | 476 | [[package]] 477 | name = "esp-hal-embassy" 478 | version = "0.7.0" 479 | source = "registry+https://github.com/rust-lang/crates.io-index" 480 | checksum = "b27f41110117a9bf2be385b42535c686b301c8ce3b5ea0a07567e200a63a2239" 481 | dependencies = [ 482 | "critical-section", 483 | "document-features", 484 | "embassy-executor", 485 | "embassy-sync", 486 | "embassy-time", 487 | "embassy-time-driver", 488 | "embassy-time-queue-utils", 489 | "esp-build", 490 | "esp-config", 491 | "esp-hal", 492 | "esp-hal-procmacros", 493 | "esp-metadata", 494 | "portable-atomic", 495 | "static_cell", 496 | ] 497 | 498 | [[package]] 499 | name = "esp-hal-procmacros" 500 | version = "0.17.0" 501 | source = "registry+https://github.com/rust-lang/crates.io-index" 502 | checksum = "1bd340a20a7d546570af58fd9e2aae17466a42572680d8e70d35fc7c475c4ed8" 503 | dependencies = [ 504 | "darling", 505 | "document-features", 506 | "litrs", 507 | "proc-macro-crate", 508 | "proc-macro-error2", 509 | "proc-macro2", 510 | "quote", 511 | "syn", 512 | ] 513 | 514 | [[package]] 515 | name = "esp-metadata" 516 | version = "0.6.0" 517 | source = "registry+https://github.com/rust-lang/crates.io-index" 518 | checksum = "30b4bffc22b7b1222c9467f0cb90eb49dcb63de810ecb3300e4b3bbc4ac2423e" 519 | dependencies = [ 520 | "anyhow", 521 | "basic-toml", 522 | "serde", 523 | "strum 0.26.3", 524 | ] 525 | 526 | [[package]] 527 | name = "esp-println" 528 | version = "0.13.1" 529 | source = "registry+https://github.com/rust-lang/crates.io-index" 530 | checksum = "960703930f9f3c899ddedd122ea27a09d6a612c22323157e524af5b18876448e" 531 | dependencies = [ 532 | "critical-section", 533 | "esp-build", 534 | "log", 535 | "portable-atomic", 536 | ] 537 | 538 | [[package]] 539 | name = "esp-riscv-rt" 540 | version = "0.10.0" 541 | source = "registry+https://github.com/rust-lang/crates.io-index" 542 | checksum = "ec69987b3d7c48b65f8fb829220832a101478d766c518ae836720d040608d5dd" 543 | dependencies = [ 544 | "document-features", 545 | "riscv", 546 | "riscv-rt-macros", 547 | ] 548 | 549 | [[package]] 550 | name = "esp-wifi" 551 | version = "0.13.0" 552 | source = "registry+https://github.com/rust-lang/crates.io-index" 553 | checksum = "cd7d7ea0e2c374343a375758861e13cf618db619436bcb386dfe5529ef31e9d5" 554 | dependencies = [ 555 | "cfg-if", 556 | "critical-section", 557 | "document-features", 558 | "embassy-net-driver", 559 | "embassy-sync", 560 | "embedded-io", 561 | "embedded-io-async", 562 | "enumset", 563 | "esp-alloc", 564 | "esp-build", 565 | "esp-config", 566 | "esp-hal", 567 | "esp-metadata", 568 | "esp-wifi-sys", 569 | "heapless", 570 | "libm", 571 | "log", 572 | "num-derive", 573 | "num-traits", 574 | "portable-atomic", 575 | "portable_atomic_enum", 576 | "rand_core", 577 | ] 578 | 579 | [[package]] 580 | name = "esp-wifi-sys" 581 | version = "0.7.1" 582 | source = "registry+https://github.com/rust-lang/crates.io-index" 583 | checksum = "c6b5438361891c431970194a733415006fb3d00b6eb70b3dcb66fd58f04d9b39" 584 | dependencies = [ 585 | "anyhow", 586 | "log", 587 | ] 588 | 589 | [[package]] 590 | name = "esp32c3" 591 | version = "0.28.0" 592 | source = "registry+https://github.com/rust-lang/crates.io-index" 593 | checksum = "df1bbcfa3ab2979171263db80804dabc38bdd45450c7eb775ee3f81d552cf0ba" 594 | dependencies = [ 595 | "critical-section", 596 | "vcell", 597 | ] 598 | 599 | [[package]] 600 | name = "esp32c3_no_std_async_mqtt_demo" 601 | version = "0.1.0" 602 | dependencies = [ 603 | "embassy-executor", 604 | "embassy-net", 605 | "embassy-time", 606 | "embedded-hal-async", 607 | "esp-alloc", 608 | "esp-backtrace", 609 | "esp-hal", 610 | "esp-hal-embassy", 611 | "esp-println", 612 | "esp-wifi", 613 | "heapless", 614 | "log", 615 | "rust-mqtt", 616 | "static_cell", 617 | ] 618 | 619 | [[package]] 620 | name = "fnv" 621 | version = "1.0.7" 622 | source = "registry+https://github.com/rust-lang/crates.io-index" 623 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 624 | 625 | [[package]] 626 | name = "fugit" 627 | version = "0.3.7" 628 | source = "registry+https://github.com/rust-lang/crates.io-index" 629 | checksum = "17186ad64927d5ac8f02c1e77ccefa08ccd9eaa314d5a4772278aa204a22f7e7" 630 | dependencies = [ 631 | "gcd", 632 | ] 633 | 634 | [[package]] 635 | name = "futures-core" 636 | version = "0.3.31" 637 | source = "registry+https://github.com/rust-lang/crates.io-index" 638 | checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" 639 | 640 | [[package]] 641 | name = "futures-sink" 642 | version = "0.3.31" 643 | source = "registry+https://github.com/rust-lang/crates.io-index" 644 | checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" 645 | 646 | [[package]] 647 | name = "futures-task" 648 | version = "0.3.31" 649 | source = "registry+https://github.com/rust-lang/crates.io-index" 650 | checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" 651 | 652 | [[package]] 653 | name = "futures-util" 654 | version = "0.3.31" 655 | source = "registry+https://github.com/rust-lang/crates.io-index" 656 | checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" 657 | dependencies = [ 658 | "futures-core", 659 | "futures-task", 660 | "pin-project-lite", 661 | "pin-utils", 662 | ] 663 | 664 | [[package]] 665 | name = "gcd" 666 | version = "2.3.0" 667 | source = "registry+https://github.com/rust-lang/crates.io-index" 668 | checksum = "1d758ba1b47b00caf47f24925c0074ecb20d6dfcffe7f6d53395c0465674841a" 669 | 670 | [[package]] 671 | name = "hash32" 672 | version = "0.3.1" 673 | source = "registry+https://github.com/rust-lang/crates.io-index" 674 | checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" 675 | dependencies = [ 676 | "byteorder", 677 | ] 678 | 679 | [[package]] 680 | name = "hashbrown" 681 | version = "0.15.2" 682 | source = "registry+https://github.com/rust-lang/crates.io-index" 683 | checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" 684 | 685 | [[package]] 686 | name = "heapless" 687 | version = "0.8.0" 688 | source = "registry+https://github.com/rust-lang/crates.io-index" 689 | checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" 690 | dependencies = [ 691 | "hash32", 692 | "portable-atomic", 693 | "stable_deref_trait", 694 | ] 695 | 696 | [[package]] 697 | name = "heck" 698 | version = "0.5.0" 699 | source = "registry+https://github.com/rust-lang/crates.io-index" 700 | checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" 701 | 702 | [[package]] 703 | name = "ident_case" 704 | version = "1.0.1" 705 | source = "registry+https://github.com/rust-lang/crates.io-index" 706 | checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" 707 | 708 | [[package]] 709 | name = "indexmap" 710 | version = "2.8.0" 711 | source = "registry+https://github.com/rust-lang/crates.io-index" 712 | checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" 713 | dependencies = [ 714 | "equivalent", 715 | "hashbrown", 716 | ] 717 | 718 | [[package]] 719 | name = "indoc" 720 | version = "2.0.6" 721 | source = "registry+https://github.com/rust-lang/crates.io-index" 722 | checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd" 723 | 724 | [[package]] 725 | name = "instability" 726 | version = "0.3.7" 727 | source = "registry+https://github.com/rust-lang/crates.io-index" 728 | checksum = "0bf9fed6d91cfb734e7476a06bde8300a1b94e217e1b523b6f0cd1a01998c71d" 729 | dependencies = [ 730 | "darling", 731 | "indoc", 732 | "proc-macro2", 733 | "quote", 734 | "syn", 735 | ] 736 | 737 | [[package]] 738 | name = "libm" 739 | version = "0.2.11" 740 | source = "registry+https://github.com/rust-lang/crates.io-index" 741 | checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" 742 | 743 | [[package]] 744 | name = "linked_list_allocator" 745 | version = "0.10.5" 746 | source = "registry+https://github.com/rust-lang/crates.io-index" 747 | checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" 748 | 749 | [[package]] 750 | name = "litrs" 751 | version = "0.4.1" 752 | source = "registry+https://github.com/rust-lang/crates.io-index" 753 | checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" 754 | dependencies = [ 755 | "proc-macro2", 756 | ] 757 | 758 | [[package]] 759 | name = "log" 760 | version = "0.4.26" 761 | source = "registry+https://github.com/rust-lang/crates.io-index" 762 | checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" 763 | 764 | [[package]] 765 | name = "managed" 766 | version = "0.8.0" 767 | source = "registry+https://github.com/rust-lang/crates.io-index" 768 | checksum = "0ca88d725a0a943b096803bd34e73a4437208b6077654cc4ecb2947a5f91618d" 769 | 770 | [[package]] 771 | name = "memchr" 772 | version = "2.7.4" 773 | source = "registry+https://github.com/rust-lang/crates.io-index" 774 | checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 775 | 776 | [[package]] 777 | name = "minijinja" 778 | version = "2.8.0" 779 | source = "registry+https://github.com/rust-lang/crates.io-index" 780 | checksum = "6e36f1329330bb1614c94b78632b9ce45dd7d761f3304a1bed07b2990a7c5097" 781 | dependencies = [ 782 | "serde", 783 | ] 784 | 785 | [[package]] 786 | name = "nb" 787 | version = "0.1.3" 788 | source = "registry+https://github.com/rust-lang/crates.io-index" 789 | checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" 790 | dependencies = [ 791 | "nb 1.1.0", 792 | ] 793 | 794 | [[package]] 795 | name = "nb" 796 | version = "1.1.0" 797 | source = "registry+https://github.com/rust-lang/crates.io-index" 798 | checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" 799 | 800 | [[package]] 801 | name = "num-derive" 802 | version = "0.4.2" 803 | source = "registry+https://github.com/rust-lang/crates.io-index" 804 | checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" 805 | dependencies = [ 806 | "proc-macro2", 807 | "quote", 808 | "syn", 809 | ] 810 | 811 | [[package]] 812 | name = "num-traits" 813 | version = "0.2.19" 814 | source = "registry+https://github.com/rust-lang/crates.io-index" 815 | checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" 816 | dependencies = [ 817 | "autocfg", 818 | ] 819 | 820 | [[package]] 821 | name = "paste" 822 | version = "1.0.15" 823 | source = "registry+https://github.com/rust-lang/crates.io-index" 824 | checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" 825 | 826 | [[package]] 827 | name = "pin-project-lite" 828 | version = "0.2.16" 829 | source = "registry+https://github.com/rust-lang/crates.io-index" 830 | checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" 831 | 832 | [[package]] 833 | name = "pin-utils" 834 | version = "0.1.0" 835 | source = "registry+https://github.com/rust-lang/crates.io-index" 836 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 837 | 838 | [[package]] 839 | name = "portable-atomic" 840 | version = "1.11.0" 841 | source = "registry+https://github.com/rust-lang/crates.io-index" 842 | checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e" 843 | 844 | [[package]] 845 | name = "portable_atomic_enum" 846 | version = "0.3.1" 847 | source = "registry+https://github.com/rust-lang/crates.io-index" 848 | checksum = "30d48f60c43e0120bb2bb48589a16d4bed2f4b911be41e299f2d0fc0e0e20885" 849 | dependencies = [ 850 | "portable-atomic", 851 | "portable_atomic_enum_macros", 852 | ] 853 | 854 | [[package]] 855 | name = "portable_atomic_enum_macros" 856 | version = "0.2.1" 857 | source = "registry+https://github.com/rust-lang/crates.io-index" 858 | checksum = "a33fa6ec7f2047f572d49317cca19c87195de99c6e5b6ee492da701cfe02b053" 859 | dependencies = [ 860 | "proc-macro2", 861 | "quote", 862 | "syn", 863 | ] 864 | 865 | [[package]] 866 | name = "proc-macro-crate" 867 | version = "3.3.0" 868 | source = "registry+https://github.com/rust-lang/crates.io-index" 869 | checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" 870 | dependencies = [ 871 | "toml_edit", 872 | ] 873 | 874 | [[package]] 875 | name = "proc-macro-error-attr2" 876 | version = "2.0.0" 877 | source = "registry+https://github.com/rust-lang/crates.io-index" 878 | checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" 879 | dependencies = [ 880 | "proc-macro2", 881 | "quote", 882 | ] 883 | 884 | [[package]] 885 | name = "proc-macro-error2" 886 | version = "2.0.1" 887 | source = "registry+https://github.com/rust-lang/crates.io-index" 888 | checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" 889 | dependencies = [ 890 | "proc-macro-error-attr2", 891 | "proc-macro2", 892 | "quote", 893 | "syn", 894 | ] 895 | 896 | [[package]] 897 | name = "proc-macro2" 898 | version = "1.0.94" 899 | source = "registry+https://github.com/rust-lang/crates.io-index" 900 | checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" 901 | dependencies = [ 902 | "unicode-ident", 903 | ] 904 | 905 | [[package]] 906 | name = "quote" 907 | version = "1.0.40" 908 | source = "registry+https://github.com/rust-lang/crates.io-index" 909 | checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" 910 | dependencies = [ 911 | "proc-macro2", 912 | ] 913 | 914 | [[package]] 915 | name = "r0" 916 | version = "1.0.0" 917 | source = "registry+https://github.com/rust-lang/crates.io-index" 918 | checksum = "bd7a31eed1591dcbc95d92ad7161908e72f4677f8fabf2a32ca49b4237cbf211" 919 | 920 | [[package]] 921 | name = "rand_core" 922 | version = "0.6.4" 923 | source = "registry+https://github.com/rust-lang/crates.io-index" 924 | checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" 925 | 926 | [[package]] 927 | name = "riscv" 928 | version = "0.12.1" 929 | source = "registry+https://github.com/rust-lang/crates.io-index" 930 | checksum = "5ea8ff73d3720bdd0a97925f0bf79ad2744b6da8ff36be3840c48ac81191d7a7" 931 | dependencies = [ 932 | "critical-section", 933 | "embedded-hal 1.0.0", 934 | "paste", 935 | "riscv-macros", 936 | "riscv-pac", 937 | ] 938 | 939 | [[package]] 940 | name = "riscv-macros" 941 | version = "0.1.0" 942 | source = "registry+https://github.com/rust-lang/crates.io-index" 943 | checksum = "f265be5d634272320a7de94cea15c22a3bfdd4eb42eb43edc528415f066a1f25" 944 | dependencies = [ 945 | "proc-macro2", 946 | "quote", 947 | "syn", 948 | ] 949 | 950 | [[package]] 951 | name = "riscv-pac" 952 | version = "0.2.0" 953 | source = "registry+https://github.com/rust-lang/crates.io-index" 954 | checksum = "8188909339ccc0c68cfb5a04648313f09621e8b87dc03095454f1a11f6c5d436" 955 | 956 | [[package]] 957 | name = "riscv-rt-macros" 958 | version = "0.4.0" 959 | source = "registry+https://github.com/rust-lang/crates.io-index" 960 | checksum = "fc71814687c45ba4cd1e47a54e03a2dbc62ca3667098fbae9cc6b423956758fa" 961 | dependencies = [ 962 | "proc-macro2", 963 | "quote", 964 | "syn", 965 | ] 966 | 967 | [[package]] 968 | name = "rust-mqtt" 969 | version = "0.3.0" 970 | source = "registry+https://github.com/rust-lang/crates.io-index" 971 | checksum = "8f71160765f368fd9a84e0955e2ddb6d64ac9018fee1c5323354d6d08c816b40" 972 | dependencies = [ 973 | "embedded-io", 974 | "embedded-io-async", 975 | "heapless", 976 | "rand_core", 977 | ] 978 | 979 | [[package]] 980 | name = "rustversion" 981 | version = "1.0.20" 982 | source = "registry+https://github.com/rust-lang/crates.io-index" 983 | checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" 984 | 985 | [[package]] 986 | name = "serde" 987 | version = "1.0.219" 988 | source = "registry+https://github.com/rust-lang/crates.io-index" 989 | checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" 990 | dependencies = [ 991 | "serde_derive", 992 | ] 993 | 994 | [[package]] 995 | name = "serde_derive" 996 | version = "1.0.219" 997 | source = "registry+https://github.com/rust-lang/crates.io-index" 998 | checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" 999 | dependencies = [ 1000 | "proc-macro2", 1001 | "quote", 1002 | "syn", 1003 | ] 1004 | 1005 | [[package]] 1006 | name = "serde_spanned" 1007 | version = "0.6.8" 1008 | source = "registry+https://github.com/rust-lang/crates.io-index" 1009 | checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" 1010 | dependencies = [ 1011 | "serde", 1012 | ] 1013 | 1014 | [[package]] 1015 | name = "smoltcp" 1016 | version = "0.12.0" 1017 | source = "registry+https://github.com/rust-lang/crates.io-index" 1018 | checksum = "dad095989c1533c1c266d9b1e8d70a1329dd3723c3edac6d03bbd67e7bf6f4bb" 1019 | dependencies = [ 1020 | "bitflags 1.3.2", 1021 | "byteorder", 1022 | "cfg-if", 1023 | "heapless", 1024 | "managed", 1025 | ] 1026 | 1027 | [[package]] 1028 | name = "stable_deref_trait" 1029 | version = "1.2.0" 1030 | source = "registry+https://github.com/rust-lang/crates.io-index" 1031 | checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" 1032 | 1033 | [[package]] 1034 | name = "static_cell" 1035 | version = "2.1.0" 1036 | source = "registry+https://github.com/rust-lang/crates.io-index" 1037 | checksum = "d89b0684884a883431282db1e4343f34afc2ff6996fe1f4a1664519b66e14c1e" 1038 | dependencies = [ 1039 | "portable-atomic", 1040 | ] 1041 | 1042 | [[package]] 1043 | name = "strsim" 1044 | version = "0.11.1" 1045 | source = "registry+https://github.com/rust-lang/crates.io-index" 1046 | checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" 1047 | 1048 | [[package]] 1049 | name = "strum" 1050 | version = "0.26.3" 1051 | source = "registry+https://github.com/rust-lang/crates.io-index" 1052 | checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" 1053 | dependencies = [ 1054 | "strum_macros 0.26.4", 1055 | ] 1056 | 1057 | [[package]] 1058 | name = "strum" 1059 | version = "0.27.1" 1060 | source = "registry+https://github.com/rust-lang/crates.io-index" 1061 | checksum = "f64def088c51c9510a8579e3c5d67c65349dcf755e5479ad3d010aa6454e2c32" 1062 | dependencies = [ 1063 | "strum_macros 0.27.1", 1064 | ] 1065 | 1066 | [[package]] 1067 | name = "strum_macros" 1068 | version = "0.26.4" 1069 | source = "registry+https://github.com/rust-lang/crates.io-index" 1070 | checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" 1071 | dependencies = [ 1072 | "heck", 1073 | "proc-macro2", 1074 | "quote", 1075 | "rustversion", 1076 | "syn", 1077 | ] 1078 | 1079 | [[package]] 1080 | name = "strum_macros" 1081 | version = "0.27.1" 1082 | source = "registry+https://github.com/rust-lang/crates.io-index" 1083 | checksum = "c77a8c5abcaf0f9ce05d62342b7d298c346515365c36b673df4ebe3ced01fde8" 1084 | dependencies = [ 1085 | "heck", 1086 | "proc-macro2", 1087 | "quote", 1088 | "rustversion", 1089 | "syn", 1090 | ] 1091 | 1092 | [[package]] 1093 | name = "syn" 1094 | version = "2.0.100" 1095 | source = "registry+https://github.com/rust-lang/crates.io-index" 1096 | checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" 1097 | dependencies = [ 1098 | "proc-macro2", 1099 | "quote", 1100 | "unicode-ident", 1101 | ] 1102 | 1103 | [[package]] 1104 | name = "termcolor" 1105 | version = "1.4.1" 1106 | source = "registry+https://github.com/rust-lang/crates.io-index" 1107 | checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" 1108 | dependencies = [ 1109 | "winapi-util", 1110 | ] 1111 | 1112 | [[package]] 1113 | name = "toml" 1114 | version = "0.8.20" 1115 | source = "registry+https://github.com/rust-lang/crates.io-index" 1116 | checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" 1117 | dependencies = [ 1118 | "serde", 1119 | "serde_spanned", 1120 | "toml_datetime", 1121 | "toml_edit", 1122 | ] 1123 | 1124 | [[package]] 1125 | name = "toml_datetime" 1126 | version = "0.6.8" 1127 | source = "registry+https://github.com/rust-lang/crates.io-index" 1128 | checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" 1129 | dependencies = [ 1130 | "serde", 1131 | ] 1132 | 1133 | [[package]] 1134 | name = "toml_edit" 1135 | version = "0.22.24" 1136 | source = "registry+https://github.com/rust-lang/crates.io-index" 1137 | checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" 1138 | dependencies = [ 1139 | "indexmap", 1140 | "serde", 1141 | "serde_spanned", 1142 | "toml_datetime", 1143 | "winnow", 1144 | ] 1145 | 1146 | [[package]] 1147 | name = "ufmt-write" 1148 | version = "0.1.0" 1149 | source = "registry+https://github.com/rust-lang/crates.io-index" 1150 | checksum = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69" 1151 | 1152 | [[package]] 1153 | name = "unicode-ident" 1154 | version = "1.0.18" 1155 | source = "registry+https://github.com/rust-lang/crates.io-index" 1156 | checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" 1157 | 1158 | [[package]] 1159 | name = "vcell" 1160 | version = "0.1.3" 1161 | source = "registry+https://github.com/rust-lang/crates.io-index" 1162 | checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" 1163 | 1164 | [[package]] 1165 | name = "void" 1166 | version = "1.0.2" 1167 | source = "registry+https://github.com/rust-lang/crates.io-index" 1168 | checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" 1169 | 1170 | [[package]] 1171 | name = "winapi-util" 1172 | version = "0.1.9" 1173 | source = "registry+https://github.com/rust-lang/crates.io-index" 1174 | checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" 1175 | dependencies = [ 1176 | "windows-sys", 1177 | ] 1178 | 1179 | [[package]] 1180 | name = "windows-sys" 1181 | version = "0.59.0" 1182 | source = "registry+https://github.com/rust-lang/crates.io-index" 1183 | checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" 1184 | dependencies = [ 1185 | "windows-targets", 1186 | ] 1187 | 1188 | [[package]] 1189 | name = "windows-targets" 1190 | version = "0.52.6" 1191 | source = "registry+https://github.com/rust-lang/crates.io-index" 1192 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 1193 | dependencies = [ 1194 | "windows_aarch64_gnullvm", 1195 | "windows_aarch64_msvc", 1196 | "windows_i686_gnu", 1197 | "windows_i686_gnullvm", 1198 | "windows_i686_msvc", 1199 | "windows_x86_64_gnu", 1200 | "windows_x86_64_gnullvm", 1201 | "windows_x86_64_msvc", 1202 | ] 1203 | 1204 | [[package]] 1205 | name = "windows_aarch64_gnullvm" 1206 | version = "0.52.6" 1207 | source = "registry+https://github.com/rust-lang/crates.io-index" 1208 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 1209 | 1210 | [[package]] 1211 | name = "windows_aarch64_msvc" 1212 | version = "0.52.6" 1213 | source = "registry+https://github.com/rust-lang/crates.io-index" 1214 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 1215 | 1216 | [[package]] 1217 | name = "windows_i686_gnu" 1218 | version = "0.52.6" 1219 | source = "registry+https://github.com/rust-lang/crates.io-index" 1220 | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 1221 | 1222 | [[package]] 1223 | name = "windows_i686_gnullvm" 1224 | version = "0.52.6" 1225 | source = "registry+https://github.com/rust-lang/crates.io-index" 1226 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 1227 | 1228 | [[package]] 1229 | name = "windows_i686_msvc" 1230 | version = "0.52.6" 1231 | source = "registry+https://github.com/rust-lang/crates.io-index" 1232 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 1233 | 1234 | [[package]] 1235 | name = "windows_x86_64_gnu" 1236 | version = "0.52.6" 1237 | source = "registry+https://github.com/rust-lang/crates.io-index" 1238 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 1239 | 1240 | [[package]] 1241 | name = "windows_x86_64_gnullvm" 1242 | version = "0.52.6" 1243 | source = "registry+https://github.com/rust-lang/crates.io-index" 1244 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 1245 | 1246 | [[package]] 1247 | name = "windows_x86_64_msvc" 1248 | version = "0.52.6" 1249 | source = "registry+https://github.com/rust-lang/crates.io-index" 1250 | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 1251 | 1252 | [[package]] 1253 | name = "winnow" 1254 | version = "0.7.4" 1255 | source = "registry+https://github.com/rust-lang/crates.io-index" 1256 | checksum = "0e97b544156e9bebe1a0ffbc03484fc1ffe3100cbce3ffb17eac35f7cdd7ab36" 1257 | dependencies = [ 1258 | "memchr", 1259 | ] 1260 | 1261 | [[package]] 1262 | name = "xtensa-lx" 1263 | version = "0.10.0" 1264 | source = "registry+https://github.com/rust-lang/crates.io-index" 1265 | checksum = "51cbb46c78cfd284c9378070ab90bae9d14d38b3766cb853a97c0a137f736d5b" 1266 | dependencies = [ 1267 | "critical-section", 1268 | "document-features", 1269 | ] 1270 | 1271 | [[package]] 1272 | name = "xtensa-lx-rt" 1273 | version = "0.18.0" 1274 | source = "registry+https://github.com/rust-lang/crates.io-index" 1275 | checksum = "689c2ef159d9cd4fc9503603e9999968a84a30db9bde0f0f880d0cceea0190a9" 1276 | dependencies = [ 1277 | "anyhow", 1278 | "document-features", 1279 | "enum-as-inner", 1280 | "minijinja", 1281 | "r0", 1282 | "serde", 1283 | "strum 0.26.3", 1284 | "toml", 1285 | "xtensa-lx", 1286 | "xtensa-lx-rt-proc-macros", 1287 | ] 1288 | 1289 | [[package]] 1290 | name = "xtensa-lx-rt-proc-macros" 1291 | version = "0.2.2" 1292 | source = "registry+https://github.com/rust-lang/crates.io-index" 1293 | checksum = "11277b1e4cbb7ffe44678c668518b249c843c81df249b8f096701757bc50d7ee" 1294 | dependencies = [ 1295 | "darling", 1296 | "proc-macro2", 1297 | "quote", 1298 | "syn", 1299 | ] 1300 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "esp32c3_no_std_async_mqtt_demo" 3 | version = "0.1.0" 4 | authors = ["Juraj Sadel "] 5 | edition = "2021" 6 | license = "MIT OR Apache-2.0" 7 | 8 | [dependencies] 9 | esp-hal = { version = "1.0.0-beta.0", features = ["esp32c3", "unstable"] } 10 | esp-wifi = { version = "0.13.0", features = [ 11 | "esp32c3", 12 | "wifi", 13 | "esp-alloc", 14 | "log", 15 | ] } 16 | esp-alloc = { version = "0.7.0" } 17 | log = "0.4.22" 18 | heapless = "0.8.0" 19 | esp-backtrace = { version = "0.15.1", features = [ 20 | "esp32c3", 21 | "exception-handler", 22 | "panic-handler", 23 | "println", 24 | ] } 25 | esp-hal-embassy = { version = "0.7.0", features = ["esp32c3"] } 26 | esp-println = { version = "0.13.1", features = ["esp32c3", "log"] } 27 | embassy-net = { version = "0.6.0", features = [ 28 | "tcp", 29 | "udp", 30 | "dhcpv4", 31 | "medium-ethernet", 32 | "proto-ipv6", 33 | "log", 34 | "dns", 35 | ] } 36 | embassy-executor = { version = "0.7.0", features = ["task-arena-size-20480"] } 37 | embassy-time = "0.4.0" 38 | embedded-hal-async = { version = "1.0.0" } 39 | static_cell = { version = "2.0", features = ["nightly"] } 40 | rust-mqtt = { version = "0.3.0", default-features = false } 41 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright [year] [fullname] 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # esp32c3-no-std-async-mqtt-demo 2 | 3 | This is a simple demo that we will use on the upcoming Espressif DevCon23. 4 | 5 | ESP32 variant: https://github.com/JurajSadel/esp32-no-std-async-mqtt-demo 6 | 7 | ESP32S3 variant: https://github.com/JurajSadel/esp32s3-no-std-async-mqtt-demo 8 | 9 | ## What it does 10 | The application measures temperature (`BMP180`) and sends the results to `MQTT` via WiFi - everything is done asynchronously. 11 | 12 | It's `async no_std` application that uses [esp-hal](https://crates.io/crates/esp32c3-hal), [esp-wifi](https://github.com/esp-rs/esp-wifi/tree/main), and [rust-mqtt](https://crates.io/crates/rust-mqtt) crates. The main skeleton is made of [embassy_dhcp](https://github.com/esp-rs/esp-wifi/blob/68dc11bbb2c0efa29c4acbbf134d6f142441065e/examples-esp32c3/examples/embassy_dhcp.rs) and [no_std_temperature_logger](https://github.com/bjoernQ/esp32-rust-nostd-temperature-logger) with a bunch of changes. 13 | 14 | The first change is `MQTT` part added. We are using `MQTTv5`. As a broker, we use[public-mqtt-broker](https://www.hivemq.com/public-mqtt-broker/) and [websocket-client](https://www.hivemq.com/demos/websocket-client/) to see the results. 15 | 16 | As a next change, we had to make [bmp180.rs](https://github.com/bjoernQ/esp32-rust-nostd-temperature-logger/blob/main/src/bmp180.rs) `async`. 17 | 18 | ## Build and run 19 | You have to set the `SSID` and `PASSWORD` environment variables before building/running the program 20 | 21 | `cargo run --release` 22 | 23 | > **_WARN:_** Be sure you are using `release` mode! 24 | ## License 25 | 26 | Licensed under either of: 27 | 28 | - Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) 29 | - MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) 30 | 31 | at your option. 32 | 33 | ### Contribution 34 | 35 | Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in 36 | the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without 37 | any additional terms or conditions. 38 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "nightly" 3 | components = ["rust-src"] 4 | targets = ["riscv32imc-unknown-none-elf"] 5 | 6 | -------------------------------------------------------------------------------- /src/bmp180_async.rs: -------------------------------------------------------------------------------- 1 | use core::future::Future; 2 | 3 | const ADDRESS: u8 = 0x77; 4 | 5 | use embedded_hal_async::i2c::I2c; 6 | 7 | #[allow(dead_code)] 8 | pub struct Bmp180 9 | where 10 | T: I2c, 11 | F: Fn(u32) -> R, 12 | R: Future, 13 | { 14 | i2c: T, 15 | ac1: i32, 16 | ac2: i32, 17 | ac3: i32, 18 | ac4: i32, 19 | ac5: i32, 20 | ac6: i32, 21 | b1: i32, 22 | b2: i32, 23 | mb: i32, 24 | mc: i32, 25 | md: i32, 26 | 27 | temp: f32, 28 | sleep_fn: F, 29 | } 30 | 31 | impl Bmp180 32 | where 33 | T: I2c, 34 | F: Fn(u32) -> R, 35 | R: Future, 36 | { 37 | pub async fn new(i2c: T, sleep_fn: F) -> Bmp180 where { 38 | let mut i2c = i2c; 39 | let mut data = [0u8; 22]; 40 | 41 | i2c.write_read(ADDRESS, &[0xaa], &mut data).await.unwrap(); 42 | 43 | let ac1 = ((data[0] as u16) << 8 | data[1] as u16) as i16 as i32; 44 | let ac2 = ((data[2] as u16) << 8 | data[3] as u16) as i16 as i32; 45 | let ac3 = ((data[4] as u16) << 8 | data[5] as u16) as i16 as i32; 46 | let ac4 = ((data[6] as u16) << 8 | data[7] as u16) as i16 as i32; 47 | let ac5 = ((data[8] as u16) << 8 | data[8] as u16) as i16 as i32; 48 | let ac6 = ((data[10] as u16) << 8 | data[11] as u16) as i16 as i32; 49 | let b1 = ((data[12] as u16) << 8 | data[13] as u16) as i16 as i32; 50 | let b2 = ((data[14] as u16) << 8 | data[15] as u16) as i16 as i32; 51 | let mb = ((data[16] as u16) << 8 | data[17] as u16) as i16 as i32; 52 | let mc = ((data[18] as u16) << 8 | data[19] as u16) as i16 as i32; 53 | let md = ((data[20] as u16) << 8 | data[21] as u16) as i16 as i32; 54 | 55 | Self { 56 | i2c, 57 | ac1, 58 | ac2, 59 | ac3, 60 | ac4, 61 | ac5, 62 | ac6, 63 | b1, 64 | b2, 65 | mb, 66 | mc, 67 | md, 68 | 69 | temp: 0f32, 70 | sleep_fn, 71 | } 72 | } 73 | 74 | pub async fn measure(&mut self) { 75 | // Select measurement control register 76 | // Enable temperature measurement 77 | self.i2c.write(ADDRESS, &[0xf4, 0x2e]).await.unwrap(); 78 | (self.sleep_fn)(100).await; 79 | 80 | // Read 2 bytes of data from address 0xF6(246) 81 | // temp msb, temp lsb 82 | let mut data = [0u8; 2]; 83 | self.i2c 84 | .write_read(ADDRESS, &[0xF6], &mut data) 85 | .await 86 | .unwrap(); 87 | 88 | // Convert the data 89 | let temp = (data[0] as u32) << 8 | data[1] as u32; 90 | 91 | // Calibration for Temperature 92 | let x1: f64 = (temp as f64 - self.ac6 as f64) * self.ac5 as f64 / 32768.0; 93 | let x2: f64 = (self.mc as f64 * 2048.0) / (x1 + self.md as f64); 94 | let b5: f64 = x1 + x2; 95 | let c_temp: f64 = ((b5 + 8.0) / 16.0) / 10.0; 96 | 97 | self.temp = c_temp as f32; 98 | } 99 | 100 | pub fn get_temperature(&self) -> f32 { 101 | self.temp 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | #![no_main] 3 | 4 | // peripherals-related imports 5 | use esp_alloc as _; 6 | use esp_hal::{ 7 | clock::CpuClock, 8 | i2c::master::{Config, I2c}, 9 | rng::Rng, 10 | timer::timg::TimerGroup, 11 | }; 12 | 13 | use esp_wifi::{ 14 | init, 15 | wifi::{ClientConfiguration, Configuration, WifiController, WifiDevice, WifiEvent, WifiState}, 16 | EspWifiController, 17 | }; 18 | 19 | // embassy related imports 20 | use embassy_executor::Spawner; 21 | use embassy_net::{ 22 | tcp::TcpSocket, 23 | Runner, 24 | {dns::DnsQueryType, Config as EmbassyNetConfig, StackResources}, 25 | }; 26 | use embassy_time::{Duration, Timer}; 27 | 28 | // Temperature sensor related imports 29 | use crate::bmp180_async::Bmp180; 30 | mod bmp180_async; 31 | 32 | // MQTT related imports 33 | use rust_mqtt::{ 34 | client::{client::MqttClient, client_config::ClientConfig}, 35 | packet::v5::reason_codes::ReasonCode, 36 | utils::rng_generator::CountingRng, 37 | }; 38 | 39 | // Formatting related imports 40 | use core::fmt::Write; 41 | use heapless::String; 42 | 43 | use esp_backtrace as _; 44 | use log::{debug, error, info}; 45 | 46 | const SSID: &str = env!("SSID"); 47 | const PASSWORD: &str = env!("PASSWORD"); 48 | 49 | macro_rules! mk_static { 50 | ($t:ty,$val:expr) => {{ 51 | static STATIC_CELL: static_cell::StaticCell<$t> = static_cell::StaticCell::new(); 52 | #[deny(unused_attributes)] 53 | let x = STATIC_CELL.uninit().write(($val)); 54 | x 55 | }}; 56 | } 57 | 58 | // maintains wifi connection, when it disconnects it tries to reconnect 59 | #[embassy_executor::task] 60 | async fn connection(mut controller: WifiController<'static>) { 61 | info!("start connection task"); 62 | debug!("Device capabilities: {:?}", controller.capabilities()); 63 | loop { 64 | match esp_wifi::wifi::wifi_state() { 65 | WifiState::StaConnected => { 66 | // wait until we're no longer connected 67 | controller.wait_for_event(WifiEvent::StaDisconnected).await; 68 | Timer::after(Duration::from_millis(5000)).await 69 | } 70 | _ => {} 71 | } 72 | if !matches!(controller.is_started(), Ok(true)) { 73 | let client_config = Configuration::Client(ClientConfiguration { 74 | ssid: SSID.try_into().unwrap(), 75 | password: PASSWORD.try_into().unwrap(), 76 | ..Default::default() 77 | }); 78 | controller.set_configuration(&client_config).unwrap(); 79 | info!("Starting wifi"); 80 | controller.start_async().await.unwrap(); 81 | info!("Wifi started!"); 82 | } 83 | info!("About to connect..."); 84 | 85 | match controller.connect_async().await { 86 | Ok(_) => info!("Wifi connected!"), 87 | Err(e) => { 88 | error!("Failed to connect to wifi: {e:?}"); 89 | Timer::after(Duration::from_millis(5000)).await 90 | } 91 | } 92 | } 93 | } 94 | 95 | // A background task, to process network events - when new packets, they need to processed, embassy-net, wraps smoltcp 96 | #[embassy_executor::task] 97 | async fn net_task(mut runner: Runner<'static, WifiDevice<'static>>) { 98 | runner.run().await 99 | } 100 | 101 | #[esp_hal_embassy::main] 102 | async fn main(spawner: Spawner) -> ! { 103 | esp_println::logger::init_logger_from_env(); 104 | let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max()); 105 | let peripherals = esp_hal::init(config); 106 | 107 | esp_alloc::heap_allocator!(size: 72 * 1024); 108 | 109 | let timg0 = TimerGroup::new(peripherals.TIMG0); 110 | let mut rng = Rng::new(peripherals.RNG); 111 | 112 | let esp_wifi_ctrl = &*mk_static!( 113 | EspWifiController<'static>, 114 | init(timg0.timer0, rng.clone(), peripherals.RADIO_CLK).unwrap() 115 | ); 116 | 117 | let (controller, interfaces) = esp_wifi::wifi::new(&esp_wifi_ctrl, peripherals.WIFI).unwrap(); 118 | let wifi_interface = interfaces.sta; 119 | 120 | // Create a new peripheral object with the described wiring 121 | // and standard I2C clock speed 122 | let i2c0 = I2c::new(peripherals.I2C0, Config::default()) 123 | .unwrap() 124 | .with_sda(peripherals.GPIO1) 125 | .with_scl(peripherals.GPIO2) 126 | .into_async(); 127 | 128 | let timg1 = TimerGroup::new(peripherals.TIMG1); 129 | esp_hal_embassy::init(timg1.timer0); 130 | 131 | let config = EmbassyNetConfig::dhcpv4(Default::default()); 132 | 133 | let seed = (rng.random() as u64) << 32 | rng.random() as u64; 134 | 135 | // Init network stack 136 | let (stack, runner) = embassy_net::new( 137 | wifi_interface, 138 | config, 139 | mk_static!(StackResources<3>, StackResources::<3>::new()), 140 | seed, 141 | ); 142 | 143 | spawner.spawn(connection(controller)).ok(); 144 | spawner.spawn(net_task(runner)).ok(); 145 | 146 | let mut rx_buffer = [0; 4096]; 147 | let mut tx_buffer = [0; 4096]; 148 | 149 | //wait until wifi connected 150 | loop { 151 | if stack.is_link_up() { 152 | break; 153 | } 154 | Timer::after(Duration::from_millis(500)).await; 155 | } 156 | 157 | info!("Waiting to get IP address..."); 158 | loop { 159 | if let Some(config) = stack.config_v4() { 160 | info!("Got IP: {}", config.address); //dhcp IP address 161 | break; 162 | } 163 | Timer::after(Duration::from_millis(500)).await; 164 | } 165 | 166 | loop { 167 | Timer::after(Duration::from_millis(1_000)).await; 168 | 169 | let mut socket = TcpSocket::new(stack, &mut rx_buffer, &mut tx_buffer); 170 | 171 | socket.set_timeout(Some(embassy_time::Duration::from_secs(10))); 172 | 173 | let address = match stack 174 | .dns_query("broker.hivemq.com", DnsQueryType::A) 175 | .await 176 | .map(|a| a[0]) 177 | { 178 | Ok(address) => address, 179 | Err(e) => { 180 | error!("DNS lookup error: {e:?}"); 181 | continue; 182 | } 183 | }; 184 | 185 | let remote_endpoint = (address, 1883); 186 | info!("connecting..."); 187 | let connection = socket.connect(remote_endpoint).await; 188 | if let Err(e) = connection { 189 | error!("connect error: {:?}", e); 190 | continue; 191 | } 192 | info!("connected!"); 193 | 194 | let mut config = ClientConfig::new( 195 | rust_mqtt::client::client_config::MqttVersion::MQTTv5, 196 | CountingRng(20000), 197 | ); 198 | config.add_max_subscribe_qos(rust_mqtt::packet::v5::publish_packet::QualityOfService::QoS1); 199 | config.add_client_id("clientId-8rhWgBODCl"); 200 | config.max_packet_size = 100; 201 | let mut recv_buffer = [0; 80]; 202 | let mut write_buffer = [0; 80]; 203 | 204 | let mut client = 205 | MqttClient::<_, 5, _>::new(socket, &mut write_buffer, 80, &mut recv_buffer, 80, config); 206 | 207 | match client.connect_to_broker().await { 208 | Ok(()) => {} 209 | Err(mqtt_error) => match mqtt_error { 210 | ReasonCode::NetworkError => { 211 | error!("MQTT Network Error"); 212 | continue; 213 | } 214 | _ => { 215 | error!("Other MQTT Error: {:?}", mqtt_error); 216 | continue; 217 | } 218 | }, 219 | } 220 | 221 | let mut bmp = Bmp180::new(i2c0, sleep).await; 222 | loop { 223 | bmp.measure().await; 224 | let temperature = bmp.get_temperature(); 225 | info!("Current temperature: {}", temperature); 226 | 227 | // Convert temperature into String 228 | let mut temperature_string: String<32> = String::new(); 229 | write!(temperature_string, "{:.2}", temperature).expect("write! failed!"); 230 | 231 | match client 232 | .send_message( 233 | "temperature/1", 234 | temperature_string.as_bytes(), 235 | rust_mqtt::packet::v5::publish_packet::QualityOfService::QoS1, 236 | true, 237 | ) 238 | .await 239 | { 240 | Ok(()) => {} 241 | Err(mqtt_error) => match mqtt_error { 242 | ReasonCode::NetworkError => { 243 | error!("MQTT Network Error"); 244 | continue; 245 | } 246 | _ => { 247 | error!("Other MQTT Error: {:?}", mqtt_error); 248 | continue; 249 | } 250 | }, 251 | } 252 | Timer::after(Duration::from_millis(3000)).await; 253 | } 254 | } 255 | } 256 | 257 | pub async fn sleep(millis: u32) { 258 | Timer::after(Duration::from_millis(millis as u64)).await; 259 | } 260 | --------------------------------------------------------------------------------