Skip to content

Commit 2f96ed8

Browse files
committed
explore: check secured read from rfid card [skip ci]
1 parent 4601cc1 commit 2f96ed8

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/rfid.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,28 @@ pub async fn rfid_task(
9898
}
9999

100100
#[cfg(not(feature = "e2e"))]
101-
let Ok(card_uid) = mfrc522
102-
.get_card(UidSize::Four)
103-
.await
104-
.map(|c| c.get_number())
105-
else {
101+
let Ok(card) = mfrc522.get_card(UidSize::Four).await else {
106102
continue;
107103
};
104+
let card_uid = card.get_number();
108105
log::info!("Card UID: {card_uid}");
109106

107+
// TODO: check read
108+
let status = mfrc522
109+
.pcd_authenticate(
110+
esp_hal_mfrc522::consts::PICCCommand::PICC_CMD_MF_AUTH_KEY_A,
111+
1,
112+
&[0x42, 0x0, 0x69, 0x12, 0x15, 0x9A], // test read key
113+
&card,
114+
)
115+
.await;
116+
if status.is_ok() {
117+
let mut buff = [0; 18];
118+
let mut byte_count = 18;
119+
let res = mfrc522.mifare_read(1, &mut buff, &mut byte_count).await;
120+
log::info!("read: {res:?}, data: {buff:#?}");
121+
}
122+
110123
let last_scan_time = (Instant::now().saturating_duration_since(last_card.1)).as_millis();
111124
if last_card.0 == card_uid && last_scan_time < 500 {
112125
log::warn!(

0 commit comments

Comments
 (0)