From 01066370909fb802afef90a276ac3e403abb4f71 Mon Sep 17 00:00:00 2001 From: decentclock Date: Tue, 25 Oct 2022 18:05:31 -0400 Subject: [PATCH] lots of nits quit deploy script if one of the command fails - don't carry on pin factory nightly to 2022-10-20 log error messages from start_config_server_and_wait throw error if PASS is set to a password less than 8 characters clearly log access point wifi name and password --- deploy.sh | 21 +++++++++++++-------- factory/rust-toolchain.toml | 2 +- sphinx-key/src/conn/wifi.rs | 6 +++++- sphinx-key/src/main.rs | 13 ++++++++----- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/deploy.sh b/deploy.sh index d97a09f..bb0c531 100755 --- a/deploy.sh +++ b/deploy.sh @@ -32,6 +32,11 @@ then echo "Please set environment variable PASS to the password of the wifi you'll use to configure your sphinx-key." exit 1 fi +if [ ${#PASS} -lt 8 ] +then + echo "Please set PASS to a password longer than 7 characters." + exit 1 +fi for FILE in /dev/tty.* do if check_port $FILE @@ -46,12 +51,12 @@ then echo "Make sure the ESP is connected with a data USB cable, and try again." exit 1 fi -esptool.py erase_flash -git pull -cd factory -cargo espflash --release $PORT -cd ../sphinx-key -cargo build --release -esptool.py --chip esp32-c3 elf2image target/riscv32imc-esp-espidf/release/sphinx-key -esptool.py --chip esp32c3 -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size 4MB 0x80000 target/riscv32imc-esp-espidf/release/sphinx-key.bin +esptool.py erase_flash && +git pull && +cd factory && +cargo espflash --release $PORT && +cd ../sphinx-key && +cargo build --release && +esptool.py --chip esp32-c3 elf2image target/riscv32imc-esp-espidf/release/sphinx-key && +esptool.py --chip esp32c3 -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size 4MB 0x80000 target/riscv32imc-esp-espidf/release/sphinx-key.bin && cargo espflash serial-monitor $PORT diff --git a/factory/rust-toolchain.toml b/factory/rust-toolchain.toml index 271800c..4f79377 100644 --- a/factory/rust-toolchain.toml +++ b/factory/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "nightly" \ No newline at end of file +channel = "nightly-2022-10-20" diff --git a/sphinx-key/src/conn/wifi.rs b/sphinx-key/src/conn/wifi.rs index 5d8a9ec..9f5483c 100644 --- a/sphinx-key/src/conn/wifi.rs +++ b/sphinx-key/src/conn/wifi.rs @@ -86,6 +86,10 @@ pub fn start_access_point(default_nvs: Arc) -> Result= 8 characters. Compile this software again with a longer password.", password)); + } + wifi.set_configuration(&Configuration::AccessPoint(AccessPointConfiguration { ssid: ssid.into(), password: password.into(), @@ -100,7 +104,7 @@ pub fn start_access_point(default_nvs: Arc) -> Result Result<()> { } else { led_tx.send(Status::WifiAccessPoint).unwrap(); println!("=============> START SERVER NOW AND WAIT <=============="); - if let Ok((_wifi, config, seed)) = start_config_server_and_wait(default_nvs.clone()) { - flash.write_config(config).expect("could not store config"); - flash.write_seed(seed).expect("could not store seed"); - println!("CONFIG SAVED"); - unsafe { esp_idf_sys::esp_restart() }; + match start_config_server_and_wait(default_nvs.clone()) { + Ok((_wifi, config, seed)) => { + flash.write_config(config).expect("could not store config"); + flash.write_seed(seed).expect("could not store seed"); + println!("CONFIG SAVED"); + unsafe { esp_idf_sys::esp_restart() }; + }, + Err(msg) => log::error!("{}", msg), } }