I try to send command to ZD420 from Zebra TC26 app. I create app with android studio but i have error and not send command
I use zebra library
My Code :
val bAdapter: BluetoothAdapter = BluetoothAdapter.getDefaultAdapter()
for (device in bAdapter.bondedDevices) {
sendZplOverBluetooth(device.address.toString())
}
private fun sendZplOverBluetooth(theBtMacAddress: String) {
try {
val thePrinterConn: Connection = BluetoothConnection(theBtMacAddress)
thePrinterConn.open()
if (thePrinterConn.isConnected) {
val zplData = "^XA^FO20,20^A0N,25,25^FDThis is a ZPL test.^FS^XZ"
thePrinterConn.write(zplData.toByteArray())
thePrinterConn.close()
}
} catch (e: java.lang.Exception) {
e.printStackTrace()
}
}
Error :
W/System.err: com.zebra.sdk.comm.ConnectionException: Could not connect to device: read failed, socket might closed or timeout, read ret: -1
W/System.err: at com.zebra.sdk.comm.ConnectionA.throwAsConnectionException(Unknown Source:42)