From 1e916806d4a81093a3cf65a9b4dc68a79ba0e7db Mon Sep 17 00:00:00 2001 From: Andrew Mackenzie Date: Wed, 7 Aug 2024 20:49:32 +0200 Subject: [PATCH 01/10] Use published machineid-rs --- wimon/Cargo.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wimon/Cargo.toml b/wimon/Cargo.toml index 99cb957..80b004d 100644 --- a/wimon/Cargo.toml +++ b/wimon/Cargo.toml @@ -19,7 +19,7 @@ ssids = ["wifiscanner"] data_model = { path = "../data_model" } # for creating a unique machine ID -machineid-rs = { version = "1.2.4", git = "https://github.com/andrewdavidmackenzie/machineid-rs", branch = "patch-1"} +machineid-rs = "1.2.4" # for reading config from a file serde_derive = "~1.0" @@ -29,13 +29,13 @@ toml = { version = "0.8.8" } url = "2.5" # for making network requests -curl = {version = "~0.4", default-features = false, features = ["rustls"]} +curl = { version = "~0.4", default-features = false, features = ["rustls"] } # for catching signals -ctrlc = {version = "3.4.1", features = ["termination"] } +ctrlc = { version = "3.4.1", features = ["termination"] } # for installing as a system service service-manager = "0.6.0" # for scanning wifi and getting SSIDs visible -wifiscanner = {version = "0.5.1", optional = true} \ No newline at end of file +wifiscanner = { version = "0.5.1", optional = true } \ No newline at end of file From 01612f9efeb7d0cac2395ee87b0ead87e6b2b528 Mon Sep 17 00:00:00 2001 From: Andrew Mackenzie Date: Wed, 7 Aug 2024 22:49:48 +0200 Subject: [PATCH 02/10] Update service-manager version and add autostart flag --- wimon/Cargo.toml | 2 +- wimon/src/main.rs | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/wimon/Cargo.toml b/wimon/Cargo.toml index 80b004d..4b96428 100644 --- a/wimon/Cargo.toml +++ b/wimon/Cargo.toml @@ -35,7 +35,7 @@ curl = { version = "~0.4", default-features = false, features = ["rustls"] } ctrlc = { version = "3.4.1", features = ["termination"] } # for installing as a system service -service-manager = "0.6.0" +service-manager = "0.7.1" # for scanning wifi and getting SSIDs visible wifiscanner = { version = "0.5.1", optional = true } \ No newline at end of file diff --git a/wimon/src/main.rs b/wimon/src/main.rs index c642e8d..139c8f8 100644 --- a/wimon/src/main.rs +++ b/wimon/src/main.rs @@ -1,12 +1,14 @@ -use config::MonitorSpec; +use std::{env, io}; +use std::path::PathBuf; +use std::sync::mpsc::channel; +use std::time::Duration; + use service_manager::{ ServiceInstallCtx, ServiceLabel, ServiceManager, ServiceStartCtx, ServiceStopCtx, ServiceUninstallCtx, }; -use std::path::PathBuf; -use std::sync::mpsc::channel; -use std::time::Duration; -use std::{env, io}; + +use config::MonitorSpec; mod monitor; @@ -47,7 +49,7 @@ fn run(config_file_path: &PathBuf) -> Result<(), io::Error> { println!("Control-C captured, sending Stop report"); tx.send(()).expect("Could not send signal on channel.") }) - .expect("Error setting Ctrl-C handler"); + .expect("Error setting Ctrl-C handler"); monitor::monitor_loop(config, rx)?; @@ -86,6 +88,7 @@ fn install_service(service_name: &ServiceLabel, path_to_exec: &str) -> Result<() username: None, // Optional String for alternative user to run service. working_directory: Some(exec_dir), environment: None, // Optional list of environment variables to supply the service process. + autostart: true, // autostart on reboot })?; // Start our service using the underlying service management platform @@ -128,10 +131,12 @@ fn uninstall_service(service_name: &ServiceLabel) -> Result<(), io::Error> { #[cfg(test)] mod test { - use super::CONFIG_FILE_NAME; - use config::{Config, MonitorSpec}; use std::path::PathBuf; + use config::{Config, MonitorSpec}; + + use super::CONFIG_FILE_NAME; + #[test] fn bundled_spec() { let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); From 901479d0b5cc498187c52569e1b9bd12429dca6d Mon Sep 17 00:00:00 2001 From: Andrew Mackenzie Date: Mon, 19 Aug 2024 10:34:35 +0200 Subject: [PATCH 03/10] Workaround issue https://github.com/cloudflare/workers-rs/issues/617 --- collectr/Cargo.toml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/collectr/Cargo.toml b/collectr/Cargo.toml index f3ac383..a545bcf 100644 --- a/collectr/Cargo.toml +++ b/collectr/Cargo.toml @@ -17,8 +17,11 @@ name = "worker" path = "src/worker.rs" [dependencies] -data_model = { path = "../data_model"} -worker = { version = "0.3.0", features = ["queue"]} +# To workaround issue: https://github.com/cloudflare/workers-rs/issues/617 +wasm-bindgen = "=0.2.92" + +data_model = { path = "../data_model" } +worker = { version = "0.3.3", features = ["queue"] } serde_derive = "~1.0" serde = "~1.0" serde_json = "1.0.107" \ No newline at end of file From aaf0b904eeb512717f42b6cc365173793faf363f Mon Sep 17 00:00:00 2001 From: Andrew Mackenzie Date: Mon, 19 Aug 2024 10:34:49 +0200 Subject: [PATCH 04/10] Small Makefile changes --- Makefile | 5 ++++- collectr/Makefile | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 4a47adb..968aec8 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,7 @@ -all: picomon collectr configr viewr wimon +all: build + +.PHONY: build +build: picomon collectr configr viewr wimon .PHONY: deploy deploy: diff --git a/collectr/Makefile b/collectr/Makefile index 2a54dd1..ce4b7cf 100644 --- a/collectr/Makefile +++ b/collectr/Makefile @@ -1,8 +1,11 @@ all: build -.PHONY: build -build: +.PHONY: clippy +clippy: cargo clippy + +.PHONY: build +build: clippy wrangler deploy --dry-run --outdir=dist local: From 1d4a46fe62be16fe343080f47e7579a5452fc5ec Mon Sep 17 00:00:00 2001 From: Andrew Mackenzie Date: Mon, 19 Aug 2024 11:56:03 +0200 Subject: [PATCH 05/10] Update leptos version --- viewr/Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/viewr/Cargo.toml b/viewr/Cargo.toml index 900f3c7..dbfe01f 100644 --- a/viewr/Cargo.toml +++ b/viewr/Cargo.toml @@ -14,8 +14,8 @@ path = "src/viewr.rs" [dependencies] data_model = { path = "../data_model" } console_error_panic_hook = "0.1.7" -leptos = { version = "0.6.9", features = ["csr"] } -leptos_router = { version = "0.6.9", features = ["csr"] } +leptos = { version = "0.6.14", features = ["csr"] } +leptos_router = { version = "0.6.14", features = ["csr"] } reqwasm = "0.5" serde = { version = "1", features = ["derive"] } -chrono = "0.4.34" \ No newline at end of file +chrono = "0.4.38" \ No newline at end of file From f66d78a23f14bf399e3f39b4bcd6b3572665ba6f Mon Sep 17 00:00:00 2001 From: Andrew Mackenzie Date: Mon, 19 Aug 2024 11:56:24 +0200 Subject: [PATCH 06/10] drying Makefile --- viewr/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/viewr/Makefile b/viewr/Makefile index fc4e0ff..dd431a1 100644 --- a/viewr/Makefile +++ b/viewr/Makefile @@ -3,8 +3,7 @@ all: build build: trunk build --release -deploy: - trunk build --release +deploy: build wrangler pages deploy dist local: From 6d0588b2529edc5615a942c34db257a2e6a7e2a0 Mon Sep 17 00:00:00 2001 From: Andrew Mackenzie Date: Mon, 19 Aug 2024 12:04:22 +0200 Subject: [PATCH 07/10] Try dependency workaround --- collectr/Cargo.toml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/collectr/Cargo.toml b/collectr/Cargo.toml index a545bcf..6ef0e0b 100644 --- a/collectr/Cargo.toml +++ b/collectr/Cargo.toml @@ -17,11 +17,10 @@ name = "worker" path = "src/worker.rs" [dependencies] -# To workaround issue: https://github.com/cloudflare/workers-rs/issues/617 -wasm-bindgen = "=0.2.92" - data_model = { path = "../data_model" } -worker = { version = "0.3.3", features = ["queue"] } +# To workaround issue: https://github.com/cloudflare/workers-rs/issues/617 +worker = { git = "https://github.com/fornwall/workers-rs", branch = "js-sys-0.3.70", features = ["queue"] } +#worker = { version = "0.3.3", features = ["queue"] } serde_derive = "~1.0" serde = "~1.0" serde_json = "1.0.107" \ No newline at end of file From 05eaca38cf26b29d62e35f1a0f06a75dad11f901 Mon Sep 17 00:00:00 2001 From: Andrew Mackenzie Date: Mon, 19 Aug 2024 12:37:12 +0200 Subject: [PATCH 08/10] Finx compatible dependencies --- collectr/Cargo.toml | 4 ++-- viewr/Cargo.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/collectr/Cargo.toml b/collectr/Cargo.toml index 6ef0e0b..d137928 100644 --- a/collectr/Cargo.toml +++ b/collectr/Cargo.toml @@ -19,8 +19,8 @@ path = "src/worker.rs" [dependencies] data_model = { path = "../data_model" } # To workaround issue: https://github.com/cloudflare/workers-rs/issues/617 -worker = { git = "https://github.com/fornwall/workers-rs", branch = "js-sys-0.3.70", features = ["queue"] } -#worker = { version = "0.3.3", features = ["queue"] } +js-sys = "=0.3.69" +worker = { version = "0.3.3", features = ["queue"] } serde_derive = "~1.0" serde = "~1.0" serde_json = "1.0.107" \ No newline at end of file diff --git a/viewr/Cargo.toml b/viewr/Cargo.toml index dbfe01f..6090738 100644 --- a/viewr/Cargo.toml +++ b/viewr/Cargo.toml @@ -14,8 +14,8 @@ path = "src/viewr.rs" [dependencies] data_model = { path = "../data_model" } console_error_panic_hook = "0.1.7" -leptos = { version = "0.6.14", features = ["csr"] } -leptos_router = { version = "0.6.14", features = ["csr"] } +leptos = { version = "0.6.13", features = ["csr"] } +leptos_router = { version = "0.6.13", features = ["csr"] } reqwasm = "0.5" serde = { version = "1", features = ["derive"] } chrono = "0.4.38" \ No newline at end of file From fc73ec4968bb67256287e93df978e92ea0fd6e3f Mon Sep 17 00:00:00 2001 From: Andrew Mackenzie Date: Tue, 20 Aug 2024 00:19:12 +0200 Subject: [PATCH 09/10] Pick up worker 0.3.4 and skip workaround --- collectr/Cargo.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/collectr/Cargo.toml b/collectr/Cargo.toml index d137928..f6ec2c4 100644 --- a/collectr/Cargo.toml +++ b/collectr/Cargo.toml @@ -18,9 +18,7 @@ path = "src/worker.rs" [dependencies] data_model = { path = "../data_model" } -# To workaround issue: https://github.com/cloudflare/workers-rs/issues/617 -js-sys = "=0.3.69" -worker = { version = "0.3.3", features = ["queue"] } +worker = { version = "0.3.4", features = ["queue"] } serde_derive = "~1.0" serde = "~1.0" serde_json = "1.0.107" \ No newline at end of file From 7a6a7c9305d24822227e60ed4dbf46f67542fa5b Mon Sep 17 00:00:00 2001 From: Andrew Mackenzie Date: Tue, 20 Aug 2024 00:29:12 +0200 Subject: [PATCH 10/10] pico feature --- picomon/Cargo.toml | 14 +++++++++----- wimon/Cargo.toml | 1 + wimon/src/lib/config.rs | 6 +++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/picomon/Cargo.toml b/picomon/Cargo.toml index 99603c1..2f31e8f 100644 --- a/picomon/Cargo.toml +++ b/picomon/Cargo.toml @@ -4,6 +4,10 @@ version = "0.1.0" readme = "README.md" edition = "2021" +[features] +default = ["pico"] +pico = [] + [dependencies] embassy-time = { version = "0.3.0", default-features = false, features = ["defmt", "defmt-timestamp-uptime"] } embassy-executor = { version = "0.6.0", default-features = false, features = ["task-arena-size-65536", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } @@ -14,19 +18,19 @@ cyw43 = { version = "0.1.0", default-features = false, features = ["defmt"] } cyw43-pio = { version = "0.1.0", default-features = false, features = ["defmt"] } panic-probe = { version = "0.3", default-features = false, features = ["print-defmt"] } portable-atomic = { version = "1.5", default-features = false, features = ["critical-section"] } -defmt = { version = "0.3", default-features = false} +defmt = { version = "0.3", default-features = false } defmt-rtt = { version = "0.4", default-features = false } cortex-m-rt = { version = "0.7.0", default-features = false } -static_cell = { version = "2", default-features = false} +static_cell = { version = "2", default-features = false } log = "0.4" # To convert device_id into hex for use as a string -faster-hex = { version = "0.9.0", default-features = false } +faster-hex = { version = "0.9.0", default-features = false } # To make httpclient requests to the server, with TLS -reqwless = { version="0.12.0", default-features = false, features = ["embedded-tls"]} +reqwless = { version = "0.12.0", default-features = false, features = ["embedded-tls"] } # Needed to workaround an embassy dns server count bug -smoltcp = { version = "0.11.0", default-features = false, features = ["dns-max-server-count-4"]} +smoltcp = { version = "0.11.0", default-features = false, features = ["dns-max-server-count-4"] } [build-dependencies] # for reading config from a file in build.rs diff --git a/wimon/Cargo.toml b/wimon/Cargo.toml index 4b96428..80017d8 100644 --- a/wimon/Cargo.toml +++ b/wimon/Cargo.toml @@ -14,6 +14,7 @@ path = "src/main.rs" [features] default = [] ssids = ["wifiscanner"] +pico = [] [dependencies] data_model = { path = "../data_model" } diff --git a/wimon/src/lib/config.rs b/wimon/src/lib/config.rs index bdbd93f..3f183d5 100644 --- a/wimon/src/lib/config.rs +++ b/wimon/src/lib/config.rs @@ -6,7 +6,7 @@ use serde_derive::{Deserialize, Serialize}; use url::Url; #[cfg_attr( - not(target = "thumbv6m-none-eabi"), + not(feature = "pico"), derive(Default, Serialize, Deserialize, Debug, PartialEq) )] pub enum MonitorSpec { @@ -18,7 +18,7 @@ pub enum MonitorSpec { } #[cfg_attr( - not(target = "thumbv6m-none-eabi"), + not(feature = "pico"), derive(Serialize, Deserialize, Debug, PartialEq) )] pub struct ReportSpec { @@ -27,7 +27,7 @@ pub struct ReportSpec { } #[cfg_attr( - not(target = "thumbv6m-none-eabi"), + not(feature = "pico"), derive(Default, Serialize, Deserialize) )] pub struct Config {