Skip to content

Commit 753a4ed

Browse files
fix: disable nfc reader module when stopping card detection to save energy
1 parent 8f648f0 commit 753a4ed

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,12 @@ internal class BluebirdContactlessReaderAdapter(activity: Activity) :
292292
/** Start NFC reader and receiver scan */
293293
private fun startScan(pollingProtocols: Int, listener: (NfcResult) -> Unit) {
294294
try {
295+
nfcReader.enable(true)
295296
nfcBroadcastReceiver.listener = listener
296297
nfcReader.cardTypeForScan = pollingProtocols
297298
var status = nfcReader.BBextNfcCarrierOn()
298299
if (status != ExtNfcReader.ResultCode.SUCCESS) {
299-
Timber.e("Error while setting the RF field on")
300+
Timber.d("Error while setting the RF field on")
300301
}
301302
status = nfcReader.startScan()
302303
// If the reader is already started -> stop it then re-start it
@@ -348,12 +349,14 @@ internal class BluebirdContactlessReaderAdapter(activity: Activity) :
348349
Timber.d("Stop card scan")
349350
var status = nfcReader.stopScan()
350351
if (status != ExtNfcReader.ResultCode.SUCCESS) {
351-
Timber.e("Error while stopping the scan")
352+
Timber.d("Error while stopping the scan")
352353
}
353354
status = nfcReader.BBextNfcCarrierOff()
354355
if (status != ExtNfcReader.ResultCode.SUCCESS) {
355-
Timber.e("Error while setting the RF field off")
356+
Timber.d("Error while setting the RF field off")
356357
}
358+
nfcReader.disconnect()
359+
nfcReader.enable(false)
357360
nfcBroadcastReceiver.unregister()
358361
}
359362

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.2
4+
version = 2.1.3-SNAPSHOT
55
archivesBaseName = keyple-plugin-cna-bluebird-specific-nfc-java-lib
66

77
javaSourceLevel = 1.6

0 commit comments

Comments
 (0)