ilabs-flir 2.1.3 → 2.1.31

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.
@@ -453,9 +453,10 @@ import ThermalSDK
453
453
  }
454
454
 
455
455
  // Get streams
456
- if let streams = cam.getStreams(), !streams.isEmpty {
456
+ let streams = cam.getStreams()
457
+ if !streams.isEmpty {
457
458
  NSLog("[FlirManager] Found \(streams.count) streams")
458
-
459
+
459
460
  // Find and start the first thermal stream (preferred) or any stream
460
461
  let thermalStream = streams.first { $0.isThermal } ?? streams.first
461
462
  if let streamToStart = thermalStream {
@@ -377,26 +377,31 @@ RCT_EXPORT_METHOD(connectToDevice:(NSString *)deviceId
377
377
  RCTLogInfo(@"[FlirModule] Authentication status: %d", (int)status);
378
378
  }
379
379
 
380
- // Use the proven connection pattern from FLIR SDK samples:
381
- // Step 1: Pair with identity (required for FLIR One devices)
380
+ // Step 1: Pair with camera (required for FLIR One devices)
382
381
  @try {
383
- [self.camera pair:identity code:0];
382
+ if (![self.camera pair:identity code:0 error:&error]) {
383
+ RCTLogError(@"[FlirModule] Pair failed: %@", error.localizedDescription);
384
+ if (completion) completion(NO, error);
385
+ return;
386
+ }
384
387
  RCTLogInfo(@"[FlirModule] Paired with: %@", [identity deviceId]);
385
388
  } @catch (NSException *exception) {
386
- RCTLogError(@"[FlirModule] Pair failed: %@", exception.reason);
389
+ RCTLogError(@"[FlirModule] Pair exception: %@", exception.reason);
387
390
  NSError *pairError = [NSError errorWithDomain:@"FlirModule" code:1001 userInfo:@{NSLocalizedDescriptionKey: exception.reason ?: @"Pair failed"}];
388
391
  if (completion) completion(NO, pairError);
389
392
  return;
390
393
  }
391
394
 
392
- // Step 2: Connect (no identity parameter - uses paired identity)
395
+ // Step 2: Connect to camera
393
396
  BOOL connected = NO;
394
397
  @try {
395
- [self.camera connect:&error];
396
- connected = (error == nil);
397
- if (connected) {
398
- RCTLogInfo(@"[FlirModule] Connected to: %@", [identity deviceId]);
398
+ if (![self.camera connect:&error]) {
399
+ RCTLogError(@"[FlirModule] Connect failed: %@", error.localizedDescription);
400
+ if (completion) completion(NO, error);
401
+ return;
399
402
  }
403
+ connected = YES;
404
+ RCTLogInfo(@"[FlirModule] Connected to: %@", [identity deviceId]);
400
405
  } @catch (NSException *exception) {
401
406
  RCTLogError(@"[FlirModule] Connect exception: %@", exception.reason);
402
407
  error = [NSError errorWithDomain:@"FlirModule" code:1002 userInfo:@{NSLocalizedDescriptionKey: exception.reason ?: @"Connect failed"}];
@@ -422,7 +427,7 @@ RCT_EXPORT_METHOD(connectToDevice:(NSString *)deviceId
422
427
  // Get available streams and prefer thermal stream
423
428
  NSArray<FLIRStream *> *streams = [self.camera getStreams];
424
429
  if (streams.count > 0) {
425
- RCTLogInfo(@"[FlirModule] Found %lu streams", (unsigned long)streams.count);
430
+ RCTLogInfo(@"[FlirModule] Found %lu stream(s)", (unsigned long)streams.count);
426
431
 
427
432
  // Find thermal stream (preferred) or use first stream
428
433
  FLIRStream *streamToStart = nil;
@@ -530,16 +535,26 @@ RCT_EXPORT_METHOD(stopFlir:(RCTPromiseResolveBlock)resolve
530
535
  newStream.delegate = self;
531
536
 
532
537
  NSError *error = nil;
533
- if ([newStream start:&error]) {
534
- self.isStreaming = YES;
535
- [self emitStateChange:@"streaming"];
536
- RCTLogInfo(@"[FlirModule] Stream started (thermal: %@)", newStream.isThermal ? @"YES" : @"NO");
537
- } else {
538
- RCTLogError(@"[FlirModule] Stream start failed: %@", error.localizedDescription);
538
+ // Use try-catch pattern from samples
539
+ @try {
540
+ if (![newStream start:&error]) {
541
+ RCTLogError(@"[FlirModule] Stream start failed: %@", error.localizedDescription);
542
+ self.stream = nil;
543
+ self.streamer = nil;
544
+ [[FlirEventEmitter shared] sendDeviceEvent:@"FlirError" body:@{@"error": error.localizedDescription ?: @"Stream start failed"}];
545
+ return;
546
+ }
547
+ } @catch (NSException *exception) {
548
+ RCTLogError(@"[FlirModule] Stream start exception: %@\", exception.reason);
539
549
  self.stream = nil;
540
550
  self.streamer = nil;
541
- [[FlirEventEmitter shared] sendDeviceEvent:@"FlirError" body:@{@"error": error.localizedDescription ?: @"Stream start failed"}];
551
+ [[FlirEventEmitter shared] sendDeviceEvent:@"FlirError" body:@{@"error": exception.reason ?: @"Stream start exception"}];
552
+ return;
542
553
  }
554
+
555
+ self.isStreaming = YES;
556
+ [self emitStateChange:@"streaming"];
557
+ RCTLogInfo(@"[FlirModule] Stream started (thermal: %@)\", newStream.isThermal ? @\"YES\" : @\"NO\");
543
558
  }
544
559
 
545
560
  - (void)stopStreamInternal {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ilabs-flir",
3
- "version": "2.1.3",
3
+ "version": "2.1.31",
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",