#zishaansunderji - Android Terminal

1 messages ยท Page 1 of 1 (latest)

north pewter
#

Hello! Just starting a thread for you -- I'll review and respond as soon as I can ๐Ÿ™‚

eager flume
#

Sounds good!

#

Btw this is the stacktrace:

2022-05-20 10:39:19.966 724-10809/com.paywithtango.tangotablet E/StripeTerminal: Bluetooth unexpectedly disconnected during operation.
    com.stripe.stripeterminal.external.models.TerminalException: Bluetooth unexpectedly disconnected during operation.
        at com.stripe.stripeterminal.adapter.BbposAdapter.register$lambda-17(BbposAdapter.kt:450)
        at com.stripe.stripeterminal.adapter.BbposAdapter.lambda$-pG0tX_wqZPkkrcRZHx8HWUdO44(Unknown Source:0)
        at com.stripe.stripeterminal.adapter.-$$Lambda$BbposAdapter$-pG0tX_wqZPkkrcRZHx8HWUdO44.accept(Unknown Source:4)
        at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:63)
        at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeOnObserver.onNext(ObservableSubscribeOn.java:58)
        at io.reactivex.subjects.PublishSubject$PublishDisposable.onNext(PublishSubject.java:308)
        at io.reactivex.subjects.PublishSubject.onNext(PublishSubject.java:228)
        at com.stripe.core.hardware.reactive.status.ReactiveReaderStatusListener.handleReaderDisconnect(ReactiveReaderStatusListener.kt:69)
        at com.stripe.core.bbpos.BBPOSControllerListener.onError(BBPOSControllerListener.kt:84)
        at com.stripe.bbpos.bbdevice.BBDeviceController$aaa023zz.run(SourceFile:8)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:246)
        at android.app.ActivityThread.main(ActivityThread.java:8653)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
north pewter
#

Is the reader paired with the device via the bluetooth settings?

eager flume
#

I was told that we should pair it from the app

#

There were issues in the past when we linked it in Android before pairing it from the app

north pewter
#

Yes thats right, just wanted to check. You should not use the device settings.

eager flume
#

Oh gotcha! Sounds good!

north pewter
#

Which reader is this?

eager flume
#

It's the Wisepad 3

north pewter
#

Is this happening consistently / reproducibly, or intermittently?

eager flume
#

It's happening consistently

#

I've not got a successful connection for bluetooth yet

#

I did update the way we do connect - but it should work just the same

north pewter
#

Ok just asking for some help with this - bear with me ๐Ÿ™‚

eager flume
#

Haha no rush ๐Ÿ™‚

#

Actually I think after I connected to it - it saved the bluetooth reader in my android bluetooth settings under "Paired Devices" - so after hitting forget device - it connected to the reader

#

But unfortunately, after it connected, I went back to Android and saw it again under paired devices

#

Is there a way to make sure it doesn't end up there lol?

worldly hearth
#

Hi ๐Ÿ‘‹ I'm stepping in for @north pewter

#

Is it possible to see the code you are using for discovering & connecting to the reader?

eager flume
#

Thanks for your help @north pewter!

#

Yeah for sure!

#
    fun discoverReaders(location: String?) {

        // Change the location in the case of internet readers with QR Code linking
        if (location != "") {
            locationId = location
        }

        var discoveryConfiguration: DiscoveryConfiguration? = null;
        discoveryConfiguration = if (businessUsesInternetReaders) {
            DiscoveryConfiguration(5, DiscoveryMethod.INTERNET, false, locationId)
        } else {
            DiscoveryConfiguration(5, DiscoveryMethod.BLUETOOTH_SCAN, false)
        }

        try {
            val statusCallback = object : com.stripe.stripeterminal.external.callable.Callback {
                override fun onSuccess() {
                    pendingDiscoverReaders = null
                    val readerCompletionResponse = Arguments.createMap()
                    sendEvent(constants.EVENT_READER_DISCOVERY_COMPLETION, readerCompletionResponse)
                }

                override fun onFailure(@Nonnull e: TerminalException) {
                    pendingDiscoverReaders = null
                    val errorMap = Arguments.createMap()
                    errorMap.putString(constants.ERROR, e.errorMessage)
                    sendEvent(constants.EVENT_READER_DISCOVERY_COMPLETION, errorMap)
                }

            }
            abortDiscoverReaders()
            pendingDiscoverReaders = Terminal.getInstance().discoverReaders(discoveryConfiguration, this, statusCallback)

        } catch (e: Exception) {
            e.printStackTrace()
            if (e.message != null) {
                val writableMap = Arguments.createMap()
                writableMap.putString(constants.ERROR, e.message)
                sendEvent(constants.EVENT_READER_DISCOVERY_COMPLETION, writableMap)
            }
        }
    }
#

So this is the discovery process

#

And after getting the result from onUpdateDiscoveredReaders with a list of readers

worldly hearth
#

Okay so you mentioned you updated the way you handle connecting to the reader. Were you able to successfully get a connection prior to the update?

eager flume
#

Yupp so after removing the reader from "Paired Devices" I got it to connect briefly for like 3O seconds successfully

#

And then I got this message:

E/StripeTerminal: discoverReaders must be called before activateReader
#

I appreciate you helping me look into this! I know it's difficult to debug this case with such little info lol

worldly hearth
#

Yeah the bluetooth readers will not function properly if paired using the device settings. All connect and disconnect operations need to be performed by your Android application. Can I ask why you are calling disconnectReader() if selectedReader != null?

eager flume
#

Yepp! The selectedReader is the reader from the list with the serial number that is desired - but if a previously connected reader was connected - it's to unpair with that reader

#

So my disconnect reader is actually this:

    fun disconnectReader() {
        if (Terminal.getInstance().connectedReader == null) {
            connectedReaderSerialNumber = null
            sendEvent(constants.EVENT_READER_DISCONNECTION_COMPLETION, Arguments.createMap())
        } else {
            Terminal.getInstance().disconnectReader(object : com.stripe.stripeterminal.external.callable.Callback {
                override fun onSuccess() {
                    connectedReaderSerialNumber = null
                    sendEvent(constants.EVENT_READER_DISCONNECTION_COMPLETION, Arguments.createMap())
                }

                override fun onFailure(@Nonnull e: TerminalException) {
                    val errorMap = Arguments.createMap()
                    errorMap.putString(constants.ERROR, e.errorMessage)
                    sendEvent(constants.EVENT_READER_DISCONNECTION_COMPLETION, errorMap)
                }
            })
        }
    }
#

So it only does anything if Terminal.getInstance().connectedReader != null

worldly hearth
#

Thank you for providing all of this. Okay so this situation is a bit more complex than I think we can easily debug here in Discord (we usually only have 1 person staffing the channel at a time). I think I saw you sent in a Support ticket with the stack trace.

#

I'm going to respond to that ticket asking for more information and if you could provide the code you shared here along with the code you are using to handle disconnects that would be super helpful

eager flume
#

Awesome! I appreciate you taking the time ๐Ÿ™‚ I'll put in the code as additional info to hopefully resolve this!