Skip to content

Commit 2212c8f

Browse files
committed
acr122u: return None instead of error on no card.
1 parent e0b0e3d commit 2212c8f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

rnfc-acr122u/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ impl Device {
120120
Ok(())
121121
}
122122

123-
pub async fn poll(&mut self) -> Result<Card<'_>, Error> {
123+
pub async fn poll(&mut self) -> Result<Option<Card<'_>>, Error> {
124124
let res = self.pn53x_cmd(0x4a, &[0x01, 0x00]).await?;
125125

126126
if res[0] != 0x01 {
127-
return Err(Error::other("no card present"));
127+
return Ok(None);
128128
}
129129
assert!(res[1] == 0x01);
130130

@@ -140,13 +140,13 @@ impl Device {
140140
trace!("uid: {:02x?}", uid);
141141
trace!("ats: {:02x?}", ats);
142142

143-
Ok(Card {
143+
Ok(Some(Card {
144144
dev: self,
145145
atqa,
146146
sak,
147147
uid,
148148
ats,
149-
})
149+
}))
150150
}
151151

152152
async fn pn53x_cmd(&mut self, code: u8, data: &[u8]) -> Result<Vec<u8>, Error> {

0 commit comments

Comments
 (0)