reorg modules and Status enum

This commit is contained in:
Evan Feenstra
2023-06-13 15:21:20 -07:00
parent eda915f8e3
commit ad46e2c184
9 changed files with 52 additions and 23 deletions

View File

@@ -48,3 +48,6 @@ anyhow = "1"
name = "clear"
path = "src/clear.rs"
[[bin]]
name = "btn"
path = "src/btn.rs"

26
sphinx-key/src/btn.rs Normal file
View File

@@ -0,0 +1,26 @@
mod periph;
mod status;
use status::Status;
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_hal::peripherals::Peripherals;
use esp_idf_svc::nvs::EspNvs;
use esp_idf_svc::nvs::*;
use std::sync::mpsc;
fn main() -> anyhow::Result<()> {
let peripherals = Peripherals::take().unwrap();
let pins = peripherals.pins;
let (led_tx, led_rx) = mpsc::channel::<Status>();
// LED control thread
periph::led::led_control_loop(pins.gpio0, peripherals.rmt.channel0, led_rx);
// BUTTON thread
periph::button::button_loop(pins.gpio8, led_tx.clone());
Ok(())
}

View File

@@ -1,7 +1,5 @@
mod conn;
mod core;
mod ota;
mod periph;
mod status;
#[allow(unused_imports)]
use crate::periph::sd::mount_sd_card;

View File

@@ -1,6 +1,7 @@
use crate::conn::mqtt::QOS;
use crate::core::lss;
use crate::ota::{update_sphinx_key, validate_ota_message};
use crate::status::Status;
use lss_connector::secp256k1::PublicKey;
use sphinx_signer::lightning_signer::bitcoin::Network;
@@ -32,23 +33,6 @@ pub enum Event {
Control(Vec<u8>),
}
#[derive(Debug, Ord, PartialOrd, Eq, PartialEq)]
pub enum Status {
Starting,
MountingSDCard,
SyncingTime,
WifiAccessPoint,
Configuring,
ConnectingToWifi,
ConnectingToMqtt,
Connected,
Signing,
Ota,
Reset1,
Reset2,
Reset3,
}
pub const ROOT_STORE: &str = "/sdcard/store";
pub const SUB_TOPICS: &[&str] = &[topics::VLS, topics::LSS_MSG, topics::CONTROL];

View File

@@ -3,9 +3,11 @@ mod conn;
mod core;
mod ota;
mod periph;
mod status;
use crate::core::control::{controller_from_seed, FlashPersister};
use crate::core::{config::*, events::*};
use crate::status::Status;
// use crate::periph::led::led_control_loop;
use crate::periph::button::button_loop;
#[allow(unused_imports)]

View File

@@ -1,4 +1,4 @@
use crate::core::events::Status;
use crate::status::Status;
use anyhow::{anyhow, Result};
use embedded_svc::http::client::Client;
use embedded_svc::http::Status as HttpStatus;

View File

@@ -1,4 +1,4 @@
use crate::core::events::Status;
use crate::status::Status;
use esp_idf_hal::gpio;
use esp_idf_hal::gpio::*;
use std::sync::mpsc;

View File

@@ -1,4 +1,4 @@
use crate::core::events::Status;
use crate::status::Status;
use esp_idf_hal::rmt::config::TransmitConfig;
use esp_idf_hal::rmt::{FixedLengthSignal, PinState, Pulse, TxRmtDriver};
use esp_idf_hal::{gpio, rmt};

16
sphinx-key/src/status.rs Normal file
View File

@@ -0,0 +1,16 @@
#[derive(Debug, Ord, PartialOrd, Eq, PartialEq)]
pub enum Status {
Starting,
MountingSDCard,
SyncingTime,
WifiAccessPoint,
Configuring,
ConnectingToWifi,
ConnectingToMqtt,
Connected,
Signing,
Ota,
Reset1,
Reset2,
Reset3,
}