Compare commits
3 commits
357437b36c
...
c2725ad3db
Author | SHA1 | Date | |
---|---|---|---|
c2725ad3db | |||
617fe896d7 | |||
9fdd219fb8 |
11 changed files with 233 additions and 14 deletions
86
common/Cargo.lock
generated
86
common/Cargo.lock
generated
|
@ -2,13 +2,77 @@
|
|||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "common"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"sha3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"crypto-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "keccak"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654"
|
||||
dependencies = [
|
||||
"cpufeatures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.167"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.92"
|
||||
|
@ -47,6 +111,16 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha3"
|
||||
version = "0.10.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60"
|
||||
dependencies = [
|
||||
"digest",
|
||||
"keccak",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.90"
|
||||
|
@ -58,8 +132,20 @@ dependencies = [
|
|||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
|
|
@ -4,4 +4,5 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
sha3 = {version="0.10.0", default-features=false}
|
||||
serde = { version = "1.0.203", default-features = false, features = ["derive"] }
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#![no_std]
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use sha3::{Digest, Sha3_256};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub enum Request {
|
||||
|
@ -25,7 +26,24 @@ pub enum Name {
|
|||
Thia,
|
||||
Michael,
|
||||
Zoey,
|
||||
Coke,
|
||||
Unknown,
|
||||
}
|
||||
|
||||
impl Name {
|
||||
pub fn from_badge(badge: u64) -> Self {
|
||||
let mut hasher = Sha3_256::new();
|
||||
hasher.update(badge.to_be_bytes());
|
||||
|
||||
let hash = hasher.finalize();
|
||||
let hash = u64::from_be_bytes(hash[..8].try_into().unwrap());
|
||||
|
||||
match hash {
|
||||
0x14b9c91fe4505456 => Self::Evan,
|
||||
0x6b859025842cd369 => Self::Andy,
|
||||
0xb366d73deaaa8d9d => Self::Felix,
|
||||
0x30c79f56dc74f998 => Self::Phil,
|
||||
_ => Self::Unknown,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
2
inside/Cargo.lock
generated
2
inside/Cargo.lock
generated
|
@ -1,6 +1,6 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "aead"
|
||||
|
|
|
@ -11,6 +11,7 @@ use core::panic::PanicInfo;
|
|||
use core::str::from_utf8;
|
||||
|
||||
use bt_hci::cmd::info;
|
||||
use cyw43::JoinOptions;
|
||||
use cyw43_pio::PioSpi;
|
||||
use embassy_rp::pwm::{self, Pwm};
|
||||
use fixed::FixedU16;
|
||||
|
@ -109,12 +110,12 @@ async fn main(spawner: Spawner) {
|
|||
|
||||
control.init(clm).await;
|
||||
control
|
||||
.set_power_management(cyw43::PowerManagementMode::PowerSave)
|
||||
.set_power_management(cyw43::PowerManagementMode::Performance)
|
||||
.await;
|
||||
|
||||
// Use a link-local address for communication without DHCP server
|
||||
let config = Config::ipv4_static(embassy_net::StaticConfigV4 {
|
||||
address: embassy_net::Ipv4Cidr::new(embassy_net::Ipv4Address::new(169, 254, 1, 1), 16),
|
||||
address: embassy_net::Ipv4Cidr::new(embassy_net::Ipv4Address::new(192, 168, 0, 10), 24),
|
||||
dns_servers: heapless::Vec::new(),
|
||||
gateway: None,
|
||||
});
|
||||
|
@ -128,8 +129,17 @@ async fn main(spawner: Spawner) {
|
|||
|
||||
defmt::unwrap!(spawner.spawn(net_task(runner)));
|
||||
|
||||
//control.start_ap_open("door409", 5).await;
|
||||
control.start_ap_wpa2("door409", "babelite", 5).await;
|
||||
loop {
|
||||
match control
|
||||
.await
|
||||
{
|
||||
Ok(_) => break,
|
||||
Err(err) => {
|
||||
info!("join failed with status={}", err.status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let mut rx_buffer = [0; 4096];
|
||||
let mut tx_buffer = [0; 4096];
|
||||
|
|
20
outside/Cargo.lock
generated
20
outside/Cargo.lock
generated
|
@ -265,6 +265,7 @@ name = "common"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"sha3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1392,6 +1393,15 @@ version = "1.0.14"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
|
||||
|
||||
[[package]]
|
||||
name = "keccak"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654"
|
||||
dependencies = [
|
||||
"cpufeatures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lalrpop"
|
||||
version = "0.19.12"
|
||||
|
@ -2074,6 +2084,16 @@ version = "0.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5f179d4e11094a893b82fff208f74d448a7512f99f5a0acbd5c679b705f83ed9"
|
||||
|
||||
[[package]]
|
||||
name = "sha3"
|
||||
version = "0.10.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60"
|
||||
dependencies = [
|
||||
"digest",
|
||||
"keccak",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "siphasher"
|
||||
version = "0.3.11"
|
||||
|
|
|
@ -33,14 +33,15 @@ impl Authorized for Name {
|
|||
}
|
||||
}
|
||||
async fn from_badge(badge: u64) -> Self {
|
||||
match badge {
|
||||
badge => {
|
||||
match Name::from_badge(badge) {
|
||||
Name::Unknown => {
|
||||
if let Some(name) = NAMES.lock().await.borrow().get(badge) {
|
||||
*name
|
||||
} else {
|
||||
Name::Unknown
|
||||
}
|
||||
},
|
||||
badge => badge,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +54,7 @@ pub async fn send_badge(channel: Receiver<'static,CriticalSectionRawMutex,u64,1>
|
|||
let card = channel.receive().await;
|
||||
|
||||
*LAST_BADGE.lock().await.borrow_mut() = card;
|
||||
let name = Name::from_badge(card).await;
|
||||
let name= <Name as Authorized>::from_badge(card).await;
|
||||
|
||||
// this is also checked on the backend (TODO)
|
||||
if !name.authorized() {
|
||||
|
@ -64,7 +65,7 @@ pub async fn send_badge(channel: Receiver<'static,CriticalSectionRawMutex,u64,1>
|
|||
let mut socket = TcpSocket::new(stack, &mut rx_buffer, &mut tx_buffer);
|
||||
socket.set_timeout(Some(Duration::from_secs(10)));
|
||||
info!("attempting conn to inside");
|
||||
if let Err(e) = socket.connect(IpEndpoint::new(Ipv4Address::new(169, 254, 1, 1).into_address(), 1234)).await {
|
||||
if let Err(e) = socket.connect(IpEndpoint::new(Ipv4Address::new(192, 168, 0, 10).into_address(), 1234)).await {
|
||||
warn!("connect error: {:?}", e);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ async fn main(spawner: Spawner) {
|
|||
|
||||
// Use a link-local address for communication without DHCP server
|
||||
let config = Config::ipv4_static(embassy_net::StaticConfigV4 {
|
||||
address: embassy_net::Ipv4Cidr::new(embassy_net::Ipv4Address::new(169, 254, 2, 1), 16),
|
||||
address: embassy_net::Ipv4Cidr::new(embassy_net::Ipv4Address::new(192, 168, 0, 12), 24),
|
||||
dns_servers: heapless::Vec::new(),
|
||||
gateway: None,
|
||||
});
|
||||
|
|
|
@ -47,7 +47,6 @@ impl Tracks for Name {
|
|||
Name::Thia => 7,
|
||||
Name::Michael => 0,
|
||||
Name::Zoey => 1,
|
||||
Name::Coke => todo!(),
|
||||
Name::Unknown => 0,
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +65,6 @@ impl Tracks for Name {
|
|||
Name::Thia => "thia",
|
||||
Name::Michael => "michael",
|
||||
Name::Zoey => "zoey",
|
||||
Name::Coke => "button",
|
||||
Name::Unknown => "",
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +80,7 @@ pub enum MusicCommand {
|
|||
/// 0-30
|
||||
SetVolume(u8),
|
||||
Play(&'static str),
|
||||
Button(),
|
||||
}
|
||||
|
||||
#[embassy_executor::task]
|
||||
|
@ -125,6 +124,10 @@ pub async fn music_manager(uart: UART1, irqs: Irqs, txp: PIN_20, rxp: PIN_21) ->
|
|||
}
|
||||
|
||||
},
|
||||
MusicCommand::Button() => {
|
||||
let index = rng.next_u32() % 12 as u32;
|
||||
play_song("b", Some((index+1) as u8), &mut uart).await;
|
||||
},
|
||||
MusicCommand::Play(song) => {
|
||||
play_song(song, None, &mut uart).await
|
||||
},
|
||||
|
|
|
@ -41,7 +41,7 @@ pub async fn wiggle_manager(pwm: PWM_SLICE5, head: PIN_26, tail: PIN_27) -> ! {
|
|||
c.compare_b = 6248;
|
||||
pwm.set_config(&c);
|
||||
|
||||
Timer::after_millis(50).await;
|
||||
Timer::after_millis(500).await;
|
||||
LOCKOUT.store(false, core::sync::atomic::Ordering::SeqCst);
|
||||
}
|
||||
|
||||
|
|
80
server/Cargo.lock
generated
80
server/Cargo.lock
generated
|
@ -125,6 +125,15 @@ version = "2.6.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.5.0"
|
||||
|
@ -154,6 +163,16 @@ name = "common"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"sha3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -177,6 +196,16 @@ version = "0.8.20"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "deranged"
|
||||
version = "0.3.11"
|
||||
|
@ -186,6 +215,16 @@ dependencies = [
|
|||
"powerfmt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"crypto-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "embedded-io"
|
||||
version = "0.4.0"
|
||||
|
@ -302,6 +341,16 @@ dependencies = [
|
|||
"slab",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.31.1"
|
||||
|
@ -418,6 +467,15 @@ version = "1.0.14"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
|
||||
|
||||
[[package]]
|
||||
name = "keccak"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654"
|
||||
dependencies = [
|
||||
"cpufeatures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
|
@ -748,6 +806,16 @@ dependencies = [
|
|||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha3"
|
||||
version = "0.10.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60"
|
||||
dependencies = [
|
||||
"digest",
|
||||
"keccak",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sharded-slab"
|
||||
version = "0.1.7"
|
||||
|
@ -1027,6 +1095,12 @@ dependencies = [
|
|||
"tracing-log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.14"
|
||||
|
@ -1039,6 +1113,12 @@ version = "0.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
|
|
Loading…
Reference in a new issue