cleversolutions / cordova-zebra-printer

A Cordova plugin for Zebra printers for both iOS and Android with Ionic 3 bindings
MIT License
10 stars 19 forks source link

Maintaining bluetooth a reliable connection? #5

Open looksystems opened 5 years ago

looksystems commented 5 years ago

Our application is for a Zebra TC72 (Android Oreo) and Zebra ZQ510.

At the start of the session, we connect to the printer and then, at intermittent intervals, we print a ticket.

Most times, the printer responds but often it drops the connection and/or goes to sleep and takes a long time to wake up.

When fails to print (ie the library throws an exception), we attempt to connect and print. If that fails, we disconnect, connect and then print (this sometimes works and sometimes requires the printer to be rebooted).

Other times, no exception is thrown when printed but nothing is printed.

On connection, we send the following zpl:

        "! U1 setvar \"wlan.enable\" \"off\"\r\n"
        + "! U1 setvar \"bluetooth.enable\" \"on\"\r\n"
        + "! U1 setvar \"bluetooth.enable_reconnect\" \"on\"\r\n"
        + "! U1 setvar \"power.inactivity_timeout\" \"0\"\r\n"
        + "! U1 setvar \"power.sleep.enable\" \"off\"\r\n"
        + "! U1 setvar \"device.languages\" \"zpl\"\r\n";
  1. Are we using the library correctly? Or should we connect, print, disconnect on every job?

  2. Is there a way to keep the bluetooth connection alive? And/or check if it's been dropped so we can reconnect?

  3. Any thoughts as to how/why the library silently fail sometimes when printing?

Mostly interested in others experiences and/or how they managed to get a reliable and responsive connection from what is an excellent library! Thank you.

looksystems commented 5 years ago

I can answer my first question:

Are we using the library correctly? Or should we connect, print, disconnect on every job?

According to "Best Practices in Creating a Printing Application for Zebra Printers" pdf, you should close the connection after each job. See attached pdf and alternative (possibly older) link here http://techdocs.zebra.com/link-os/2-13/bestpractices/content/index.html

333912018-Best-Practices-in-Creating-a-Printing-Application-for-Zebra-Printers-pdf.pdf

looksystems commented 5 years ago

A little more feedback: since connecting, printing & disconnecting on every job, we've found the "connection" has become much more reliable. That said, we still have pairing issues, with the printer seemly ignoring connections and only becoming responsive again after being rebooted.

Will be working on this further, so will provide further feedback - in case it helps someone else - as I can.