This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lane :bluepill do | |
scan(scheme: “myApp”, build_for_testing: true) | |
sh “bash ./bluepill.sh“ | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum SectionTitle: String { | |
case a = "a" | |
case b = "b" | |
case c = "c" | |
case d = "d" | |
init?(section: Int, hasB: Bool = false, hasD: Bool = false) { | |
if hasD { | |
switch section { | |
case 0: self = .a | |
case 1: self = .b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum CommonPrintingFormat: String { | |
case start = “! 0 200 200 150 1” | |
case end = “\nFORM\nPRINT “ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum CommonPrintingFormat: String { | |
case start = “! 0 200 200 150 1” | |
case end = “\nFORM\nPRINT “ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func didDisconnect(notification: Notification) { | |
isConnected = false | |
connectionDelegate?.connectionStatusChanged() | |
} | |
private func didConnect(notification: Notification) { | |
isConnected = true | |
connectionDelegate?.connectionStatusChanged() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol EAAccessoryManagerConnectionStatusDelegate { | |
func connectionStatusChanged() -> Void | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var manager: EAAccessoryManager! | |
var isConnected: Bool = false | |
//new content from step1 | |
var connectionDelegate: EAAccessoryManagerConnectionStatusDelegate? | |
// end new content | |
private var printerConnection: MfiBtPrinterConnection? | |
private var serialNumber: String? | |
private var disconnectNotificationObserver: NSObjectProtocol? | |
private var connectedNotificationObserver: NSObjectProtocol? | |
static let sharedInstance = PrintManager() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private override init() { | |
super.init() | |
manager = EAAccessoryManager.shared() | |
findConnectedPrinter { [weak self] bool in | |
if let strongSelf = self { | |
strongSelf.isConnected = bool | |
} | |
} | |
//Notifications | |
disconnectNotificationObserver = NotificationCenter.default.addObserver(forName: Notification.Name.EAAccessoryDidDisconnect, object: nil, queue: nil, using: didDisconnect) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deinit { | |
if let disconnectNotificationObserver = disconnectNotificationObserver { | |
NotificationCenter.default.removeObserver(disconnectNotificationObserver) | |
} | |
if let connectedNotificationObserver = connectedNotificationObserver { | |
NotificationCenter.default.removeObserver(connectedNotificationObserver) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func findConnectedPrinter(completion: (Bool) -> Void) { | |
let connectedDevices = manager.connectedAccessories | |
for device in connectedDevices { | |
if device.protocolStrings.contains(“com.zebra.rawport”) { | |
serialNumber = device.serialNumber | |
connectToPrinter(completion: { completed in | |
completion(completed) | |
}) | |
} | |
} |
OlderNewer