From 7c1bc0e1ba54c292477f68e735cfac6effe8dcd7 Mon Sep 17 00:00:00 2001 From: Christian M Date: Fri, 13 Oct 2023 17:36:29 +0200 Subject: [PATCH] :sparkles::recycle: disable webcam --- Cargo.lock | 195 ++++++++++++++++++----------------- Cargo.toml | 4 +- build.rs | 19 ++-- docs/RaspberryPi.md | 2 +- examples/bt_rfcomm_client.rs | 2 + examples/raspicam.rs | 7 ++ examples/webcam.rs | 10 +- src/bluetooth/mod.rs | 9 +- src/capture/mod.rs | 2 + src/lib.rs | 8 +- src/main.rs | 6 +- 11 files changed, 148 insertions(+), 116 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f7717b1..61d5b35 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -47,9 +47,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -141,7 +141,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -155,9 +155,12 @@ dependencies = [ [[package]] name = "atomic" -version = "0.5.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" +checksum = "8d818003e740b63afc82337e3160717f4f63078720a810b7b903e70a5d1d2994" +dependencies = [ + "bytemuck", +] [[package]] name = "atty" @@ -362,9 +365,9 @@ checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" @@ -390,8 +393,8 @@ dependencies = [ [[package]] name = "candle-core" -version = "0.2.3" -source = "git+https://github.com/huggingface/candle#29bd6b297990141cfa31d5225b8a29683e71c282" +version = "0.3.0" +source = "git+https://github.com/huggingface/candle#7473c4cecaeb4cde39452c0b3442a3f6105c53d7" dependencies = [ "byteorder", "candle-gemm", @@ -535,8 +538,8 @@ dependencies = [ [[package]] name = "candle-nn" -version = "0.2.3" -source = "git+https://github.com/huggingface/candle#29bd6b297990141cfa31d5225b8a29683e71c282" +version = "0.3.0" +source = "git+https://github.com/huggingface/candle#7473c4cecaeb4cde39452c0b3442a3f6105c53d7" dependencies = [ "candle-core", "half 2.3.1", @@ -1099,7 +1102,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -1117,7 +1120,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" dependencies = [ - "libloading 0.8.0", + "libloading 0.8.1", ] [[package]] @@ -1146,9 +1149,9 @@ checksum = "23d2f3407d9a573d666de4b5bdf10569d73ca9478087346697dcbae6244bfbcd" [[package]] name = "dyn-stack" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24269739c7c175bc12130622ef1a60b9ab2d5b30c0b9ce5110cd406d7fd497bc" +checksum = "7fe7f8d7bcc523381d3c437b82cf74805de3931de0da69309ae0fe1bdf7a256e" dependencies = [ "bytemuck", "reborrow", @@ -1174,15 +1177,15 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "enum-ordinalize" -version = "3.1.13" +version = "3.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4f76552f53cefc9a7f64987c3701b99d982f7690606fd67de1d09712fbf52f1" +checksum = "1bf1fa3f06bbff1ea5b1a9c7b14aa992a39657db60a2759457328d7e058f49ee" dependencies = [ "num-bigint", "num-traits", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -1219,25 +1222,14 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" +checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" dependencies = [ - "errno-dragonfly", "libc", "windows-sys", ] -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "fastrand" version = "2.0.1" @@ -1255,14 +1247,14 @@ dependencies = [ [[package]] name = "figment" -version = "0.10.10" +version = "0.10.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4547e226f4c9ab860571e070a9034192b3175580ecea38da34fcdb53a018c9a5" +checksum = "a014ac935975a70ad13a3bff2463b1c1b083b35ae4cb6309cfc59476aa7a181f" dependencies = [ "atomic", "pear", "serde", - "toml 0.7.8", + "toml 0.8.2", "uncased", "version_check", ] @@ -1422,7 +1414,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -1555,7 +1547,7 @@ checksum = "cc11df1ace8e7e564511f53af41f3e42ddc95b56fd07b3f4445d2a6048bc682c" dependencies = [ "bitflags 2.4.0", "gpu-descriptor-types", - "hashbrown 0.14.0", + "hashbrown 0.14.1", ] [[package]] @@ -1603,9 +1595,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" dependencies = [ "ahash 0.8.3", "allocator-api2", @@ -1820,12 +1812,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown 0.14.1", ] [[package]] @@ -1895,9 +1887,9 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "jobserver" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" dependencies = [ "libc", ] @@ -2022,9 +2014,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.148" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "libdbus-sys" @@ -2057,9 +2049,9 @@ dependencies = [ [[package]] name = "libloading" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d580318f95776505201b28cf98eb1fa5e4be3b689633ba6a3e6cd880ff22d8cb" +checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" dependencies = [ "cfg-if 1.0.0", "windows-sys", @@ -2067,9 +2059,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "linked-hash-map" @@ -2079,9 +2071,9 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.4.7" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" +checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" [[package]] name = "liquid" @@ -2122,7 +2114,7 @@ checksum = "fc2fb41a9bb4257a3803154bdf7e2df7d45197d1941c9b1a90ad815231630721" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -2189,9 +2181,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "memmap2" @@ -2715,9 +2707,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", "libm", @@ -2916,7 +2908,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -2962,7 +2954,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -2983,7 +2975,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.0.0", + "indexmap 2.0.2", ] [[package]] @@ -3003,7 +2995,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -3166,7 +3158,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.15", ] [[package]] @@ -3201,9 +3193,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.67" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] @@ -3216,7 +3208,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", "version_check", "yansi", ] @@ -3411,9 +3403,9 @@ dependencies = [ [[package]] name = "reborrow" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2962bf2e1f971c53ef59b2d7ca51d6a5e5c4a9d2be47eb1f661a321a4da85888" +checksum = "03251193000f4bd3b042892be858ee50e8b3719f2b08e5833ac4353724632430" [[package]] name = "redox_syscall" @@ -3435,9 +3427,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.5" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" +checksum = "d119d7c7ca818f8a53c300863d4f87566aac09943aef5b355bb83969dae75d87" dependencies = [ "aho-corasick", "memchr", @@ -3447,9 +3439,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.8" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" +checksum = "465c6fc0621e4abc4187a2bda0937bfd4f722c2730b29562e19689ea796c9a4b" dependencies = [ "aho-corasick", "memchr", @@ -3458,9 +3450,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.5" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +checksum = "56d84fdd47036b038fc80dd333d10b6aab10d5d31f4a366e20014def75328d33" [[package]] name = "renderdoc-sys" @@ -3537,9 +3529,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.14" +version = "0.38.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "747c788e9ce8e92b12cd485c49ddf90723550b654b32508f979b71a7b1ecda4f" +checksum = "745ecfa778e66b2b63c88a61cb36e0eea109e803b0b86bf9879fbc77c70e86ed" dependencies = [ "bitflags 2.4.0", "errno", @@ -3621,9 +3613,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "seq-macro" @@ -3658,7 +3650,7 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -3974,9 +3966,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -4009,7 +4001,7 @@ checksum = "285ba80e733fac80aa4270fbcdf83772a79b80aa35c97075320abfee4a915b06" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", "unicode-xid", ] @@ -4078,7 +4070,7 @@ checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -4126,9 +4118,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.32.0" +version = "1.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" +checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" dependencies = [ "backtrace", "bytes 1.5.0", @@ -4151,7 +4143,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -4207,14 +4199,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.8" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" +checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit", + "toml_edit 0.20.2", ] [[package]] @@ -4232,7 +4224,18 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.0.2", + "toml_datetime", + "winnow", +] + +[[package]] +name = "toml_edit" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +dependencies = [ + "indexmap 2.0.2", "serde", "serde_spanned", "toml_datetime", @@ -4620,7 +4623,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", "wasm-bindgen-shared", ] @@ -4654,7 +4657,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4849,9 +4852,9 @@ dependencies = [ [[package]] name = "wide" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa469ffa65ef7e0ba0f164183697b89b854253fd31aeb92358b7b6155177d62f" +checksum = "ebecebefc38ff1860b4bc47550bbfa63af5746061cf0d29fcd7fa63171602598" dependencies = [ "bytemuck", "safe_arch", @@ -5062,9 +5065,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.5.15" +version = "0.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" +checksum = "037711d82167854aff2018dfd193aa0fef5370f456732f0d5a0c59b0f1b4b907" dependencies = [ "memchr", ] @@ -5145,7 +5148,7 @@ checksum = "d5e19fb6ed40002bab5403ffa37e53e0e56f914a4450c8765f533018db1db35f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", "synstructure 0.13.0", ] @@ -5166,7 +5169,7 @@ checksum = "e6a647510471d372f2e6c2e6b7219e44d8c574d24fdc11c610a61455782f18c3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", "synstructure 0.13.0", ] diff --git a/Cargo.toml b/Cargo.toml index 3745751..e066254 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ build = "build.rs" default = ["server", "camera", "yolo"] full = ["bluetooth", "camera", "detect", "hotspot", "server"] pi = ["bluetooth", "camera", "detect", "server"] -bluetooth = ["bluer"] +bluetooth = ["base64", "bluer"] camera = ["nokhwa/input-native"] hotspot = ["wifi-rs"] server = ["axum", "base64", "tower", "tower-http"] @@ -49,7 +49,7 @@ lenna_birds_plugin = { git = "https://github.com/lenna-project/birds-plugin", br lenna_yolo_plugin = { git = "https://github.com/lenna-project/yolo-plugin", branch = "main", default-features = false, optional = true } log = "0.4" mime = "0.3.17" -nokhwa = { version = "0.10.4", features = ["output-threaded"] } +nokhwa = { version = "0.10.4", features = ["output-threaded"], optional = true} rand = "0.8" serde = { version = "1.0", features = ["derive"] } diff --git a/build.rs b/build.rs index 1ed3baf..e1536d3 100644 --- a/build.rs +++ b/build.rs @@ -5,18 +5,17 @@ use std::path::Path; use std::process::Command; fn main() { - #[cfg(feature = "server")] - { - let app_dir = format!("{}/app", env::var("CARGO_MANIFEST_DIR").unwrap()); + let app_dir = format!("{}/app", env::var("CARGO_MANIFEST_DIR").unwrap()); - Command::new("trunk") - .args(&["build --release"]) - .current_dir(&Path::new(&app_dir)) - .status() - .unwrap(); + let status = Command::new("trunk") + .args(&["build", "--release"]) + .current_dir(&Path::new(&app_dir)) + .status(); - println!("building {}", app_dir); + match status { + Ok(status) if status.success() => println!("Successfully built {}", app_dir), + Ok(status) => eprintln!("Failed to build {}: exit code {}", app_dir, status), + Err(err) => eprintln!("Failed to run trunk command: {}", err), } - println!("cargo:rerun-if-changed=build.rs"); } diff --git a/docs/RaspberryPi.md b/docs/RaspberryPi.md index 679af90..3cc40ac 100644 --- a/docs/RaspberryPi.md +++ b/docs/RaspberryPi.md @@ -157,7 +157,7 @@ If you have a monitor and keyboard connected to your Raspberry Pi, you can find 3. Install prerequisites: ```sh sudo apt install git build-essential clang -sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev v4l-utils libssl-dev +sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev v4l-utils libssl-dev libdbus-1-dev curl https://sh.rustup.rs -sSf | sh cargo install --locked trunk cargo install --locked wasm-bindgen-cli diff --git a/examples/bt_rfcomm_client.rs b/examples/bt_rfcomm_client.rs index ed0161a..2246bf7 100644 --- a/examples/bt_rfcomm_client.rs +++ b/examples/bt_rfcomm_client.rs @@ -89,5 +89,7 @@ async fn main() { let target_address: Address = "B8:27:EB:4C:40:D5".parse().expect("invalid address"); let target_address: Address = "00:15:83:0C:BF:EB".parse().expect("invalid address"); + let target_address: Address = "DC:A6:32:84:72:93".parse().expect("invalid address"); + perform(target_address, CHANNEL).await.unwrap(); } diff --git a/examples/raspicam.rs b/examples/raspicam.rs index 73886ca..209c769 100644 --- a/examples/raspicam.rs +++ b/examples/raspicam.rs @@ -1,9 +1,11 @@ +#[cfg(feature = "webcam")] use nokhwa::{ pixel_format::RgbFormat, utils::{CameraFormat, CameraIndex, FrameFormat, RequestedFormat, RequestedFormatType}, Camera, }; +#[cfg(feature = "webcam")] fn main() { let index = CameraIndex::Index(0); // request the absolute highest resolution CameraFormat that can be decoded to RGB. @@ -28,3 +30,8 @@ fn main() { println!("{}, {}", decoded.width(), decoded.height()); decoded.save("frame.jpg").unwrap(); } + +#[cfg(not(feature = "webcam"))] +fn main() { + println!("Webcam feature not enabled"); +} diff --git a/examples/webcam.rs b/examples/webcam.rs index caade5c..41dc80b 100644 --- a/examples/webcam.rs +++ b/examples/webcam.rs @@ -1,8 +1,14 @@ -use ornithology_pi::{Capture, WebCam}; +use ornithology_pi::Capture; +#[cfg(feature = "webcam")] fn main() { - let mut capture = WebCam::default(); + let mut capture = ornithology_pi::WebCam::default(); let frame = capture.frame().unwrap(); println!("{}, {}", frame.width(), frame.height()); frame.save("frame.jpg").unwrap(); } + +#[cfg(not(feature = "webcam"))] +fn main() { + println!("Webcam feature not enabled"); +} diff --git a/src/bluetooth/mod.rs b/src/bluetooth/mod.rs index b335bc8..478f6db 100644 --- a/src/bluetooth/mod.rs +++ b/src/bluetooth/mod.rs @@ -10,8 +10,7 @@ pub mod rfcomm_srv; pub const MANUFACTURER_ID: u16 = 0xf00d; -pub async fn run_bluetooth(sightings: Arc>>) -> bluer::Result<()> { - let session = bluer::Session::new().await?; +pub async fn setup_session(session: &bluer::Session) -> bluer::Result<()> { let adapter_names = session.adapter_names().await?; let adapter_name = adapter_names.first().expect("No Bluetooth adapter present"); let adapter = session.adapter(adapter_name)?; @@ -25,6 +24,12 @@ pub async fn run_bluetooth(sightings: Arc>>) -> bluer::Resul &adapter_name, adapter.address().await? ); + Ok(()) +} + +pub async fn run_bluetooth(sightings: Arc>>) -> bluer::Result<()> { + let mut session = bluer::Session::new().await?; + setup_session(&session).await?; /*let gatt_handle = gatt_srv::run_advertise(&adapter, sightings.clone()) .await .unwrap(); diff --git a/src/capture/mod.rs b/src/capture/mod.rs index ed49dfb..a8989d2 100644 --- a/src/capture/mod.rs +++ b/src/capture/mod.rs @@ -16,5 +16,7 @@ pub trait Capture: Stream { } } +#[cfg(feature = "webcam")] mod webcam; +#[cfg(feature = "webcam")] pub use webcam::WebCam; diff --git a/src/lib.rs b/src/lib.rs index a87336c..551539a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,11 +1,13 @@ // Publicly re-exporting types for external use. pub use self::{ - capture::{Capture, WebCam}, + capture::Capture, config::Config, - mjpeg::MJpeg, sighting::{DataSighting, Sighting}, }; +#[cfg(feature = "webcam")] +pub use self::{capture::WebCam, mjpeg::MJpeg}; + // Type aliases for convenience. pub type Error = Box; pub type Result = std::result::Result; @@ -15,6 +17,8 @@ pub mod capture; pub mod cli; pub mod config; pub mod logger; + +#[cfg(feature = "webcam")] pub mod mjpeg; pub mod sighting; diff --git a/src/main.rs b/src/main.rs index b8e4844..79821f7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,9 @@ use ornithology_pi::hotspot::Hotspot; use ornithology_pi::logger::init_logger; #[cfg(feature = "server")] use ornithology_pi::server::server; -use ornithology_pi::{Sighting, WebCam}; +use ornithology_pi::Sighting; +#[cfg(feature = "webcam")] +use ornithology_pi::WebCam; use std::sync::{Arc, Mutex}; #[tokio::main] @@ -25,6 +27,8 @@ async fn main() { let sightings: Arc>> = Arc::new(Mutex::new( ornithology_pi::sighting::load_from_file("sightings/sightings.db").unwrap_or_default(), )); + + #[cfg(feature = "webcam")] let capture: Arc> = Arc::new(Mutex::new( WebCam::new(config.camera.width, config.camera.height, config.camera.fps).unwrap(), ));