ekasetiawans / flutter_bluetooth_printer_plugin

MIT License
21 stars 36 forks source link

iOS print issues #8

Open putheng opened 1 year ago

putheng commented 1 year ago

Hi there, Thank you for your package. I have an issue with ios printing as you see below image the top one is printed by an Android device and the bottom one is printed by an iOS device (iPhone 10) I really don't know where the white line comes from and how to solve it. By the way, why do Android devices print faster than iOS devices?

photo_2022-12-03_23-49-01

thank you

ekasetiawans commented 1 year ago

hi, I have updated the ios implementation, could you check it?

M6268 commented 1 year ago

Now it does not print at all. Worked till before updating package. Now libGSDK.a is removed.

putheng commented 1 year ago

Hi, Thank you for keeping up to date with this package. I just discover that not only ios devices but also some Android devices get the same issues

Like this kind of machine photo_2022-12-13_15-24-45 I have tested 2 machines. I'm not sure if it is because of devices or the code issues, for the receipt widget, I just follow the example

ekasetiawans commented 1 year ago

@M6268 i decided to implement from the CoreBluetooth instead libGSDK. Its happened to the example project?

M6268 commented 1 year ago

there is no logs from IOS side what is happening.

ekasetiawans commented 1 year ago

@putheng is the device use bluetooth connection to the printer?

putheng commented 1 year ago

@ekasetiawans yes it does

M6268 commented 1 year ago

Hi, Thank you for keeping up to date with this package. I just discover that not only ios devices but also some Android devices get the same issues

Like this kind of machine photo_2022-12-13_15-24-45 I have tested 2 machines. I'm not sure if it is because of devices or the code issues, for the receipt widget, I just follow the example

Usually android printers wont work by default, you have to manually add UUID of the device , it can be found from sunmi android sdk

M6268 commented 1 year ago

@M6268 i decided to implement from the CoreBluetooth instead libGSDK. Its happened to the example project?

i haven;t tried the example yet, i will update

ekasetiawans commented 1 year ago

@M6268 could you debug the example project from the xcode?

putheng commented 1 year ago

@M6268 it does print but it got a white line through the text as I mentioned above image

M6268 commented 1 year ago

@M6268 could you debug the example project from the xcode?

yes

M6268 commented 1 year ago

2022-12-13 14:13:49.257944+0530 Runner[50448:2804378] Metal API Validation Enabled 2022-12-13 14:13:49.515916+0530 Runner[50448:2804378] Warning: Unable to create restoration in progress marker file 2022-12-13 14:13:49.562128+0530 Runner[50448:2804878] flutter: The Dart VM service is listening on http://127.0.0.1:49422/tG5MTzXIxcs=/ 2022-12-13 14:13:50.012529+0530 Runner[50448:2804852] fopen failed for data file: errno = 2 (No such file or directory) 2022-12-13 14:13:50.012594+0530 Runner[50448:2804852] Errors found! Invalidating cache... 2022-12-13 14:13:50.044212+0530 Runner[50448:2804851] fopen failed for data file: errno = 2 (No such file or directory) 2022-12-13 14:13:50.044243+0530 Runner[50448:2804851] Errors found! Invalidating cache...

This is the only thing found from console

M6268 commented 1 year ago

It connects with the printer , in my printer connectivity LED is on after few seconds it get disconnected.

ekasetiawans commented 1 year ago

@M6268 it does print but it got a white line through the text as I mentioned above image

Its hard for me to find out the cause, its seems like the raster size is too big for your printer, but I'm not sure about that.

M6268 commented 1 year ago

Text printing is working fine. Image printing with a single line of text in receipt fails

ekasetiawans commented 1 year ago

Text printing is working fine. Image printing with a single line of text in receipt fails

https://github.com/ekasetiawans/flutter_bluetooth_printer_plugin/blob/3e2975368fcb5bfb87e3c75eae5f8f9742ec8aac/packages/flutter_bluetooth_printer/lib/src/flutter_bluetooth_printer_impl.dart#L60 You can try to change this by hardcode to lower value.

M6268 commented 1 year ago
Screenshot 2022-12-13 at 5 41 04 PM

This is the error getting from Xcode.

ekasetiawans commented 1 year ago

hi @M6268, I have added option useImageRaster on print method, it will use an obsolete method to raster the image, could you try it?

M6268 commented 1 year ago

hi @M6268, I have added option useImageRaster on print method, it will use an obsolete method to raster the image, could you try it?

Sure, i will update, is the above error is related to that ?

ekasetiawans commented 1 year ago

hi @M6268, I have added option useImageRaster on print method, it will use an obsolete method to raster the image, could you try it?

Sure, i will update, is the above error is related to that ?

I'm not sure enough, but its seems error while sending data to the printer.

M6268 commented 1 year ago

Still Error Domain=CBATTErrorDomain Code=13 "The value's length is invalid." UserInfo={NSLocalizedDescription=The value's length is invalid.}

putheng commented 1 year ago

Two left are from iPhone X iOS 15.6.1 and the right side is from Redmi S2 Android 9PKQ1 photo_2022-12-13_20-27-43

ekasetiawans commented 1 year ago

Still Error Domain=CBATTErrorDomain Code=13 "The value's length is invalid." UserInfo={NSLocalizedDescription=The value's length is invalid.}

I think it caused by limitation of BLE payload length. You can try change the size here (total/5) with smaller value depending your device for example explicit to 30 bytes each payload.

https://github.com/ekasetiawans/flutter_bluetooth_printer_plugin/blob/95f507d42614508d6c69dc210bb02aca5c912bcb/packages/flutter_bluetooth_printer/ios/Classes/Bluetooth/BluetoothPrinterManager.swift#L293

ekasetiawans commented 1 year ago

Two left are from iPhone X iOS 15.6.1 and the right side is from Redmi S2 Android 9PKQ1 photo_2022-12-13_20-27-43

Did you tried with the latest version I'd recently published?

putheng commented 1 year ago

Two left are from iPhone X iOS 15.6.1 and the right side is from Redmi S2 Android 9PKQ1 photo_2022-12-13_20-27-43

Did you tried with the latest version I'd recently published?

Yes I do, I just clone and run it

ekasetiawans commented 1 year ago

https://stackoverflow.com/questions/24349945/maximum-data-size-when-sending-data-via-btle-on-ios

It seems the data was corrupted while being transmited to the device because there are difference maximum supported payload length on every device.

I think this is related issue, i will implement it when I have enough time.

M6268 commented 1 year ago

Still Error Domain=CBATTErrorDomain Code=13 "The value's length is invalid." UserInfo={NSLocalizedDescription=The value's length is invalid.}

I think it caused by limitation of BLE payload length. You can try change the size here (total/5) with smaller value depending your device for example explicit to 30 bytes each payload.

https://github.com/ekasetiawans/flutter_bluetooth_printer_plugin/blob/95f507d42614508d6c69dc210bb02aca5c912bcb/packages/flutter_bluetooth_printer/ios/Classes/Bluetooth/BluetoothPrinterManager.swift#L293

Thanks for idea. size set to 50. and working .

ekasetiawans commented 1 year ago

Still Error Domain=CBATTErrorDomain Code=13 "The value's length is invalid." UserInfo={NSLocalizedDescription=The value's length is invalid.}

I think it caused by limitation of BLE payload length. You can try change the size here (total/5) with smaller value depending your device for example explicit to 30 bytes each payload. https://github.com/ekasetiawans/flutter_bluetooth_printer_plugin/blob/95f507d42614508d6c69dc210bb02aca5c912bcb/packages/flutter_bluetooth_printer/ios/Classes/Bluetooth/BluetoothPrinterManager.swift#L293

Thanks for idea. size set to 50. and working .

Yeayy!! Now we should think to make it flexible depending on the device

M6268 commented 1 year ago

Yes, but still the same slow printing !

ekasetiawans commented 1 year ago

Yes, but still the same slow printing !

Yes, because the payload is more smaller on every write

M6268 commented 1 year ago

Yes, but still the same slow printing !

Yes, because the payload is more smaller on every write

Trying to make chunk size dynamic. i will update the results.

ekasetiawans commented 1 year ago

Yes, but still the same slow printing !

Yes, because the payload is more smaller on every write

Trying to make chunk size dynamic. i will update the results.

Cool thank you

ekasetiawans commented 1 year ago

hi @M6268 I have updated the chunkSize based on peripheral, please check it if you have time

M6268 commented 1 year ago

hi @M6268 I have updated the chunkSize based on peripheral, please check it if you have time

In my test it is broken again. I can give details by tomorrow.(reverting to my patch again, passing size from flutter)

putheng commented 1 year ago

https://stackoverflow.com/questions/24349945/maximum-data-size-when-sending-data-via-btle-on-ios

It seems the data was corrupted while being transmited to the device because there are difference maximum supported payload length on every device.

I think this is related issue, i will implement it when I have enough time.

Ohh, because I have zero knowledge of iOS so waiting for your update. By the way, how can we implement auto paper cut?

putheng commented 1 year ago

For iOS print getting better now, but still abit more issue photo_2022-12-14_04-36-26

ekasetiawans commented 1 year ago

For iOS print getting better now, but still abit more issue photo_2022-12-14_04-36-26

could you try to run the example project, and print the example receipt?