ilabs-flir 2.2.7 → 2.2.8
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.
- package/ios/Flir/src/FlirManager.swift +50 -11
- package/package.json +1 -1
|
@@ -361,13 +361,19 @@ import ThermalSDK
|
|
|
361
361
|
FlirLogger.log(.discovery, "Starting discovery...")
|
|
362
362
|
|
|
363
363
|
#if FLIR_ENABLED
|
|
364
|
+
// Guard: prevent re-entry if already scanning
|
|
364
365
|
if isScanning {
|
|
365
|
-
FlirLogger.log(.discovery, "
|
|
366
|
+
FlirLogger.log(.discovery, "⚠️ Discovery already in progress - ignoring duplicate startDiscovery call")
|
|
366
367
|
return
|
|
367
368
|
}
|
|
368
369
|
|
|
370
|
+
// Cancel any previous timeout and reset state
|
|
371
|
+
discoveryTimeoutWorkItem?.cancel()
|
|
372
|
+
discoveryTimeoutWorkItem = nil
|
|
373
|
+
|
|
369
374
|
isScanning = true
|
|
370
375
|
discoveredDevices.removeAll()
|
|
376
|
+
identityMap.removeAll()
|
|
371
377
|
|
|
372
378
|
if discovery == nil {
|
|
373
379
|
discovery = FLIRDiscovery()
|
|
@@ -459,6 +465,16 @@ import ThermalSDK
|
|
|
459
465
|
discoveryTimeoutWorkItem = nil
|
|
460
466
|
discovery?.stop()
|
|
461
467
|
isScanning = false
|
|
468
|
+
|
|
469
|
+
// Emit final device list to RN so UI updates properly
|
|
470
|
+
DispatchQueue.main.async { [weak self] in
|
|
471
|
+
guard let self = self else { return }
|
|
472
|
+
self.delegate?.onDevicesFound(self.discoveredDevices)
|
|
473
|
+
if self.discoveredDevices.isEmpty {
|
|
474
|
+
self.emitStateChange("no_device_found")
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
462
478
|
FlirLogger.log(.discovery, "Discovery stopped")
|
|
463
479
|
#endif
|
|
464
480
|
}
|
|
@@ -469,6 +485,14 @@ import ThermalSDK
|
|
|
469
485
|
FlirLogger.logConnectionAttempt(deviceId: deviceId)
|
|
470
486
|
|
|
471
487
|
#if FLIR_ENABLED
|
|
488
|
+
// Guard: if already connected, disconnect first
|
|
489
|
+
if _isConnected {
|
|
490
|
+
FlirLogger.log(.connection, "⚠️ Already connected - disconnecting first...")
|
|
491
|
+
disconnect()
|
|
492
|
+
// Give disconnect a moment to complete
|
|
493
|
+
Thread.sleep(forTimeInterval: 0.5)
|
|
494
|
+
}
|
|
495
|
+
|
|
472
496
|
// Find the identity for this device
|
|
473
497
|
guard let identity = findIdentity(for: deviceId) else {
|
|
474
498
|
FlirLogger.logError(.connection, "Device not found in identity map: \(deviceId)")
|
|
@@ -479,9 +503,32 @@ import ThermalSDK
|
|
|
479
503
|
return
|
|
480
504
|
}
|
|
481
505
|
|
|
482
|
-
// Run connection on background thread with timeout
|
|
483
|
-
|
|
506
|
+
// Run connection on background thread with overall timeout
|
|
507
|
+
let timeoutSeconds: Double = 15.0
|
|
508
|
+
var connectionCompleted = false
|
|
509
|
+
let connectionQueue = DispatchQueue.global(qos: .userInitiated)
|
|
510
|
+
|
|
511
|
+
// Start connection attempt
|
|
512
|
+
connectionQueue.async { [weak self] in
|
|
484
513
|
self?.performConnection(identity: identity)
|
|
514
|
+
connectionCompleted = true
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// Monitor for timeout
|
|
518
|
+
DispatchQueue.global(qos: .utility).asyncAfter(deadline: .now() + timeoutSeconds) { [weak self] in
|
|
519
|
+
guard let self = self, !connectionCompleted else { return }
|
|
520
|
+
|
|
521
|
+
FlirLogger.logError(.connection, "⏱ Connection timeout after \(timeoutSeconds) seconds - aborting")
|
|
522
|
+
|
|
523
|
+
// Force cleanup
|
|
524
|
+
self.camera = nil
|
|
525
|
+
self._isConnected = false
|
|
526
|
+
self.connectedDeviceId = nil
|
|
527
|
+
|
|
528
|
+
DispatchQueue.main.async {
|
|
529
|
+
self.emitStateChange("connection_failed")
|
|
530
|
+
self.delegate?.onError("Connection timeout - device not responding")
|
|
531
|
+
}
|
|
485
532
|
}
|
|
486
533
|
#else
|
|
487
534
|
FlirLogger.logError(.connection, "FLIR SDK not available")
|
|
@@ -541,14 +588,6 @@ import ThermalSDK
|
|
|
541
588
|
}
|
|
542
589
|
|
|
543
590
|
FlirLogger.log(.connection, "Authentication status: \(status.rawValue)")
|
|
544
|
-
|
|
545
|
-
if status != .authenticated {
|
|
546
|
-
FlirLogger.logError(.connection, "Authentication failed with status: \(status.rawValue)")
|
|
547
|
-
DispatchQueue.main.async { [weak self] in
|
|
548
|
-
self?.delegate?.onError("Camera authentication failed")
|
|
549
|
-
}
|
|
550
|
-
return
|
|
551
|
-
}
|
|
552
591
|
}
|
|
553
592
|
|
|
554
593
|
do {
|