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

Not able to connect to inbuilt printer #155

Closed
finnkassaoy opened this issue Aug 9, 2022 · 10 comments
Closed

Not able to connect to inbuilt printer #155

finnkassaoy opened this issue Aug 9, 2022 · 10 comments

Comments

@finnkassaoy
Copy link

finnkassaoy commented Aug 9, 2022

Hello, I am using blue_thermal_printer blue_thermal_printer: ^1.2.3 package for printing in a bluetooth inbuilt thermal printer, but its not getting connected, printer is detected in the dropdown and not able to print

image

Best Regards
Shakir

@kakzaki
Copy link
Owner

kakzaki commented Aug 10, 2022 via email

@finnkassaoy
Copy link
Author

No it doesnt show any error

@oatlpk
Copy link

oatlpk commented Aug 15, 2022

Hi I am also having this trouble. Has anyone found a fix to this yet? No errors shown here as well.

@nipzyaw88
Copy link

void _connect() async { if (_device != null) { bluetooth.isConnected.then((isConnected) { if (isConnected == false) { bluetooth.connect(_device!).catchError((error) { setState(() => _connected = false); }); setState(() => _connected = true); } else { ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Already connected'))); } }); } else { show('No device selected.'); } }

maybe you should change _connect void like this. for me it's working

@ot-repo
Copy link

ot-repo commented Sep 10, 2022

Hi @nipzyaw88 I have the same problem. It was working fine, after I upgraded my flutter to 3.3.0 it stopped working.

I have not really understood your solution and how it should help.

I really appreciate it, if you can explain it more.

Thank you.

@nipzyaw88
Copy link

nipzyaw88 commented Sep 10, 2022

Hi @nipzyaw88 I have the same problem. It was working fine, after I upgraded my flutter to 3.3.0 it stopped working.

I have not really understood your solution and how it should help.

I really appreciate it, if you can explain it more.

Thank you.

well i didn't try this plugin on 3.3.0 yet. i got 2.10.5 n it's working fine. anyway is there any error? please describe what error you got. maybe i can help you.

by the way the change i've made is on the _connect void the if (isConnected == true) and i set it to false

@ot-repo
Copy link

ot-repo commented Sep 10, 2022

That's the stack trace when the connect method is called:

E/BThermalPrinterPlugin(26525): Attempt to invoke virtual method 'int java.io.InputStream.read(byte[], int, int)' on a null object reference E/BThermalPrinterPlugin(26525): java.lang.NullPointerException: Attempt to invoke virtual method 'int java.io.InputStream.read(byte[], int, int)' on a null object reference E/BThermalPrinterPlugin(26525): at android.bluetooth.BluetoothSocket.readAll(BluetoothSocket.java:803) E/BThermalPrinterPlugin(26525): at android.bluetooth.BluetoothSocket.readInt(BluetoothSocket.java:819) E/BThermalPrinterPlugin(26525): at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:417) E/BThermalPrinterPlugin(26525): at id.kakzaki.blue_thermal_printer.BlueThermalPrinterPlugin.lambda$connect$1$BlueThermalPrinterPlugin(BlueThermalPrinterPlugin.java:531) E/BThermalPrinterPlugin(26525): at id.kakzaki.blue_thermal_printer.-$$Lambda$BlueThermalPrinterPlugin$Ahw9MM_9K6f9UCVqtrNy_jHybcU.run(Unknown Source:6) E/BThermalPrinterPlugin(26525): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) E/BThermalPrinterPlugin(26525): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) E/BThermalPrinterPlugin(26525): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) E/BThermalPrinterPlugin(26525): at java.lang.Thread.run(Thread.java:764)

@ot-repo
Copy link

ot-repo commented Sep 11, 2022

Hi @nipzyaw88 I have the same problem. It was working fine, after I upgraded my flutter to 3.3.0 it stopped working.
I have not really understood your solution and how it should help.
I really appreciate it, if you can explain it more.
Thank you.

well i didn't try this plugin on 3.3.0 yet. i got 2.10.5 n it's working fine. anyway is there any error? please describe what error you got. maybe i can help you.

by the way the change i've made is on the _connect void the if (isConnected == true) and i set it to false

I tried it with an external printer and it's working fine. It seems that only the internal printer has a problem.

When I try with an internal app coming with the device, I could print something. So the printers is not broken. Only my app cannot access it anymore.

@kakzaki
Copy link
Owner

kakzaki commented Oct 11, 2022 via email

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

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

No branches or pull requests

5 participants