bitbank2 / Print2BLE

MacOS app which allows drag and drop of images to BLE thermal printers
Apache License 2.0
67 stars 11 forks source link

Add support for Royal PT-300 #14

Closed lukevp closed 1 year ago

lukevp commented 1 year ago

I have a Royal PT-300 receipt printer, which supports both Classic Bluetooth and BLE. In order to make BLE work, I had to connect to the printer in setup mode and set the printer to "label mode". Once I did that, the printer started broadcasting as Printer_{first 4 hex of MAC address} i.e. Printer_AAAA. I added Printer_ to the list of valid printer names, and I was able to print images from my Mac using your library without any issues, so adding Printer_ to this list should be an easy way to add support for the Royal PT-300.

One thing I noticed is with larger images, I saw some buffer overrun issues. One image printed with part of it sheared off, and another printed garbled text. This usually happens when the source device's buffer is overwhelmed or when some data is written to the stream but is lost, which results in the printer's ESC/POS commands getting offset. I wonder if there's some issue with the BLE implementation where it's losing bits somewhere, or if this is specific to my printer (and likely a buffering issue)? I don't see the same issue using my library ESCPOS_NET and printing over WiFi to the printer, but the WiFi chip and the BLE chip may have different buffer sizes or something.

bitbank2 commented 1 year ago

The data loss may be due to the writeWithoutResponse vs writeWithResponse. Some printers can't handle the data being sent too quickly and without responses. Try using writeWithResponse. It will probably go much slower, but the data will be reliable.

For the change to the library, please do a pull request - thanks