ilabs-flir 2.2.6 → 2.2.7

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.
@@ -472,16 +472,22 @@ import ThermalSDK
472
472
  // Find the identity for this device
473
473
  guard let identity = findIdentity(for: deviceId) else {
474
474
  FlirLogger.logError(.connection, "Device not found in identity map: \(deviceId)")
475
- delegate?.onError("Device not found: \(deviceId)")
475
+ DispatchQueue.main.async { [weak self] in
476
+ self?.emitStateChange("connection_failed")
477
+ self?.delegate?.onError("Device not found: \(deviceId)")
478
+ }
476
479
  return
477
480
  }
478
481
 
482
+ // Run connection on background thread with timeout monitoring
479
483
  DispatchQueue.global(qos: .userInitiated).async { [weak self] in
480
484
  self?.performConnection(identity: identity)
481
485
  }
482
486
  #else
483
487
  FlirLogger.logError(.connection, "FLIR SDK not available")
484
- delegate?.onError("FLIR SDK not available")
488
+ DispatchQueue.main.async { [weak self] in
489
+ self?.delegate?.onError("FLIR SDK not available")
490
+ }
485
491
  #endif
486
492
  }
487
493
 
@@ -514,14 +520,35 @@ import ThermalSDK
514
520
  FlirLogger.log(.connection, "Generic/network camera - starting authentication...")
515
521
  let certName = getCertificateName()
516
522
  var status = FLIRAuthenticationStatus.pending
517
- while status == .pending {
523
+ var attempts = 0
524
+ let maxAttempts = 10 // 10 seconds max
525
+
526
+ while status == .pending && attempts < maxAttempts {
518
527
  status = cam.authenticate(identity, trustedConnectionName: certName)
519
528
  if status == .pending {
520
- FlirLogger.log(.connection, "Waiting for camera authentication approval...")
529
+ FlirLogger.log(.connection, "Waiting for camera authentication approval... (\(attempts + 1)/\(maxAttempts))")
521
530
  Thread.sleep(forTimeInterval: 1.0)
531
+ attempts += 1
532
+ }
533
+ }
534
+
535
+ if status == .pending {
536
+ FlirLogger.logError(.connection, "Authentication timeout after \(maxAttempts) seconds")
537
+ DispatchQueue.main.async { [weak self] in
538
+ self?.delegate?.onError("Camera authentication timeout - device may require approval")
522
539
  }
540
+ return
523
541
  }
542
+
524
543
  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
+ }
525
552
  }
526
553
 
527
554
  do {
@@ -532,6 +559,7 @@ import ThermalSDK
532
559
  FlirLogger.log(.connection, "✅ Paired successfully with: \(identity.deviceId())")
533
560
 
534
561
  // Step 2: Connect (no identity parameter - uses paired identity)
562
+ // Note: This can hang on some devices - ensure we have timeout in place
535
563
  FlirLogger.log(.connection, "Step 2: Connecting to device...")
536
564
  try cam.connect()
537
565
  FlirLogger.log(.connection, "✅ Connected successfully to: \(identity.deviceId())")
@@ -586,8 +614,14 @@ import ThermalSDK
586
614
  } catch {
587
615
  FlirLogger.logError(.connection, "Connection failed", error: error)
588
616
  _isConnected = false
617
+ _isStreaming = false
618
+ connectedDeviceId = nil
619
+ connectedDeviceName = nil
589
620
  camera = nil
621
+
622
+ // CRITICAL: Always emit error state to RN so UI doesn't hang waiting
590
623
  DispatchQueue.main.async { [weak self] in
624
+ self?.emitStateChange("connection_failed")
591
625
  self?.delegate?.onError("Connection failed: \(error.localizedDescription)")
592
626
  }
593
627
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ilabs-flir",
3
- "version": "2.2.6",
3
+ "version": "2.2.7",
4
4
  "description": "FLIR Thermal SDK for React Native - iOS & Android (bundled at compile time via postinstall)",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",