Android Question Bluetooth Scanner not connecting when SPP mode

EduardoElias

Well-Known Member
Licensed User
Longtime User
Hi there,

I have a scanner that works fine with my app in a Samsung Tab E tablet. Works great.

The same scanner on an older Motorola Xoom does not connect with SPP mode.

Turning it to HID mode it works fine, however it is bad because it just restart my app evertime the scanner is turned off or on.

Part of the code that I am using is this one: (copied from the forum and I use just fine in other places)

B4X:
Sub Class_Globals
    Dim BTMac                 As String
    Dim Connected             As Boolean
    
    Private OSerial         As Serial
    Private FOnNewData      As Object = Null

    Dim Scanner             As AsyncStreams
end sub

Public Sub Connect
    If BTMac = "" Then
        ToastMessageShow("no scanner paired", False)
    Else
        If Not(OSerial.IsEnabled) Then
            ToastMessageShow("bluetooth off", True)
            Connected = False
            Return
        End If

        If Not(Connected) Then
            OSerial.Connect(BTMac) 'convert the name to mac address and connect
        End If
    End If
End Sub

Private Sub OnSerial_Connected (Success As Boolean)
    Try
        Connected = Success
        If Success Then
            Scanner.Initialize(OSerial.InputStream, OSerial.OutputStream, "Scanner")
        Else
            Log("not connected")
        End If
    Catch
        Connected = False
    End Try
End Sub

In this Motorola Tablet with the Scanner in SPP and paired (it does pair just fine) it finds the scanner MAC and when trying to connec it always gets OnSerial_Connected with success = false. Same code works fine with same scanner in a samsung tablet.

Any ideas?
 
Top