ilabs-flir 2.1.3 → 2.1.32

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 {
@@ -99,6 +99,11 @@ static BOOL flir_isPreferSdkRotation(void) {
99
99
  @property (nonatomic, copy) NSString *connectedDeviceId;
100
100
  @property (nonatomic, copy) NSString *connectedDeviceName;
101
101
  @property (nonatomic, assign) double lastTemperature;
102
+
103
+ - (void)emitStateChange:(NSString *)state;
104
+ - (void)emitDeviceConnected;
105
+ - (void)stopStreamInternal;
106
+
102
107
  @end
103
108
 
104
109
  @implementation FlirModule
@@ -377,26 +382,31 @@ RCT_EXPORT_METHOD(connectToDevice:(NSString *)deviceId
377
382
  RCTLogInfo(@"[FlirModule] Authentication status: %d", (int)status);
378
383
  }
379
384
 
380
- // Use the proven connection pattern from FLIR SDK samples:
381
- // Step 1: Pair with identity (required for FLIR One devices)
385
+ // Step 1: Pair with camera (required for FLIR One devices)
382
386
  @try {
383
- [self.camera pair:identity code:0];
387
+ if (![self.camera pair:identity code:0 error:&error]) {
388
+ RCTLogError(@"[FlirModule] Pair failed: %@", error.localizedDescription);
389
+ if (completion) completion(NO, error);
390
+ return;
391
+ }
384
392
  RCTLogInfo(@"[FlirModule] Paired with: %@", [identity deviceId]);
385
393
  } @catch (NSException *exception) {
386
- RCTLogError(@"[FlirModule] Pair failed: %@", exception.reason);
394
+ RCTLogError(@"[FlirModule] Pair exception: %@", exception.reason);
387
395
  NSError *pairError = [NSError errorWithDomain:@"FlirModule" code:1001 userInfo:@{NSLocalizedDescriptionKey: exception.reason ?: @"Pair failed"}];
388
396
  if (completion) completion(NO, pairError);
389
397
  return;
390
398
  }
391
399
 
392
- // Step 2: Connect (no identity parameter - uses paired identity)
400
+ // Step 2: Connect to camera
393
401
  BOOL connected = NO;
394
402
  @try {
395
- [self.camera connect:&error];
396
- connected = (error == nil);
397
- if (connected) {
398
- RCTLogInfo(@"[FlirModule] Connected to: %@", [identity deviceId]);
403
+ if (![self.camera connect:&error]) {
404
+ RCTLogError(@"[FlirModule] Connect failed: %@", error.localizedDescription);
405
+ if (completion) completion(NO, error);
406
+ return;
399
407
  }
408
+ connected = YES;
409
+ RCTLogInfo(@"[FlirModule] Connected to: %@", [identity deviceId]);
400
410
  } @catch (NSException *exception) {
401
411
  RCTLogError(@"[FlirModule] Connect exception: %@", exception.reason);
402
412
  error = [NSError errorWithDomain:@"FlirModule" code:1002 userInfo:@{NSLocalizedDescriptionKey: exception.reason ?: @"Connect failed"}];
@@ -422,7 +432,7 @@ RCT_EXPORT_METHOD(connectToDevice:(NSString *)deviceId
422
432
  // Get available streams and prefer thermal stream
423
433
  NSArray<FLIRStream *> *streams = [self.camera getStreams];
424
434
  if (streams.count > 0) {
425
- RCTLogInfo(@"[FlirModule] Found %lu streams", (unsigned long)streams.count);
435
+ RCTLogInfo(@"[FlirModule] Found %lu stream(s)", (unsigned long)streams.count);
426
436
 
427
437
  // Find thermal stream (preferred) or use first stream
428
438
  FLIRStream *streamToStart = nil;
@@ -530,16 +540,26 @@ RCT_EXPORT_METHOD(stopFlir:(RCTPromiseResolveBlock)resolve
530
540
  newStream.delegate = self;
531
541
 
532
542
  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);
543
+ // Use try-catch pattern from samples
544
+ @try {
545
+ if (![newStream start:&error]) {
546
+ RCTLogError(@"[FlirModule] Stream start failed: %@", error.localizedDescription);
547
+ self.stream = nil;
548
+ self.streamer = nil;
549
+ [[FlirEventEmitter shared] sendDeviceEvent:@"FlirError" body:@{@"error": error.localizedDescription ?: @"Stream start failed"}];
550
+ return;
551
+ }
552
+ } @catch (NSException *exception) {
553
+ RCTLogError(@"[FlirModule] Stream start exception: %@", exception.reason);
539
554
  self.stream = nil;
540
555
  self.streamer = nil;
541
- [[FlirEventEmitter shared] sendDeviceEvent:@"FlirError" body:@{@"error": error.localizedDescription ?: @"Stream start failed"}];
556
+ [[FlirEventEmitter shared] sendDeviceEvent:@"FlirError" body:@{@"error": exception.reason ?: @"Stream start exception"}];
557
+ return;
542
558
  }
559
+
560
+ self.isStreaming = YES;
561
+ [self emitStateChange:@"streaming"];
562
+ RCTLogInfo(@"[FlirModule] Stream started (thermal: %@)", newStream.isThermal ? @"YES" : @"NO");
543
563
  }
544
564
 
545
565
  - (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.32",
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",