Clean up some lints
This commit is contained in:
parent
5592708271
commit
f8ef06ee0c
|
|
@ -9,7 +9,7 @@ use ekv::{
|
||||||
flash::{Flash, PageID},
|
flash::{Flash, PageID},
|
||||||
};
|
};
|
||||||
use embassy_embedded_hal::{adapter::BlockingAsync, flash::partition::Partition};
|
use embassy_embedded_hal::{adapter::BlockingAsync, flash::partition::Partition};
|
||||||
use embassy_sync::blocking_mutex::raw::{CriticalSectionRawMutex, RawMutex};
|
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||||
use embedded_storage_async::nor_flash::{NorFlash, ReadNorFlash};
|
use embedded_storage_async::nor_flash::{NorFlash, ReadNorFlash};
|
||||||
use esp_hal::rng::Trng;
|
use esp_hal::rng::Trng;
|
||||||
use esp_storage::FlashStorage;
|
use esp_storage::FlashStorage;
|
||||||
|
|
@ -300,7 +300,7 @@ where
|
||||||
key: &[u8],
|
key: &[u8],
|
||||||
buffer: &'b mut Vec<u8>,
|
buffer: &'b mut Vec<u8>,
|
||||||
) -> Result<&'b mut [u8], ekv::ReadError<F::Error>> {
|
) -> Result<&'b mut [u8], ekv::ReadError<F::Error>> {
|
||||||
if buffer.len() == 0 {
|
if buffer.is_empty() {
|
||||||
buffer.resize(1, 0);
|
buffer.resize(1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,7 @@ use core::{
|
||||||
|
|
||||||
use data_encoding_macro::hexlower;
|
use data_encoding_macro::hexlower;
|
||||||
use embassy_sync::blocking_mutex::{self, raw::CriticalSectionRawMutex};
|
use embassy_sync::blocking_mutex::{self, raw::CriticalSectionRawMutex};
|
||||||
use hmac::{
|
use hmac::digest::{FixedOutput, KeyInit, Update};
|
||||||
Hmac, SimpleHmac,
|
|
||||||
digest::{FixedOutput, KeyInit, Update},
|
|
||||||
};
|
|
||||||
use sha2::{
|
use sha2::{
|
||||||
Digest,
|
Digest,
|
||||||
digest::{consts::U32, generic_array::GenericArray},
|
digest::{consts::U32, generic_array::GenericArray},
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ pub unsafe extern "C" fn __xkbc_fprintf(
|
||||||
pub unsafe extern "C" fn __spre_fprintf(
|
pub unsafe extern "C" fn __spre_fprintf(
|
||||||
stream: *mut FILE,
|
stream: *mut FILE,
|
||||||
format: *const c_char,
|
format: *const c_char,
|
||||||
mut args: ...
|
args: ...
|
||||||
) -> c_int {
|
) -> c_int {
|
||||||
unsafe { __xkbc_fprintf(stream, format) }
|
unsafe { __xkbc_fprintf(stream, format) }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
||||||
use core::{
|
use core::{
|
||||||
error,
|
|
||||||
ffi::{c_char, c_int, c_long, c_longlong, c_size_t, c_void},
|
ffi::{c_char, c_int, c_long, c_longlong, c_size_t, c_void},
|
||||||
ptr::null_mut,
|
ptr::null_mut,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ use slint::platform::Key;
|
||||||
use xkbcommon::xkb::{self, FeedResult, KeyDirection, Keysym, Status};
|
use xkbcommon::xkb::{self, FeedResult, KeyDirection, Keysym, Status};
|
||||||
|
|
||||||
use crate::matrix::{MATRIX_COLS, MATRIX_ROWS};
|
use crate::matrix::{MATRIX_COLS, MATRIX_ROWS};
|
||||||
use crate::util::{DurationExt, FormattedDuration};
|
use crate::util::DurationExt;
|
||||||
use crate::vial::CustomKeycodes;
|
use crate::vial::CustomKeycodes;
|
||||||
use crate::{KEYBOARD_REPORT_PROXY, PSRAM_ALLOCATOR};
|
use crate::{KEYBOARD_REPORT_PROXY, PSRAM_ALLOCATOR};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,12 @@ use alloc::vec;
|
||||||
use embassy_embedded_hal::adapter::BlockingAsync;
|
use embassy_embedded_hal::adapter::BlockingAsync;
|
||||||
use embassy_embedded_hal::flash::partition::Partition;
|
use embassy_embedded_hal::flash::partition::Partition;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_sync::blocking_mutex;
|
|
||||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||||
use embassy_sync::channel::Channel;
|
use embassy_sync::channel::Channel;
|
||||||
use embassy_sync::mutex::Mutex;
|
use embassy_sync::mutex::Mutex;
|
||||||
use embassy_sync::signal::Signal;
|
use embassy_sync::signal::Signal;
|
||||||
use embassy_time::{Duration, Timer};
|
use embassy_time::{Duration, Timer};
|
||||||
use esp_alloc::{HeapRegion, MemoryCapability, RegionStats};
|
use esp_alloc::{HeapRegion, MemoryCapability};
|
||||||
use esp_hal::Blocking;
|
use esp_hal::Blocking;
|
||||||
use esp_hal::clock::CpuClock;
|
use esp_hal::clock::CpuClock;
|
||||||
use esp_hal::dma::{BurstConfig, DmaDescriptor, DmaTxBuf, ExternalBurstConfig};
|
use esp_hal::dma::{BurstConfig, DmaDescriptor, DmaTxBuf, ExternalBurstConfig};
|
||||||
|
|
@ -44,10 +43,9 @@ use esp_hal::mcpwm::{McPwm, PeripheralClockConfig};
|
||||||
use esp_hal::psram::{FlashFreq, PsramConfig, PsramSize, SpiRamFreq, SpiTimingConfigCoreClock};
|
use esp_hal::psram::{FlashFreq, PsramConfig, PsramSize, SpiRamFreq, SpiTimingConfigCoreClock};
|
||||||
use esp_hal::ram;
|
use esp_hal::ram;
|
||||||
use esp_hal::rng::TrngSource;
|
use esp_hal::rng::TrngSource;
|
||||||
use esp_hal::sha::{Sha, ShaBackend};
|
use esp_hal::sha::ShaBackend;
|
||||||
use esp_hal::system::Stack;
|
use esp_hal::system::Stack;
|
||||||
use esp_hal::timer::timg::TimerGroup;
|
use esp_hal::timer::timg::TimerGroup;
|
||||||
use esp_println::println;
|
|
||||||
use esp_rtos::embassy::Executor;
|
use esp_rtos::embassy::Executor;
|
||||||
use esp_storage::FlashStorage;
|
use esp_storage::FlashStorage;
|
||||||
use log::{error, info, warn};
|
use log::{error, info, warn};
|
||||||
|
|
@ -64,7 +62,6 @@ use rmk::storage::async_flash_wrapper;
|
||||||
use rmk::types::action::{Action, KeyAction};
|
use rmk::types::action::{Action, KeyAction};
|
||||||
use rmk::{initialize_keymap_and_storage, run_devices, run_rmk};
|
use rmk::{initialize_keymap_and_storage, run_devices, run_rmk};
|
||||||
use slint::platform::software_renderer::Rgb565Pixel;
|
use slint::platform::software_renderer::Rgb565Pixel;
|
||||||
use spectre_api_sys::SpectreAlgorithm;
|
|
||||||
use static_cell::StaticCell;
|
use static_cell::StaticCell;
|
||||||
use {esp_alloc as _, esp_backtrace as _};
|
use {esp_alloc as _, esp_backtrace as _};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ use core::{cell::RefCell, time::Duration};
|
||||||
|
|
||||||
use alloc::{rc::Rc, string::ToString};
|
use alloc::{rc::Rc, string::ToString};
|
||||||
use esp_hal::time::Instant;
|
use esp_hal::time::Instant;
|
||||||
use log::{debug, info, warn};
|
use log::{debug, info};
|
||||||
use slint::{
|
use slint::{
|
||||||
PhysicalSize, SharedString, ToSharedString, WindowSize,
|
PhysicalSize, SharedString, WindowSize,
|
||||||
platform::{
|
platform::{
|
||||||
Key, WindowEvent,
|
Key, WindowEvent,
|
||||||
software_renderer::{RenderingRotation, RepaintBufferType, Rgb565Pixel, SoftwareRenderer},
|
software_renderer::{RenderingRotation, RepaintBufferType, Rgb565Pixel, SoftwareRenderer},
|
||||||
|
|
@ -62,8 +62,7 @@ impl slint::platform::Platform for SlintBackend {
|
||||||
|
|
||||||
if let Some(string) = key_message.string.as_ref()
|
if let Some(string) = key_message.string.as_ref()
|
||||||
&& (Keysym::a..=Keysym::z).contains(&key_message.keysym)
|
&& (Keysym::a..=Keysym::z).contains(&key_message.keysym)
|
||||||
{
|
&& let &[code] = string.as_bytes() {
|
||||||
if let &[code] = string.as_bytes() {
|
|
||||||
const UNICODE_CTRL_A: char = '\u{1}';
|
const UNICODE_CTRL_A: char = '\u{1}';
|
||||||
|
|
||||||
let letter_index_from_keysym =
|
let letter_index_from_keysym =
|
||||||
|
|
@ -85,7 +84,6 @@ impl slint::platform::Platform for SlintBackend {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// let text = key_message.string.map(SharedString::from).or_else(|| {
|
// let text = key_message.string.map(SharedString::from).or_else(|| {
|
||||||
// Key::try_from_keysym(key_message.keysym).map(SharedString::from)
|
// Key::try_from_keysym(key_message.keysym).map(SharedString::from)
|
||||||
|
|
|
||||||
|
|
@ -1,50 +1,18 @@
|
||||||
// #![cfg_attr(not(feature = "simulator"), no_main)]
|
// #![cfg_attr(not(feature = "simulator"), no_main)]
|
||||||
|
|
||||||
use core::{
|
use core::{cell::RefCell, ffi::CStr};
|
||||||
cell::RefCell,
|
|
||||||
ffi::CStr,
|
|
||||||
iter::Chain,
|
|
||||||
ops::{Deref, DerefMut, Range},
|
|
||||||
};
|
|
||||||
|
|
||||||
use alloc::{
|
use alloc::{boxed::Box, ffi::CString, format, rc::Rc, vec};
|
||||||
borrow::Cow,
|
use embassy_time::Instant;
|
||||||
boxed::Box,
|
|
||||||
ffi::CString,
|
|
||||||
format,
|
|
||||||
rc::Rc,
|
|
||||||
string::{String, ToString},
|
|
||||||
vec,
|
|
||||||
vec::Vec,
|
|
||||||
};
|
|
||||||
use chrono::{DateTime, NaiveDateTime};
|
|
||||||
use ekv::{Database, MountError, flash::PageID};
|
|
||||||
use embassy_embedded_hal::{adapter::BlockingAsync, flash::partition::Partition};
|
|
||||||
use embassy_sync::blocking_mutex::raw::{CriticalSectionRawMutex, RawMutex};
|
|
||||||
use embassy_time::{Duration, Instant};
|
|
||||||
use embedded_storage_async::nor_flash::{NorFlash, ReadNorFlash};
|
|
||||||
use esp_hal::rng::Trng;
|
|
||||||
use esp_storage::FlashStorage;
|
|
||||||
use itertools::Itertools;
|
|
||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use password_hash::Key;
|
use slint::SharedString;
|
||||||
use rmk::futures::TryFutureExt;
|
use spectre_api_sys::{SpectreAlgorithm, SpectreUserKey};
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use serde_bytes::Bytes;
|
|
||||||
use slint::{ModelRc, SharedString, StandardListViewItem, VecModel};
|
|
||||||
use spectre_api_sys::{
|
|
||||||
SpectreAlgorithm, SpectreCounter, SpectreKeyID, SpectreKeyPurpose, SpectreResultType,
|
|
||||||
SpectreUserKey,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(feature = "limit-fps")]
|
#[cfg(feature = "limit-fps")]
|
||||||
use crate::FRAME_DURATION_MIN;
|
use crate::FRAME_DURATION_MIN;
|
||||||
use crate::{
|
use crate::{
|
||||||
PSRAM_ALLOCATOR, SIGNAL_LCD_SUBMIT, SIGNAL_UI_RENDER,
|
PSRAM_ALLOCATOR, SIGNAL_LCD_SUBMIT, SIGNAL_UI_RENDER,
|
||||||
db::{
|
db::{AcidDatabase, DbKey, DbPathSpectreUsers, PartitionAcid, ReadTransactionExt},
|
||||||
AcidDatabase, DbKey, DbPathSpectreUserSite, DbPathSpectreUserSites, DbPathSpectreUsers,
|
|
||||||
PartitionAcid, ReadTransactionExt,
|
|
||||||
},
|
|
||||||
ffi::alloc::__spre_free,
|
ffi::alloc::__spre_free,
|
||||||
ui::{
|
ui::{
|
||||||
backend::SlintBackend,
|
backend::SlintBackend,
|
||||||
|
|
@ -77,7 +45,7 @@ fn spectre_derive_user_key(username: &CStr, password: &CStr) -> SpectreUserKey {
|
||||||
"User key derived in {} seconds:\n{user_key:02x?}",
|
"User key derived in {} seconds:\n{user_key:02x?}",
|
||||||
user_key_duration.display_as_secs()
|
user_key_duration.display_as_secs()
|
||||||
);
|
);
|
||||||
let user_key_stack = user_key.clone();
|
let user_key_stack = *user_key;
|
||||||
|
|
||||||
// TODO: Erase memory before freeing
|
// TODO: Erase memory before freeing
|
||||||
__spre_free(user_key as *const _ as *mut _);
|
__spre_free(user_key as *const _ as *mut _);
|
||||||
|
|
@ -215,7 +183,7 @@ impl State {
|
||||||
.read_to_vec(&DbKey::new(DbPathSpectreUsers), &mut buffer)
|
.read_to_vec(&DbKey::new(DbPathSpectreUsers), &mut buffer)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(bytes) => postcard::from_bytes::<SpectreUsersConfig>(&bytes).unwrap(),
|
Ok(bytes) => postcard::from_bytes::<SpectreUsersConfig>(bytes).unwrap(),
|
||||||
Err(ekv::ReadError::KeyNotFound) => Default::default(),
|
Err(ekv::ReadError::KeyNotFound) => Default::default(),
|
||||||
Err(error) => panic!("Failed to read the users config: {error:?}"),
|
Err(error) => panic!("Failed to read the users config: {error:?}"),
|
||||||
}
|
}
|
||||||
|
|
@ -347,7 +315,7 @@ impl State {
|
||||||
}
|
}
|
||||||
|
|
||||||
trait AppViewTrait {
|
trait AppViewTrait {
|
||||||
fn process_callback_message(state: &mut State, message: CallbackMessage) {}
|
fn process_callback_message(_state: &mut State, _message: CallbackMessage) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
@ -355,8 +323,9 @@ struct StateLogin {}
|
||||||
|
|
||||||
impl AppViewTrait for StateLogin {
|
impl AppViewTrait for StateLogin {
|
||||||
fn process_callback_message(state: &mut State, message: CallbackMessage) {
|
fn process_callback_message(state: &mut State, message: CallbackMessage) {
|
||||||
match message {
|
if let CallbackMessage::Login(CallbackMessageLogin::PwAccepted { username, password }) =
|
||||||
CallbackMessage::Login(CallbackMessageLogin::PwAccepted { username, password }) => {
|
message
|
||||||
|
{
|
||||||
let username_c =
|
let username_c =
|
||||||
CString::new(&*username).expect("Username cannot be converted to a C string.");
|
CString::new(&*username).expect("Username cannot be converted to a C string.");
|
||||||
let password_c =
|
let password_c =
|
||||||
|
|
@ -382,7 +351,7 @@ impl AppViewTrait for StateLogin {
|
||||||
.users
|
.users
|
||||||
.users
|
.users
|
||||||
.iter()
|
.iter()
|
||||||
.find(|user| &*user.username == &*username)
|
.find(|user| *user.username == *username)
|
||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
@ -396,8 +365,6 @@ impl AppViewTrait for StateLogin {
|
||||||
// TODO: Clear the input
|
// TODO: Clear the input
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => (),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -469,7 +436,7 @@ impl AppViewTrait for StateUserEdit {
|
||||||
identicon,
|
identicon,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
CallbackMessage::UserEdit(CallbackMessageUserEdit::Confirm { encrypted_key }) => {
|
CallbackMessage::UserEdit(CallbackMessageUserEdit::Confirm { encrypted_key: _ }) => {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ impl Default for SpectreSiteConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
struct SpectreSite {
|
pub struct SpectreSite {
|
||||||
pub username: String,
|
pub username: String,
|
||||||
pub site_name: String,
|
pub site_name: String,
|
||||||
pub config: SpectreSiteConfig,
|
pub config: SpectreSiteConfig,
|
||||||
|
|
@ -91,6 +91,7 @@ mod with_repr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
pub fn serialize<T, S>(value: &T, serializer: S) -> Result<S::Ok, S::Error>
|
pub fn serialize<T, S>(value: &T, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
T: ReprConvert<Repr = u32>,
|
T: ReprConvert<Repr = u32>,
|
||||||
|
|
@ -99,6 +100,7 @@ mod with_repr {
|
||||||
serializer.serialize_u32(value.into_repr())
|
serializer.serialize_u32(value.into_repr())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
pub fn deserialize<'de, T, D>(deserializer: D) -> Result<T, D::Error>
|
pub fn deserialize<'de, T, D>(deserializer: D) -> Result<T, D::Error>
|
||||||
where
|
where
|
||||||
T: ReprConvert<Repr = u32>,
|
T: ReprConvert<Repr = u32>,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue