Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect success then disconnect immediately #177

Open
mtaweel opened this issue Oct 24, 2023 · 10 comments
Open

Connect success then disconnect immediately #177

mtaweel opened this issue Oct 24, 2023 · 10 comments

Comments

@mtaweel
Copy link

mtaweel commented Oct 24, 2023

The bluethooth thermal printer device is found successfully, but when I click on connect it connects for a 1 sec and then disconnects immediately, here are the logs:

/flutter (25274): ******************* cur device status: 12
D/BluetoothPrintPlugin(25274): start scan 
D/BluetoothAdapter(25274): isLeEnabled(): ON
D/BluetoothLeScanner(25274): onScannerRegistered() - status=0 scannerId=8 mScannerId=0
V/PhoneWindow(25274): DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@3bc37fa, this = DecorView@58e31ab[MainActivity]
D/BluetoothAdapter(25274): isLeEnabled(): ON
D/BluetoothPrintPlugin(25274): start scan 
/BluetoothAdapter(25274): isLeEnabled(): ON
D/BluetoothLeScanner(25274): onScannerRegistered() - status=0 scannerId=8 mScannerId=0
V/PhoneWindow(25274): DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@3bc37fa, this = DecorView@58e31ab[MainActivity]
D/BluetoothAdapter(25274): isLeEnabled(): ON
D/BluetoothPrintPlugin(25274): start scan 
D/BluetoothAdapter(25274): isLeEnabled(): ON
D/BluetoothLeScanner(25274): onScannerRegistered() - status=0 scannerId=8 mScannerId=0
V/PhoneWindow(25274): DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@3bc37fa, this = DecorView@58e31ab[MainActivity]
D/BluetoothAdapter(25274): isLeEnabled(): ON
/BluetoothAdapter(25274): getBluetoothService() called with no BluetoothManagerCallback
D/BluetoothPrintPlugin(25274): stateStreamHandler, current action: android.bluetooth.device.action.ACL_CONNECTED
I/flutter (25274): ******************* cur device status: 1
W/System.err(25274): java.io.IOException: read failed, socket might closed or timeout, read ret: -1
W/System.err(25274): 	at android.bluetooth.BluetoothSocket.readAll(BluetoothSocket.java:758)
W/System.err(25274): 	at android.bluetooth.BluetoothSocket.waitSocketSignal(BluetoothSocket.java:711)
W/System.err(25274): 	at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:409)
W/System.err(25274): 	at com.gprinter.io.BluetoothPort.openPort(BluetoothPort.java:58)
W/System.err(25274): 	at com.example.bluetooth_print.DeviceConnFactoryManager.openPort(DeviceConnFactoryManager.java:150)
W/System.err(25274): 	at com.example.bluetooth_print.BluetoothPrintPlugin$3.run(BluetoothPrintPlugin.java:346)
W/System.err(25274): 	at com.example.bluetooth_print.ThreadPool$1.run(ThreadPool.java:78)
W/System.err(25274): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err(25274): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/System.err(25274): 	at java.lang.Thread.run(Thread.java:923)
D/BluetoothPrintPlugin(25274): stateStreamHandler, current action: android.bluetooth.device.action.ACL_DISCONNECTED
I/flutter (25274): ******************* cur device status: 0
@danilocatalanoapsystem
Copy link

I have the same problem too

@danilocatalanoapsystem
Copy link

I managed to solve the problem. I had changed an image. In my opinion the printer memory or bluetooth is unable to receive or store data internally.

@mtaweel
Copy link
Author

mtaweel commented Oct 26, 2023

@danilocatalanoapsystem What image? Can you please elaborate more, i'm running the example app. When I search for the printer, I found it, but when I click on connect, it connects for 1 sec and then disconnects throwing the above Exception. I don't print anything yet. It just disconnects directly after connect

@jboffog
Copy link

jboffog commented Oct 27, 2023

same problem here:

D/BluetoothPrintPlugin(25057): start scan
D/BluetoothAdapter(25057): isLeEnabled(): ON
D/BluetoothLeScanner(25057): onScannerRegistered() - status=0 scannerId=10 mScannerId=0
D/BluetoothSocket(25057): mRstricteState = false
D/BluetoothAdapter(25057): isLeEnabled(): ON
D/BluetoothSocket(25057): startRecord connect mPfd = {ParcelFileDescriptor: java.io.FileDescriptor@3de5e6e}fd = 132
E/DeviceConnFactoryManager(25057): ******************* wait read
D/BluetoothSocket(25057): close() this: android.bluetooth.BluetoothSocket@c4bb3a5, channel: 6, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@395f37a, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@164072b, mSocket: android.net.LocalSocket@8085788 impl:android.net.LocalSocketImpl@168e521 fd:java.io.FileDescriptor@3de5e6e, mSocketState: CONNECTED
D/BluetoothSocket(25057): removeChangeCallback
D/BluetoothSocket(25057): startRecord close mPfd = {ParcelFileDescriptor: java.io.FileDescriptor@3de5e6e}fd = 132
W/System.err(25057): java.io.IOException: bt socket closed, read return: -1
W/System.err(25057): 	at android.bluetooth.BluetoothSocket.read(BluetoothSocket.java:620)
W/System.err(25057): 	at android.bluetooth.BluetoothInputStream.read(BluetoothInputStream.java:91)
W/System.err(25057): 	at java.io.InputStream.read(InputStream.java:205)
W/System.err(25057): 	at com.gprinter.io.BluetoothPort.readData(BluetoothPort.java:130)
D/BluetoothSocket(25057): close() this: android.bluetooth.BluetoothSocket@c4bb3a5, channel: 6, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@395f37a, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@164072b, mSocket: null, mSocketState: CLOSED
W/System.err(25057): 	at com.example.bluetooth_print.DeviceConnFactoryManager.readDataImmediately(DeviceConnFactoryManager.java:308)
D/BluetoothSocket(25057): close() this: android.bluetooth.BluetoothSocket@c4bb3a5, channel: 6, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@395f37a, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@164072b, mSocket: null, mSocketState: CLOSED
W/System.err(25057): 	at com.example.bluetooth_print.DeviceConnFactoryManager$PrinterReader.run(DeviceConnFactoryManager.java:387)
E/BluetoothPort(25057): connection device is lost
E/DeviceConnFactoryManager(25057): ******************* read 0

@biloo-dev
Copy link

Is there any update on this issue?
I have the same problem with the pin code??
Please let us know if it has been resolved. Thanks!

@ebecenek
Copy link

ebecenek commented Dec 14, 2023

I am trying to solve the same problem. I can list and select the printer but when I tap connect, it's connecting but immediatly after connection breaks. I'm using a Zebra printer with an Android 12 tablet.

I would appriciate any help.

D/BluetoothPrintPlugin( 4207): stateStreamHandler, current action: android.bluetooth.device.action.ACL_CONNECTED I/flutter ( 4207): ******************* cur device status: 1 E/DeviceConnFactoryManager( 4207): ******************* wait read D/BluetoothSocket( 4207): close() this: android.bluetooth.BluetoothSocket@43cb4e9, channel: 1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@22e356e, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@308740fmSocket: android.net.LocalSocket@902c9c impl:android.net.LocalSocketImpl@7a2b6a5 fd:java.io.FileDescriptor@c8c3a7a, mSocketState: CONNECTED W/System.err( 4207): java.io.IOException: bt socket closed, read return: -1 D/BluetoothSocket( 4207): close() this: android.bluetooth.BluetoothSocket@43cb4e9, channel: 1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@22e356e, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@308740fmSocket: null, mSocketState: CLOSED W/System.err( 4207): at android.bluetooth.BluetoothSocket.read(BluetoothSocket.java:751) D/BluetoothSocket( 4207): close() this: android.bluetooth.BluetoothSocket@43cb4e9, channel: 1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@22e356e, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@308740fmSocket: null, mSocketState: CLOSED W/System.err( 4207): at android.bluetooth.BluetoothInputStream.read(BluetoothInputStream.java:91) W/System.err( 4207): at java.io.InputStream.read(InputStream.java:101) W/System.err( 4207): at com.gprinter.io.BluetoothPort.readData(BluetoothPort.java:130) W/System.err( 4207): at com.example.bluetooth_print.DeviceConnFactoryManager.readDataImmediately(DeviceConnFactoryManager.java:308) W/System.err( 4207): at com.example.bluetooth_print.DeviceConnFactoryManager$PrinterReader.run(DeviceConnFactoryManager.java:387) E/BluetoothPort( 4207): connection device is lost

@AmanBhangre
Copy link

I am facing the same issue. Any updates would help.

@krunalagrawal
Copy link

krunalagrawal commented May 29, 2024

I am also facing this issue in old Android version. Printer connected for 1 sec and then disconnected.

@AmanBhangre
Copy link

I am also facing this issue in old Android version. Printer connected for 1 sec and then disconnected.

For me, the device was supporting V2 Bluetooth for android but the package is only supporting V4. I switched to this package named flutter_blue_plus package and it worked for me

@DedeSnrwn13
Copy link

I am also facing this issue in old Android version. Printer connected for 1 sec and then disconnected.

Yes, same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants