Printing image via CoreBluetooth is slow

Dear friends,


I am creating an App, that prints to thermal printer over Bluetooth (BLE) connection. I am able to print images, but printing is very slow and images have lines in it.


I am creating a single data packet, which includes printer command (standard ESC/POS commands) and image data and printing it using this method:

writeValue: forCharacteristic: type:


I have observed that when I print same data using socket connection (to a wifi printer), it prints correctly.


Please suggest


Thanks,

Dipak

  • Any luck on this ? I'm also facing the exact same issue.

Add a Comment

Replies

Hi Dipak,


There's not enough information to be able to provide any guidance here. The error in printing is likely due to wrong or missing data being sent or how the printer expects it. It would be best for you to use a sniffer to view what's being sent and how, but without any details on the printer I don't think anyone could tell you what to do.


Regards,

Gustavo


====================================

ARGENOX

Wireless Connecitivity Experts

Bluetooth, BLE, Wi-Fi

www.argenox.com

info@argenox.com

====================================

Hi Gustavo,


Thanks for your reply. I would try to explain the task in my hand and the process that I am following. Finally I would explain the error.


I am developing an iOS app, which will print images on a thermal printer via Bluetooth. I am doing following steps to print the image:

  • Connection
    • Discovering nearby device (in my case a Bluetooth printer, which is BLE enable)
    • Connecting to discovered device.
    • Finding services of connected device.
    • Finding writable characterinstic from found services.
  • Printing
    • Converting image into grayscale (as thermal printer prints inly black-n-white).
    • Packing pixels into black and white formats
    • Adding printer specific command (which is 8 byte - 0x1d, 0x76, 0x30, 0x00, (bytesPerLine%256), (bytesPerLine/256), (height%256), (height/256)) to buffer array.
    • Adding image bytes at the end of buffer array.
    • Converting it to NSData and sending it to connecting device by calling "writeValue: forCharacteristic: type:" method.

Image is being printed successfully, but the problem is: printing is very slow (compared to printing from Android app) and printed images have horizontal lines in it.


Note that same packet prints correctly on a wifi printer (printed by connecting to socet and writing data to outputstream).


Let me know, if I was able to explain the problem or you need more clarifycation.


Thanks,

Dipak

Hi Dipak

Are you still facing the issue?
how about printing via wifi, can it be faster?

Regards,
Tipi

HI @dipakmishra

Can you share code for Print UIImage?