ilabs-flir 2.1.401 → 2.2.1
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.
|
@@ -509,6 +509,8 @@ import ThermalSDK
|
|
|
509
509
|
connectedDeviceName = identity.deviceId()
|
|
510
510
|
_isConnected = true
|
|
511
511
|
|
|
512
|
+
FlirLogger.log(.connection, "[Flir-BRIDGE-CONNECTION] Connected to: \(identity.deviceId())")
|
|
513
|
+
|
|
512
514
|
// Get camera info if available
|
|
513
515
|
if let remoteControl = cam.getRemoteControl(),
|
|
514
516
|
let cameraInfo = try? remoteControl.getCameraInformation() {
|
|
@@ -542,8 +544,10 @@ import ThermalSDK
|
|
|
542
544
|
communicationType: self.communicationInterfaceName(identity.communicationInterface()),
|
|
543
545
|
isEmulator: identity.communicationInterface() == .emulator
|
|
544
546
|
)
|
|
545
|
-
|
|
547
|
+
|
|
548
|
+
// Emit connected state (matches Android emitDeviceState("connected"))
|
|
546
549
|
self.emitStateChange("connected")
|
|
550
|
+
self.delegate?.onDeviceConnected(deviceInfo)
|
|
547
551
|
}
|
|
548
552
|
|
|
549
553
|
} catch {
|
|
@@ -97,7 +97,9 @@ static BOOL flir_isPreferSdkRotation(void) {
|
|
|
97
97
|
@property(nonatomic, copy) RCTPromiseRejectBlock connectReject;
|
|
98
98
|
@end
|
|
99
99
|
|
|
100
|
-
@implementation FlirModule
|
|
100
|
+
@implementation FlirModule {
|
|
101
|
+
NSInteger _listenerCount;
|
|
102
|
+
}
|
|
101
103
|
|
|
102
104
|
RCT_EXPORT_MODULE(FlirModule);
|
|
103
105
|
|
|
@@ -107,6 +109,7 @@ RCT_EXPORT_MODULE(FlirModule);
|
|
|
107
109
|
|
|
108
110
|
- (instancetype)init {
|
|
109
111
|
if (self = [super init]) {
|
|
112
|
+
_listenerCount = 0;
|
|
110
113
|
// Wire up delegate
|
|
111
114
|
id manager = flir_manager_shared();
|
|
112
115
|
if (manager) {
|
|
@@ -127,11 +130,30 @@ RCT_EXPORT_MODULE(FlirModule);
|
|
|
127
130
|
}
|
|
128
131
|
|
|
129
132
|
RCT_EXPORT_METHOD(addListener : (NSString *)eventName) {
|
|
130
|
-
|
|
133
|
+
_listenerCount++;
|
|
134
|
+
NSLog(@"[FlirModule] addListener: %@ (count: %ld)", eventName, (long)_listenerCount);
|
|
135
|
+
|
|
136
|
+
// When FlirDevicesFound listener is added, immediately emit current device list
|
|
137
|
+
// This handles the case where discovery happened before React Native mounted
|
|
138
|
+
if ([eventName isEqualToString:@"FlirDevicesFound"]) {
|
|
139
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
140
|
+
id manager = flir_manager_shared();
|
|
141
|
+
if (manager) {
|
|
142
|
+
NSArray *devices = ((NSArray * (*)(id, SEL))
|
|
143
|
+
objc_msgSend)(manager, sel_registerName("getDiscoveredDevices"));
|
|
144
|
+
if (devices && devices.count > 0) {
|
|
145
|
+
NSLog(@"[FlirModule] addListener - re-emitting %lu discovered devices", (unsigned long)devices.count);
|
|
146
|
+
[self onDevicesFound:devices];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
131
151
|
}
|
|
132
152
|
|
|
133
153
|
RCT_EXPORT_METHOD(removeListeners : (NSInteger)count) {
|
|
134
|
-
|
|
154
|
+
_listenerCount -= count;
|
|
155
|
+
if (_listenerCount < 0) _listenerCount = 0;
|
|
156
|
+
NSLog(@"[FlirModule] removeListeners: %ld (remaining: %ld)", (long)count, (long)_listenerCount);
|
|
135
157
|
}
|
|
136
158
|
|
|
137
159
|
+ (void)emitBatteryUpdateWithLevel:(NSInteger)level charging:(BOOL)charging {
|
|
@@ -410,9 +432,15 @@ RCT_EXPORT_METHOD(isPreferSdkRotation : (RCTPromiseResolveBlock)
|
|
|
410
432
|
}
|
|
411
433
|
}
|
|
412
434
|
|
|
413
|
-
NSLog(@"[FlirModule] onDevicesFound -
|
|
414
|
-
|
|
415
|
-
|
|
435
|
+
NSLog(@"[FlirModule] onDevicesFound - %lu devices, listenerCount: %ld", (unsigned long)arr.count, (long)_listenerCount);
|
|
436
|
+
|
|
437
|
+
if (_listenerCount > 0) {
|
|
438
|
+
NSLog(@"[FlirModule] emitting FlirDevicesFound event");
|
|
439
|
+
[self sendEventWithName:@"FlirDevicesFound"
|
|
440
|
+
body:@{@"devices" : arr, @"count" : @(arr.count)}];
|
|
441
|
+
} else {
|
|
442
|
+
NSLog(@"[FlirModule] ⚠️ No listeners registered yet - devices will be re-emitted when listener is added");
|
|
443
|
+
}
|
|
416
444
|
}
|
|
417
445
|
|
|
418
446
|
- (void)onDeviceConnected:(id)device {
|
|
@@ -429,8 +457,14 @@ RCT_EXPORT_METHOD(isPreferSdkRotation : (RCTPromiseResolveBlock)
|
|
|
429
457
|
addEntriesFromDictionary:((NSDictionary * (*)(id, SEL)) objc_msgSend)(
|
|
430
458
|
device, sel_registerName("toDictionary"))];
|
|
431
459
|
}
|
|
460
|
+
|
|
461
|
+
// Add state info to match Android's FlirDeviceConnected event format
|
|
462
|
+
[body setObject:@"connected" forKey:@"state"];
|
|
463
|
+
[body setObject:@(YES) forKey:@"isConnected"];
|
|
464
|
+
[body setObject:@(NO) forKey:@"isStreaming"]; // streaming starts after connection
|
|
465
|
+
// isEmulator info should be in device dictionary already from toDictionary
|
|
432
466
|
|
|
433
|
-
NSLog(@"[FlirModule] onDeviceConnected - emitting FlirDeviceConnected event");
|
|
467
|
+
NSLog(@"[FlirModule] onDeviceConnected - emitting FlirDeviceConnected event with state info");
|
|
434
468
|
[self sendEventWithName:@"FlirDeviceConnected" body:body];
|
|
435
469
|
}
|
|
436
470
|
|
package/package.json
CHANGED