@ruhiverse/thermal-printer-plugin 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -208,37 +208,38 @@ public class ThermalPrinterPlugin: CAPPlugin, CBCentralManagerDelegate, CBPeriph
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
// Find peripheral by identifier
|
|
211
|
-
if let uuid = UUID(uuidString: address)
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
211
|
+
if let uuid = UUID(uuidString: address) {
|
|
212
|
+
let peripherals = centralManager.retrievePeripherals(withIdentifiers: [uuid])
|
|
213
|
+
if let peripheral = peripherals.first {
|
|
214
|
+
// Found in known peripherals, connect directly
|
|
215
|
+
printData = data
|
|
216
|
+
printCompletion = { success, error in
|
|
217
|
+
if success {
|
|
218
|
+
DispatchQueue.main.async {
|
|
219
|
+
call.resolve([
|
|
220
|
+
"success": true,
|
|
221
|
+
"message": "Bluetooth print data sent to printer (BLE).",
|
|
222
|
+
])
|
|
223
|
+
}
|
|
224
|
+
} else {
|
|
225
|
+
DispatchQueue.main.async {
|
|
226
|
+
call.reject("BLE print failed: \(error ?? "Unknown error")")
|
|
227
|
+
}
|
|
223
228
|
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
connectedPeripheral = peripheral
|
|
232
|
+
peripheral.delegate = self
|
|
233
|
+
|
|
234
|
+
if centralManager.state == .poweredOn {
|
|
235
|
+
centralManager.connect(peripheral, options: nil)
|
|
224
236
|
} else {
|
|
225
237
|
DispatchQueue.main.async {
|
|
226
|
-
call.reject("
|
|
238
|
+
call.reject("Bluetooth is not powered on")
|
|
227
239
|
}
|
|
228
240
|
}
|
|
241
|
+
return
|
|
229
242
|
}
|
|
230
|
-
|
|
231
|
-
connectedPeripheral = peripheral
|
|
232
|
-
peripheral.delegate = self
|
|
233
|
-
|
|
234
|
-
if centralManager.state == .poweredOn {
|
|
235
|
-
centralManager.connect(peripheral, options: nil)
|
|
236
|
-
} else {
|
|
237
|
-
DispatchQueue.main.async {
|
|
238
|
-
call.reject("Bluetooth is not powered on")
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
return
|
|
242
243
|
}
|
|
243
244
|
|
|
244
245
|
// Not found in known peripherals, scan for it
|