Skip to content

Commit 5ac649a

Browse files
fix: ignore cards using unsupported protocols (#1)
1 parent 537fd1a commit 5ac649a

File tree

5 files changed

+23
-18
lines changed

5 files changed

+23
-18
lines changed

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [2.1.4] - 2024-02-21
10+
### Fixed
11+
- Cards using unsupported contactless protocols are now ignored.
12+
913
## [2.1.3] - 2024-02-06
1014
### Fixed
1115
- Card scanning process. The RF module is now enabled/disabled in addition to the
@@ -51,8 +55,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5155
## [1.0.0] - 2020-12-18
5256
This is the initial release.
5357

54-
[unreleased]: https://github.com/calypsonet/keyple-plugin-cna-bluebird-specific-nfc-java-lib/compare/2.1.3...HEAD
55-
[2.1.3]: https://github.com/calypsonet/keyple-plugin-cna-bluebird-specific-nfc-java-lib/compare/2.1.3...2.1.2
58+
[unreleased]: https://github.com/calypsonet/keyple-plugin-cna-bluebird-specific-nfc-java-lib/compare/2.1.4...HEAD
59+
[2.1.4]: https://github.com/calypsonet/keyple-plugin-cna-bluebird-specific-nfc-java-lib/compare/2.1.3...2.1.4
60+
[2.1.3]: https://github.com/calypsonet/keyple-plugin-cna-bluebird-specific-nfc-java-lib/compare/2.1.2...2.1.3
5661
[2.1.2]: https://github.com/calypsonet/keyple-plugin-cna-bluebird-specific-nfc-java-lib/compare/2.1.1...2.1.2
5762
[2.1.1]: https://github.com/calypsonet/keyple-plugin-cna-bluebird-specific-nfc-java-lib/compare/2.1.0...2.1.1
5863
[2.1.0]: https://github.com/calypsonet/keyple-plugin-cna-bluebird-specific-nfc-java-lib/compare/2.0.0...2.1.0

bluebird-plugin-mock/src/main/kotlin/org/calypsonet/keyple/plugin/bluebird/BluebirdSupportContactlessProtocols.kt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,19 @@ package org.calypsonet.keyple.plugin.bluebird
1313

1414
enum class BluebirdSupportContactlessProtocols constructor(val value: Int) {
1515
ISO_14443_4_A(0x01),
16+
ISO_14443_4_A_SKY_ECP(0x81),
1617
ISO_14443_4_B(0x02),
17-
INNOVATRON_B_PRIME(0x04),
18-
SRT512(0x08),
19-
MIFARE_CLASSIC(0x10),
20-
MIFARE_ULTRALIGHT(0x20),
21-
ISO14443_4_SKY_ECP_A(0x81),
22-
ISO14443_4_SKY_ECP_B(0x82);
18+
ISO_14443_4_B_SKY_ECP(0x82),
19+
INNOVATRON_B_PRIME(0x04);
2320

2421
companion object {
25-
fun fromValue(value: Int): BluebirdSupportContactlessProtocols {
22+
fun fromValue(value: Int): BluebirdSupportContactlessProtocols? {
2623
for (protocol in values()) {
2724
if (protocol.value == value) {
2825
return protocol
2926
}
3027
}
31-
throw IllegalArgumentException("BluebirdSupportContactlessProtocols '$value' is not defined")
28+
return null
3229
}
3330
}
3431
}

bluebird-plugin/src/main/kotlin/org/calypsonet/keyple/plugin/bluebird/BluebirdContactlessReaderAdapter.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,14 @@ internal class BluebirdContactlessReaderAdapter(activity: Activity) :
382382
if (ExtNfcReader.Broadcast.EXTNFC_DETECTED_ACTION == intent.action) {
383383
listener?.let {
384384
val cardType = intent.getIntExtra(ExtNfcReader.Broadcast.EXTNFC_CARD_TYPE_KEY, -1)
385-
val tag =
386-
Tag(
387-
BluebirdSupportContactlessProtocols.fromValue(cardType),
388-
intent.getByteArrayExtra(ExtNfcReader.Broadcast.EXTNFC_CARD_DATA_KEY))
389-
it(NfcResultSuccess(tag))
385+
val protocol = BluebirdSupportContactlessProtocols.fromValue(cardType)
386+
protocol?.let {
387+
val tag =
388+
Tag(
389+
protocol,
390+
intent.getByteArrayExtra(ExtNfcReader.Broadcast.EXTNFC_CARD_DATA_KEY))
391+
it(NfcResultSuccess(tag))
392+
}
390393
}
391394
}
392395
}

bluebird-plugin/src/main/kotlin/org/calypsonet/keyple/plugin/bluebird/BluebirdSupportContactlessProtocols.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ enum class BluebirdSupportContactlessProtocols constructor(val value: Int) {
2626
INNOVATRON_B_PRIME(0x04);
2727

2828
companion object {
29-
fun fromValue(value: Int): BluebirdSupportContactlessProtocols {
29+
fun fromValue(value: Int): BluebirdSupportContactlessProtocols? {
3030
for (protocol in values()) {
3131
if (protocol.value == value) {
3232
return protocol
3333
}
3434
}
35-
throw IllegalArgumentException("BluebirdSupportContactlessProtocols '$value' is not defined")
35+
return null
3636
}
3737
}
3838
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
group = org.calypsonet.keyple
22
title = Keyple Plugin CNA Bluebird Specific NFC Java Lib
33
description = Keyple add-on to manage Bluebird Specific NFC readers
4-
version = 2.1.3
4+
version = 2.1.4
55
archivesBaseName = keyple-plugin-cna-bluebird-specific-nfc-java-lib
66

77
javaSourceLevel = 1.6

0 commit comments

Comments
 (0)