【问题标题】:Zebra bluetooth printer only working under debuggerZebra 蓝牙打印机只能在调试器下工作
【发布时间】:2015-03-31 20:42:59
【问题描述】:

我正在打印到 QLn420,它在调试器下运行良好,或者当非常少量的 ZPL 传递给它时,但当我不在调试器下运行应用程序时它会失败。该代码与 Zebra 的演示代码 (https://km.zebra.com/kb/index?page=content&id=WH122&actp=LIST) 基本相同,只是 dispatch_async 在调用堆栈中更早地执行。

NSString *serialNumber = [ZebraPrintManager getBluetoothSerial];

// Instantiate connection to Zebra Bluetooth accessory
id<ZebraPrinterConnection, NSObject> thePrinterConn = [[MfiBtPrinterConnection alloc] initWithSerialNumber:serialNumber];

// Open the connection - physical connection is established here.
BOOL success = [thePrinterConn open];

NSError *error = nil;

// Send the data to printer as a byte array.
NSData* data = [ZPL dataUsingEncoding:NSUTF8StringEncoding];
success = success && [thePrinterConn write:data error:&error];

dispatch_async(dispatch_get_main_queue(), ^{
    if(success != YES || error != nil) {
        UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
        [errorAlert show];
    }
});

// Close the connection to release resources.
[thePrinterConn close];

【问题讨论】:

    标签: ios bluetooth zebra-printers


    【解决方案1】:

    蓝牙有延迟设置。将此值增加到至少 100。某些手机无法使用设置为 30 的值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-10
      • 1970-01-01
      • 2014-04-26
      • 2011-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多