Skip to content

Commit

Permalink
Card scanning check is optional
Browse files Browse the repository at this point in the history
As reported in #8, it seems that card scanning is not available on all scanners.
This change makes it optional and simply returns no card scanning when the feature seems to not be available.
  • Loading branch information
Jan Rüth authored and janrueth committed May 13, 2024
1 parent 8452eb3 commit 95df68d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion es2button/src/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,20 @@ impl<'a> Listener<'a> {
self.scanner
.get_bool_value_for_key(es2command::ESKEY_DOCUMENT_LOADED)
}

fn is_card_scanning(&self) -> Result<bool, ESError> {
self.scanner
match self
.scanner
.get_bool_value_for_key(es2command::ESKEY_CARD_SCANNING)
{
// Not all scanners support card scanning, in this case,
// we get a InvalidParameter, we just report this as no card scanning
Err(ESError::InvalidParameter) => {
trace!("Got InvalidParameter for \"cardScanning\" lookup, assuming no card scanning available");
Ok(false)
}
x => x,
}
}

fn handle_button_press(&self, button: u8) -> Result<(), anyhow::Error> {
Expand Down

0 comments on commit 95df68d

Please sign in to comment.