ilabs-flir 2.4.6 → 2.4.7

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.
@@ -86,16 +86,6 @@ object FlirManager {
86
86
 
87
87
  fun setPalette(name: String) {
88
88
  sdkManager?.setPalette(name)
89
- // Also try to update the app's global Var.cool if possible
90
- try {
91
- val palettes = getAvailablePalettes()
92
- val idx = palettes.indexOfFirst { it.equals(name, ignoreCase = true) }
93
- if (idx != -1) {
94
- updateAcol(idx.toFloat())
95
- }
96
- } catch (e: Exception) {
97
- Log.e(TAG, "setPalette: Failed to update Var.cool", e)
98
- }
99
89
  }
100
90
 
101
91
  fun getAvailablePalettes(): List<String> {
@@ -463,15 +453,6 @@ object FlirManager {
463
453
  }
464
454
 
465
455
  coolField?.set(null, shaderIdx)
466
-
467
- // Standard FLIR palette list
468
- val paletteNames = getAvailablePalettes()
469
- val maxEff = paletteNames.size
470
- val paletteIdx = rawIdx % maxEff
471
- val safeIdx = if (paletteIdx < 0) paletteIdx + maxEff else paletteIdx
472
-
473
- val targetPaletteName = paletteNames[safeIdx]
474
- sdkManager?.setPalette(targetPaletteName)
475
456
 
476
457
  } catch (e: Throwable) {
477
458
  Log.w(TAG, "updateAcol reflection failed: ${e.message}")
@@ -34,7 +34,7 @@ class FlirModule(private val reactContext: ReactApplicationContext) : ReactConte
34
34
  // Simple placeholder conversion: converts an ARGB color to a pseudo-temperature value.
35
35
  // Replace with SDK call when integrating thermalsdk APIs.
36
36
  @ReactMethod
37
- fun getTemperatureFromColor(color: Int, promise: com.facebook.react.bridge.Promise?) {
37
+ fun getTemperatureFromColor(color: Int, promise: Promise?) {
38
38
  try {
39
39
  val r = (color shr 16) and 0xFF
40
40
  val g = (color shr 8) and 0xFF
@@ -305,17 +305,18 @@ class FlirModule(private val reactContext: ReactApplicationContext) : ReactConte
305
305
 
306
306
  @ReactMethod
307
307
  fun stopFlir(promise: Promise?) {
308
- if (isDebounced()) {
309
- promise?.resolve(false)
310
- return
311
- }
312
- try {
313
- FlirManager.stop()
314
- promise?.resolve(true)
315
- } catch (e: Exception) {
316
- promise?.reject("ERR_FLIR_STOP", e)
317
- }
318
- }
308
+ if (isDebounced()) {
309
+ promise?.resolve(false)
310
+ return
311
+ }
312
+ try {
313
+ FlirManager.stop()
314
+ promise?.resolve(true)
315
+ } catch (e: Exception) {
316
+ promise?.reject("ERR_FLIR_STOP", e)
317
+ }
318
+ }
319
+
319
320
 
320
321
  @ReactMethod
321
322
  fun simulateFlirContextLoss(promise: Promise?) {
@@ -440,7 +441,7 @@ class FlirModule(private val reactContext: ReactApplicationContext) : ReactConte
440
441
  }
441
442
 
442
443
  @ReactMethod
443
- fun getDebugInfo(promise: com.facebook.react.bridge.Promise?) {
444
+ fun getDebugInfo(promise: Promise?) {
444
445
  try {
445
446
  val result = com.facebook.react.bridge.Arguments.createMap()
446
447
 
@@ -134,12 +134,17 @@ public class FlirSdkManager {
134
134
  notifyError("SDK not initialized");
135
135
  return;
136
136
  }
137
- if (isScanning)
138
- return;
137
+ if (isScanning) {
138
+ Log.d(TAG, "Discovery already running, ensuring clean state...");
139
+ try {
140
+ DiscoveryFactory.getInstance().stop();
141
+ } catch (Throwable ignored) {}
142
+ isScanning = false;
143
+ }
139
144
 
140
145
  isScanning = true;
141
146
  discoveredDevices.clear();
142
- Log.d(TAG, "Starting discovery...");
147
+ Log.d(TAG, "Starting discovery for all interfaces...");
143
148
 
144
149
  try {
145
150
  DiscoveryFactory.getInstance().scan(
@@ -157,19 +162,23 @@ public class FlirSdkManager {
157
162
  }
158
163
 
159
164
  public void stopScan() {
160
- if (!isScanning) return;
161
- isScanning = false;
162
- executor.execute(this::stopScanInternal);
165
+ executor.execute(() -> {
166
+ if (!isScanning) return;
167
+ isScanning = false;
168
+ stopScanInternal();
169
+ });
163
170
  }
164
171
 
165
172
  private void stopScanInternal() {
166
173
  try {
167
- Log.d(TAG, "Stopping discovery...");
174
+ Log.d(TAG, "Stopping all discovery scanners...");
168
175
  // Use zero-arg stop() as seen in official samples to stop all scanners
169
176
  DiscoveryFactory.getInstance().stop();
170
177
  Log.d(TAG, "Discovery stopped successfully");
171
- } catch (Exception e) {
172
- Log.w(TAG, "Stop scan warning (internal SDK): " + e.getMessage());
178
+ } catch (Throwable t) {
179
+ // This catches the notorious 'Receiver not registered' IllegalArgumentException
180
+ // and any other JNI-bubbled exceptions during teardown.
181
+ Log.w(TAG, "Stop scan suppressed (SDK internal race): " + t.getMessage());
173
182
  }
174
183
  }
175
184
 
@@ -297,6 +306,10 @@ public class FlirSdkManager {
297
306
 
298
307
  public void disconnect() {
299
308
  executor.execute(() -> {
309
+ if (isScanning) {
310
+ isScanning = false;
311
+ stopScanInternal();
312
+ }
300
313
  stopStreamInternal();
301
314
 
302
315
  if (camera != null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ilabs-flir",
3
- "version": "2.4.6",
3
+ "version": "2.4.7",
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",