kakzaki / blue_thermal_printer

Working with thermal printer via bluetooth (Flutter)
MIT License
164 stars 205 forks source link

Not able to connect to inbuilt printer #155

Closed finnkassaoy closed 1 year ago

finnkassaoy commented 2 years ago

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 commented 2 years ago

Is there any error message?

Pada tanggal Sel, 9 Agu 2022 16:21, finnkassaoy @.***> menulis:

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

[image: image] https://user-images.githubusercontent.com/110221089/183613462-85abeb5b-1667-4c97-9da3-9e1ca331149a.png

Best Regards Shakir

— Reply to this email directly, view it on GitHub https://github.com/kakzaki/blue_thermal_printer/issues/155, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACYBC2ZJNCRW2BQIBQBODQDVYIPKNANCNFSM56ABOQQQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

finnkassaoy commented 2 years ago

No it doesnt show any error

oatlpk commented 2 years ago

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

nipzyaw88 commented 2 years ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Is the device connected to android system?

Pada tanggal Rab, 10 Agu 2022 13:13, finnkassaoy @.***> menulis:

No it doesnt show any error

— Reply to this email directly, view it on GitHub https://github.com/kakzaki/blue_thermal_printer/issues/155#issuecomment-1210206801, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACYBC24VY3JGFWTRO7MR6WDVYNB73ANCNFSM56ABOQQQ . You are receiving this because you commented.Message ID: @.***>

github-actions[bot] commented 1 year ago

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.