ilabs-flir 2.1.39 → 2.1.402

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.
@@ -56,7 +56,24 @@ import Foundation
56
56
  }
57
57
 
58
58
  /// Log frame received (rate-limited to avoid log spam)
59
- @objc public static func logFrame(width: Int, height: Int, temperature: Double? = nil) {
59
+ @objc public static func logFrame(width: Int, height: Int) {
60
+ logFrame(width: width, height: height, temperature: 0)
61
+ }
62
+
63
+ /// Log frame received with temperature (rate-limited to avoid log spam)
64
+ @objc public static func logFrame(width: Int, height: Int, temperature: Double) {
65
+ frameCount += 1
66
+ if frameCount % frameLogInterval == 0 {
67
+ var msg = "Frame #\(frameCount) received (\(width)x\(height))"
68
+ if !temperature.isNaN {
69
+ msg += " temp=\(String(format: "%.1f", temperature))°C"
70
+ }
71
+ log(.frame, msg)
72
+ }
73
+ }
74
+
75
+ /// Internal implementation for logFrame with optional temperature
76
+ private static func logFrame(width: Int, height: Int, temperature: Double?) {
60
77
  frameCount += 1
61
78
  if frameCount % frameLogInterval == 0 {
62
79
  var msg = "Frame #\(frameCount) received (\(width)x\(height))"
@@ -127,7 +127,21 @@ RCT_EXPORT_MODULE(FlirModule);
127
127
  }
128
128
 
129
129
  RCT_EXPORT_METHOD(addListener : (NSString *)eventName) {
130
- // Required for RCTEventEmitter
130
+ // When FlirDevicesFound listener is added, immediately emit current device list
131
+ // This handles the case where discovery happened before React Native mounted
132
+ if ([eventName isEqualToString:@"FlirDevicesFound"]) {
133
+ dispatch_async(dispatch_get_main_queue(), ^{
134
+ id manager = flir_manager_shared();
135
+ if (manager) {
136
+ NSArray *devices = ((NSArray * (*)(id, SEL))
137
+ objc_msgSend)(manager, sel_registerName("getDiscoveredDevices"));
138
+ if (devices && devices.count > 0) {
139
+ NSLog(@"[FlirModule] addListener - re-emitting %lu discovered devices", (unsigned long)devices.count);
140
+ [self onDevicesFound:devices];
141
+ }
142
+ }
143
+ });
144
+ }
131
145
  }
132
146
 
133
147
  RCT_EXPORT_METHOD(removeListeners : (NSInteger)count) {
@@ -136,8 +150,12 @@ RCT_EXPORT_METHOD(removeListeners : (NSInteger)count) {
136
150
 
137
151
  + (void)emitBatteryUpdateWithLevel:(NSInteger)level charging:(BOOL)charging {
138
152
  NSDictionary *payload = @{@"level" : @(level), @"isCharging" : @(charging)};
139
- [[FlirEventEmitter shared] sendDeviceEvent:@"FlirBatteryUpdated"
140
- body:payload];
153
+ NSLog(@"[FlirModule] Emitting battery update - level: %ld, charging: %d", (long)level, charging);
154
+
155
+ // Note: This is a class method, so we need to get the module instance
156
+ // For now, we'll just log - in production you'd need to get the module instance
157
+ // or convert this to an instance method
158
+ // [[FlirModule sharedInstance] sendEventWithName:@"FlirBatteryUpdated" body:payload];
141
159
  }
142
160
 
143
161
  #pragma mark - Methods
@@ -405,9 +423,10 @@ RCT_EXPORT_METHOD(isPreferSdkRotation : (RCTPromiseResolveBlock)
405
423
  objc_msgSend)(d, sel_registerName("toDictionary"))];
406
424
  }
407
425
  }
408
- [[FlirEventEmitter shared]
409
- sendDeviceEvent:@"FlirDevicesFound"
410
- body:@{@"devices" : arr, @"count" : @(arr.count)}];
426
+
427
+ NSLog(@"[FlirModule] onDevicesFound - emitting FlirDevicesFound with %lu devices", (unsigned long)arr.count);
428
+ [self sendEventWithName:@"FlirDevicesFound"
429
+ body:@{@"devices" : arr, @"count" : @(arr.count)}];
411
430
  }
412
431
 
