斑马打印机连接失败“读取失败,套接字可能关闭或超时,读取ret:-1”



"java.io.IOException:read failed,socket may closed or timeout,read ret:-1"当我试图通过蓝牙将我的android设备与Zebra ZD410打印机连接时,出现异常。

        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;
            }
        }

我已经尝试了使用回退套接字连接的解决方案,但并没有起到任何作用。此代码适用于Epson打印机和其他一些设备,但不适用于斑马ZD410打印机。原因是什么?

我收到了Zebra支持部门的回复。我的Zebra打印机只支持蓝牙LE,解决方案是使用具有蓝牙经典功能的打印机。

ZD410的SKU表示仅限蓝牙LE的打印机是ZD4xxxxxxx$xxxx,其中$是E、F、M或S。蓝牙LE不是Android设备连接和打印到打印机的足够连接。为了能够从Android设备通过蓝牙连接和打印,打印机需要蓝牙经典功能。ZD410的SKU表示除蓝牙LE之外的蓝牙经典功能是ZD4xxxxxxx$xxxx,其中$是a、B、L或W。

最新更新