fixed netcode
This commit is contained in:
parent
1e8208b1e8
commit
ead78021d7
3 changed files with 10 additions and 5 deletions
|
@ -186,9 +186,8 @@ async fn main(spawner: Spawner) {
|
||||||
pwm.set_config(&c);
|
pwm.set_config(&c);
|
||||||
},
|
},
|
||||||
'B' => {
|
'B' => {
|
||||||
let mut buf: [u8;8] = [0;8];
|
let buf: [u8;8] = hex::FromHex::from_hex(segs.next().unwrap()).unwrap();
|
||||||
buf.copy_from_slice(segs.next().unwrap());
|
let card: u64 = u64::from_ne_bytes(buf);
|
||||||
let card = u64::from_ne_bytes(buf);
|
|
||||||
info!("card {card:#16x}");
|
info!("card {card:#16x}");
|
||||||
|
|
||||||
open_door(&mut c, &mut pwm).await;
|
open_door(&mut c, &mut pwm).await;
|
||||||
|
|
2
outside/Cargo.lock
generated
2
outside/Cargo.lock
generated
|
@ -730,6 +730,7 @@ source = "git+https://github.com/embassy-rs/embassy#0ede8479dc4c6a58cfab0a5d4df4
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"critical-section",
|
"critical-section",
|
||||||
|
"defmt",
|
||||||
"embedded-io-async",
|
"embedded-io-async",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"heapless 0.8.0",
|
"heapless 0.8.0",
|
||||||
|
@ -1556,6 +1557,7 @@ dependencies = [
|
||||||
"embassy-net",
|
"embassy-net",
|
||||||
"embassy-net-wiznet",
|
"embassy-net-wiznet",
|
||||||
"embassy-rp",
|
"embassy-rp",
|
||||||
|
"embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy)",
|
||||||
"embassy-time",
|
"embassy-time",
|
||||||
"embassy-usb",
|
"embassy-usb",
|
||||||
"embassy-usb-logger",
|
"embassy-usb-logger",
|
||||||
|
|
|
@ -225,8 +225,12 @@ async fn main(spawner: Spawner) {
|
||||||
info!("Connected to {:?}", socket.remote_endpoint());
|
info!("Connected to {:?}", socket.remote_endpoint());
|
||||||
control.gpio_set(0, true).await;
|
control.gpio_set(0, true).await;
|
||||||
|
|
||||||
socket.write(b"C ").await.unwrap();
|
let mut data: [u8;18] = [b' ';18];
|
||||||
socket.write(&card.to_ne_bytes()).await.unwrap();
|
data[0] = b'B';
|
||||||
|
data[1] = b' ';
|
||||||
|
hex::encode_to_slice(&card.to_ne_bytes(), &mut data[2..]).unwrap();
|
||||||
|
|
||||||
|
socket.write_all(&data).await.unwrap();
|
||||||
info!("wrote to {:?}", socket.remote_endpoint());
|
info!("wrote to {:?}", socket.remote_endpoint());
|
||||||
|
|
||||||
socket.close();
|
socket.close();
|
||||||
|
|
Loading…
Reference in a new issue