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
|
-
|
|
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
|
-
//
|
|
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
|
|
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
|
|
400
|
+
// Step 2: Connect to camera
|
|
393
401
|
BOOL connected = NO;
|
|
394
402
|
@try {
|
|
395
|
-
[self.camera connect:&error]
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
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
|
|
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
|
-
|
|
534
|
-
|
|
535
|
-
[
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
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":
|
|
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 {
|