问题
“java.io.IOException: read failed, socket might closed or timeout, read ret: -1” exception appears while i'm trying to connect my android device with Zebra ZD410 printer through bluetooth.
try {
mmSocket.connect();
} catch (IOException e1) {
android.util.Log.e(TAG, e1.toString());
try {
android.util.Log.i(TAG, "Trying fallback...");
mmSocket =(BluetoothSocket) mmDevice.getClass().getMethod("createRfcommSocket", new Class[] {int.class}).invoke(mmDevice,1);
mmSocket.connect();
android.util.Log.i(TAG, "Connected");
} catch (Exception e2) {
android.util.Log.e(TAG, "Couldn't establish Bluetooth connection!");
try {
mmSocket.close();
} catch (IOException e3) {
android.util.Log.e(TAG, "unable to close() " + mSocketType + " socket during connection failure", e3);
}
connectionFailed();
return;
}
}
I already tried solution with fallback socket connection but it didn't helped. This code works well with Epson printer and some other devices, but not with zebra ZD410 printer. What can be a reason?
回答1:
I received a response from Zebra support. My Zebra printer supports only Bluetooth LE, solution is to use printer with bluetooth classic capabilities.
SKUs of the ZD410 that indicate a Bluetooth LE only printer are ZD4xxxx-xxx$xxxx where $ is E, F, M, or S. Bluetooth LE is not a sufficient connection for an Android device to connect and print to the printer. In order to be able to connect and print via Bluetooth from an Android device, the printer would require Bluetooth Classic capabilities. SKUs of the ZD410 that indicate a Bluetooth Classic capabilities in addition to Bluetooth LE are ZD4xxxx-xxx$xxxx where $ is A, B, L, or W.
来源:https://stackoverflow.com/questions/36262106/zebra-printer-connection-failed-read-failed-socket-might-closed-or-timeout-re