diff --git a/README.md b/README.md index 79ac66a..ccd86c9 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ A Lightning Hardware Wallet based on [Validating Lightning Signer](https://gitla Find your port (`ls /dev/tty.*`) -`PORT=/dev/tty.usbserial-1420` +`PORT=/dev/tty.usbserial-1410` `espflash $PORT target/riscv32imc-esp-espidf/release/sphinx-key-factory` diff --git a/sphinx-key/src/clear.rs b/sphinx-key/src/clear.rs index c17803e..30a3cb3 100644 --- a/sphinx-key/src/clear.rs +++ b/sphinx-key/src/clear.rs @@ -1,9 +1,22 @@ +mod conn; +mod core; +mod ota; +mod periph; + +#[allow(unused_imports)] +use crate::periph::sd::mount_sd_card; + use esp_idf_sys as _; // If using the `binstart` feature of `esp-idf-sys`, always keep this module imported // use embedded_svc::storage::StorageBase; use esp_idf_svc::nvs::EspNvs; use esp_idf_svc::nvs::*; +use std::fs; +use std::path::Path; + +pub const ROOT_STORE: &str = "/sdcard/store"; + fn main() -> anyhow::Result<()> { // NvsDefault::new(); let default_nvs = EspDefaultNvsPartition::take()?; @@ -13,5 +26,28 @@ fn main() -> anyhow::Result<()> { store.remove("nonce").expect("couldnt remove nonce 1"); store.remove("policy").expect("couldnt remove policy 1"); println!("NVS cleared!"); + + println!("About to mount the sdcard..."); + while let Err(_e) = mount_sd_card() { + println!("Failed to mount sd card. Make sure it is connected, trying again..."); + std::thread::sleep(std::time::Duration::from_secs(5)); + } + println!("SD card mounted!"); + + let dir = Path::new(ROOT_STORE); + println!("root store is dir {}", dir.is_dir()); + if dir.is_dir() { + for entry in fs::read_dir(dir)? { + let entry = entry?; + let path = entry.path(); + if path.is_dir() { + println!("PATH {}", path.display()); + if let Err(e) = fs::remove_dir_all(path) { + println!("err removing dir"); + } + } + } + } + Ok(()) } diff --git a/sphinx-key/src/conn/mqtt.rs b/sphinx-key/src/conn/mqtt.rs index e978902..1dd9c50 100644 --- a/sphinx-key/src/conn/mqtt.rs +++ b/sphinx-key/src/conn/mqtt.rs @@ -13,7 +13,7 @@ use log::*; use std::sync::mpsc; use std::thread; -pub const QOS: QoS = QoS::ExactlyOnce; +pub const QOS: QoS = QoS::AtMostOnce; pub fn make_client( broker: &str,