413
432
  - (void)onDeviceConnected:(id)device {
@@ -424,32 +443,38 @@ RCT_EXPORT_METHOD(isPreferSdkRotation : (RCTPromiseResolveBlock)
424
443
  addEntriesFromDictionary:((NSDictionary * (*)(id, SEL)) objc_msgSend)(
425
444
  device, sel_registerName("toDictionary"))];
426
445
  }
446
+
447
+ // Add state info to match Android's FlirDeviceConnected event format
448
+ [body setObject:@"connected" forKey:@"state"];
449
+ [body setObject:@(YES) forKey:@"isConnected"];
450
+ [body setObject:@(NO) forKey:@"isStreaming"]; // streaming starts after connection
451
+ // isEmulator info should be in device dictionary already from toDictionary
427
452
 
428
- [[FlirEventEmitter shared] sendDeviceEvent:@"FlirDeviceConnected" body:body];
453
+ NSLog(@"[FlirModule] onDeviceConnected - emitting FlirDeviceConnected event with state info");
454
+ [self sendEventWithName:@"FlirDeviceConnected" body:body];
429
455
  }
430
456
 
431
457
  - (void)onDeviceDisconnected {
432
- [[FlirEventEmitter shared] sendDeviceEvent:@"FlirDeviceDisconnected"
433
- body:@{}];
458
+ NSLog(@"[FlirModule] onDeviceDisconnected - emitting FlirDeviceDisconnected event");
459
+ [self sendEventWithName:@"FlirDeviceDisconnected" body:@{}];
434
460
  }
435
461
 
436
462
  - (void)onFrameReceived:(UIImage *)image
437
463
  width:(NSInteger)width
438
464
  height:(NSInteger)height {
439
465
  // Also emit event for JS consumers (though slow, some might use it)
440
- [[FlirEventEmitter shared]
441
- sendDeviceEvent:@"FlirFrameReceived"
442
- body:@{
443
- @"width" : @(width),
444
- @"height" : @(height),
445
- @"timestamp" :
446
- @([[NSDate date] timeIntervalSince1970] * 1000)
447
- }];
466
+ [self sendEventWithName:@"FlirFrameReceived"
467
+ body:@{
468
+ @"width" : @(width),
469
+ @"height" : @(height),
470
+ @"timestamp" :
471
+ @([[NSDate date] timeIntervalSince1970] * 1000)
472
+ }];
448
473
  }
449
474
 
450
475
  - (void)onFrameReceivedRaw:(NSData *)data width:(NSInteger)width height:(NSInteger)height bytesPerRow:(NSInteger)bytesPerRow timestamp:(double)timestamp {
451
476
  // Emit a lightweight event to notify JS that a raw bitmap is available; raw bytes are available via getLatestFrameBitmap()
452
- [[FlirEventEmitter shared] sendDeviceEvent:@"FlirFrameBitmapAvailable" body:@{
477
+ [self sendEventWithName:@"FlirFrameBitmapAvailable" body:@{
453
478
  @"width": @(width),
454
479
  @"height": @(height),
455
480
  @"bytesPerRow": @(bytesPerRow),
@@ -463,9 +488,9 @@ RCT_EXPORT_METHOD(isPreferSdkRotation : (RCTPromiseResolveBlock)
463
488
  self.connectResolve = nil;
464
489
  self.connectReject = nil;
465
490
  }
466
- [[FlirEventEmitter shared]
467
- sendDeviceEvent:@"FlirError"
468
- body:@{@"error" : message ?: @"Unknown error"}];
491
+ NSLog(@"[FlirModule] onError - emitting FlirError: %@", message);
492
+ [self sendEventWithName:@"FlirError"
493
+ body:@{@"error" : message ?: @"Unknown error"}];
469
494
  }
470
495
 
471
496
  - (void)onStateChanged:(NSString *)state
@@ -478,7 +503,8 @@ RCT_EXPORT_METHOD(isPreferSdkRotation : (RCTPromiseResolveBlock)
478
503
  @"isStreaming" : @(isStreaming),
479
504
  @"isEmulator" : @(isEmulator)
480
505
  };
481
- [[FlirEventEmitter shared] sendDeviceEvent:@"FlirStateChanged" body:body];
506
+ NSLog(@"[FlirModule] onStateChanged - state: %@, connected: %d, streaming: %d", state, isConnected, isStreaming);
507
+ [self sendEventWithName:@"FlirStateChanged" body:body];
482
508
  }
483
509
 
484
510
  @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ilabs-flir",
3
- "version": "2.1.39",
3
+ "version": "2.1.402",
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",