Problem connecting printer on Android Lollipop

Hi,

 

I developed an android app that uses bluetooth connection to print receipts through iMZ320 printers, everything works great on Android 4.x, yet on a tablet with Lollipop logs these errors:

 

02-06 17:40:10.790 18479 18498 W System.err: com.zebra.sdk.comm.ConnectionException: Could not connect to device: read failed, socket might closed or timeout, read ret: -1

02-06 17:40:10.790 18479 18498 W System.err:     at com.zebra.sdk.comm.ConnectionA.open(Unknown Source)

02-06 17:40:10.790 18479 18498 W System.err:     at com.zebra.sdk.comm.BluetoothConnection.open(Unknown Source)

02-06 17:40:10.790 18479 18498 W System.err:     at com.labinf.gestioneagenti.oggetti.Printer.connect(Printer.java:51)

02-06 17:40:10.790 18479 18498 W System.err:     at com.labinf.gestioneagenti.threads.PrintAT.doInBackground(PrintAT.java:57)

02-06 17:40:10.790 18479 18498 W System.err:     at com.labinf.gestioneagenti.threads.PrintAT.doInBackground(PrintAT.java:1)

02-06 17:40:10.790 18479 18498 W System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:288)

02-06 17:40:10.790 18479 18498 W System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)

02-06 17:40:10.790 18479 18498 W System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)

02-06 17:40:10.790 18479 18498 W System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)

02-06 17:40:10.790 18479 18498 W System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)

02-06 17:40:10.790 18479 18498 W System.err:     at java.lang.Thread.run(Thread.java:818)

02-06 17:40:10.790 18479 18498 W System.err: Caused by: com.zebra.sdk.comm.ConnectionException: read failed, socket might closed or timeout, read ret: -1

02-06 17:40:10.790 18479 18498 W System.err:     at com.zebra.sdk.comm.internal.BluetoothInsecureZebraConnectorImpl.tryPublicApiWay(Unknown Source)

02-06 17:40:10.790 18479 18498 W System.err:     at com.zebra.sdk.comm.internal.BluetoothInsecureZebraConnectorImpl.open(Unknown Source)

02-06 17:40:10.790 18479 18498 W System.err:     ... 11 more

 

These errors show off when:

 

printerConnection = new BluetoothConnectionInsecure(PRINTER_ADDRESS);

        try {

            printerConnection.open();

            Logger.log(zebra_tag, "Connected");

        } catch (ConnectionException e) {

            Logger.log(zebra_tag, "Comm Error! Disconnecting");

            e.printStackTrace();

            // DemoSleeper.sleep(1000);

            disconnect();

        }

 

The PRINTER_ADDRESS is saved this way:

 

1) get the list of devices available

new Thread(new Runnable() {

            public void run() {

                Looper.prepare();

                try {

                    BluetoothDiscoverer.findPrinters(getActivity(),

                            BTscannerDlg.this);

                } catch (ConnectionException e) {

                    // new

                    // UIHelper(BluetoothDiscovery.this).showErrorDialogOnGuiThread(e.getMessage());

                } finally {

                    Looper.myLooper().quit();

                }

            }

        }).start();

2) save the one selected

public void onItemClick(AdapterView<?> parent, View view,

                    int position, long id) {

                DiscoveredPrinterBluetooth p = (DiscoveredPrinterBluetooth) devicesAdp

                        .getItem(position);

                PRINTER_ADDRESS = p.address;

    

If anyone needs more code to understand the problem, just ask for it.

Thank you very much for your help.

 

Enrico

Manuel Caicedo-...
Hi Enrico,There were some

Hi Enrico,

There were some changes that Google introduced with Android 5.0 and upper versions for BT connectivity.

You can try to add these BT permissions to the manifiest. Also, We recommend to use our latest version of our Link-OS SDK. (build v2.11.2800), please, update the latest library to your project.

  <uses-permission android:name="android.permission.BLUETOOTH" />

  <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Please, could you help me with some additional pieces of information to debug your issue better.

1.) Firmware of the iMZ320

2.) Version of the Android Link-OS you are using.

3.) Actual printer language of the printer. Are you using ZPL, CPCL, Line_Print?

Thanks,

MC

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Enrico Schio
Hi Manuel,first of all, thank

Hi Manuel,

first of all, thank you for your help; I use the last versione of link-os (v2.11.2800), the printer language should be CPCL, unfortunately I don't have the printer here and seeing that the connection fails I can't see the log taht shows the current language. For the Firmware of the printer I'll ask for it to our customer, who currently has the printer.

Anyway, I was missing the 3rd permission in manifest, now I'll update the project with this fix and send the app to our customer to test if the problem is fixed.

I'll keep you updated, thank you again.

ES

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Enrico Schio
Hi Manuel,adding that

Hi Manuel,

adding that permission to the manifest didn't fix the problem. Furthermore the printer still works with others 4.xx devices, but with this one (Lollipop) also the setup client can't pair the printer even if it's scanned, as you can see below, in the screenshot with the error.

Do you have any suggestion?

Thank you very much, again.

ES

Screenshot_2017-02-11-12-28-50.jpg

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Manuel Caicedo-...
Hi Enrico,Please, could you

Hi Enrico,

Please, could you add (as attached file) the allcv report, of the printer you are testing, to the following post, also could you give me details of the tablet you are using as well.

If you are not familiar with the allcv report, please, follow the directions on the link below.

https://km.zebra.com/kb/index?page=content&id=SO8613&actp=LIST

Thanks,

MC

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Alessandro Caliaro
Hi Enrico. Have you found a

Hi Enrico. Have you found a solution for this?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments