mirror of
https://github.com/stakwork/sphinx-key.git
synced 2026-02-09 17:54:35 +01:00
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
This commit is contained in:
21
deploy.sh
21
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
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "nightly"
|
||||
channel = "nightly-2022-10-20"
|
||||
|
||||
@@ -86,6 +86,10 @@ pub fn start_access_point(default_nvs: Arc<EspDefaultNvs>) -> Result<Box<EspWifi
|
||||
|
||||
let ssid: &'static str = env!("SSID");
|
||||
let password: &'static str = env!("PASS");
|
||||
if password.len() < 8 {
|
||||
return Err(anyhow::anyhow!("Password error!\nCurrent password: {}\nYour wifi password must be >= 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<EspDefaultNvs>) -> Result<Box<EspWifi
|
||||
|
||||
let status = wifi.get_status();
|
||||
if let Status(ClientStatus::Stopped, ApStatus::Started(ApIpStatus::Done)) = status {
|
||||
info!("Wifi started!");
|
||||
info!("Wifi started!\n \nWIFI NAME: {}\nWIFI PASSWORD: {}\n", ssid, password);
|
||||
} else {
|
||||
return Err(anyhow::anyhow!("Unexpected AP Wifi status: {:?}", status));
|
||||
}
|
||||
|
||||
@@ -104,11 +104,14 @@ fn main() -> 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),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user