ugly fix for printer reconnects
This commit is contained in:
parent
0b0f0bf99e
commit
5adcb23dd0
@ -54,6 +54,10 @@ class ZebraPrinterPlugin: CDVPlugin {
|
|||||||
if( self.isConnected()){
|
if( self.isConnected()){
|
||||||
let data = cpcl.data(using: .utf8)
|
let data = cpcl.data(using: .utf8)
|
||||||
var error: NSError?
|
var error: NSError?
|
||||||
|
// it seems self.isConnected() can lie if the printer has power cycled
|
||||||
|
// a workaround is to close and reopen the connection
|
||||||
|
self.printerConnection!.close()
|
||||||
|
self.printerConnection!.open()
|
||||||
self.printerConnection!.write(data, error:&error)
|
self.printerConnection!.write(data, error:&error)
|
||||||
if error != nil{
|
if error != nil{
|
||||||
let pluginResult = CDVPluginResult(
|
let pluginResult = CDVPluginResult(
|
||||||
@ -63,6 +67,7 @@ class ZebraPrinterPlugin: CDVPlugin {
|
|||||||
pluginResult,
|
pluginResult,
|
||||||
callbackId: command.callbackId
|
callbackId: command.callbackId
|
||||||
)
|
)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
let pluginResult = CDVPluginResult(
|
let pluginResult = CDVPluginResult(
|
||||||
@ -72,6 +77,7 @@ class ZebraPrinterPlugin: CDVPlugin {
|
|||||||
pluginResult,
|
pluginResult,
|
||||||
callbackId: command.callbackId
|
callbackId: command.callbackId
|
||||||
)
|
)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
let pluginResult = CDVPluginResult(
|
let pluginResult = CDVPluginResult(
|
||||||
status: CDVCommandStatus_OK
|
status: CDVCommandStatus_OK
|
||||||
|
Loading…
x
Reference in New Issue
Block a user