Improve Classic card reader robustness with retry and error handling - #220
Merged
Conversation
Fixes #191 The old FareBot CEPASProtocol manually built APDU commands but omitted the Le (expected response length) byte, causing cards to reject with 6D00 (instruction not supported). Replaced with Metrodroid's approach that delegates to ISO7816Protocol.sendRequest() for proper APDU framing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements three enhancements ported from Metrodroid ClassicReader: 1. Single-byte 0x04 retry logic (Task 5A): - When block read returns single byte 0x04, reauthenticate and retry up to 3 times - Tracks successful authentication key (Key A/B) for retry - Ported from Metrodroid ClassicReader.kt lines 44-53 2. CardLostException handling (Task 5E): - New CardLostException class for card removal during read - Catch CardLostException separately from other errors - Return immediately with isPartialRead=true to preserve partial data - Ported from Metrodroid ClassicReader.kt lines 147-153 3. Added isPartialRead support to RawClassicCard: - Tracks whether card read was interrupted - Passed through to ClassicCard.create() Task 5B (Key A/B post-read fallback) marked as TODO - requires infrastructure for tracking unauthorized blocks at the raw level. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
codebutler
force-pushed
the
feat/classic-reader-improvements
branch
from
February 15, 2026 07:15
d15f045 to
cb37366
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
codebutler
force-pushed
the
feat/classic-reader-improvements
branch
from
February 15, 2026 14:32
6f4cebd to
6f6c1f5
Compare
…-improvements # Conflicts: # card/classic/src/commonMain/kotlin/com/codebutler/farebot/card/classic/ClassicCardReader.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements three enhancements ported from Metrodroid ClassicReader to improve Classic card reading robustness:
isPartialReadsupport toRawClassicCardto track interrupted readsChanges
1. CardLostException (New)
card/src/commonMain/kotlin/.../CardLostException.kt2. ClassicCardReader improvements
isPartialRead=true3. RawClassicCard enhancements
isPartialReadparameter (defaults to false)ClassicCard.create()Metrodroid References
metrodroid/.../ClassicReader.ktlines 44-53metrodroid/.../ClassicReader.ktlines 147-153metrodroid/.../ClassicReader.ktlines 118-139Testing
🤖 Generated with Claude Code