ilabs-flir 2.0.4 → 2.0.5

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.
Files changed (35) hide show
  1. package/Flir.podspec +139 -139
  2. package/README.md +1066 -1066
  3. package/android/Flir/build.gradle.kts +72 -72
  4. package/android/Flir/src/main/AndroidManifest.xml +45 -45
  5. package/android/Flir/src/main/java/flir/android/FlirCommands.java +136 -136
  6. package/android/Flir/src/main/java/flir/android/FlirFrameCache.kt +6 -6
  7. package/android/Flir/src/main/java/flir/android/FlirManager.kt +476 -476
  8. package/android/Flir/src/main/java/flir/android/FlirModule.kt +257 -257
  9. package/android/Flir/src/main/java/flir/android/FlirPackage.kt +18 -18
  10. package/android/Flir/src/main/java/flir/android/FlirSDKLoader.kt +74 -74
  11. package/android/Flir/src/main/java/flir/android/FlirSdkManager.java +583 -583
  12. package/android/Flir/src/main/java/flir/android/FlirStatus.kt +12 -12
  13. package/android/Flir/src/main/java/flir/android/FlirView.kt +48 -48
  14. package/android/Flir/src/main/java/flir/android/FlirViewManager.kt +13 -13
  15. package/app.plugin.js +381 -381
  16. package/expo-module.config.json +5 -5
  17. package/ios/Flir/src/Flir-Bridging-Header.h +34 -34
  18. package/ios/Flir/src/FlirEventEmitter.h +25 -25
  19. package/ios/Flir/src/FlirEventEmitter.m +63 -63
  20. package/ios/Flir/src/FlirManager.swift +599 -599
  21. package/ios/Flir/src/FlirModule.h +17 -17
  22. package/ios/Flir/src/FlirModule.m +713 -713
  23. package/ios/Flir/src/FlirPreviewView.h +13 -13
  24. package/ios/Flir/src/FlirPreviewView.m +171 -171
  25. package/ios/Flir/src/FlirState.h +68 -68
  26. package/ios/Flir/src/FlirState.m +135 -135
  27. package/ios/Flir/src/FlirViewManager.h +16 -16
  28. package/ios/Flir/src/FlirViewManager.m +27 -27
  29. package/package.json +72 -71
  30. package/react-native.config.js +14 -14
  31. package/scripts/fetch-binaries.js +47 -5
  32. package/sdk-manifest.json +50 -50
  33. package/src/index.d.ts +63 -63
  34. package/src/index.js +7 -7
  35. package/src/index.ts +6 -6
@@ -1,257 +1,257 @@
1
- package flir.android
2
-
3
- import android.util.Log
4
- import com.facebook.react.bridge.Promise
5
- import com.facebook.react.bridge.ReactApplicationContext
6
- import com.facebook.react.bridge.ReactContextBaseJavaModule
7
- import com.facebook.react.bridge.ReactMethod
8
- import com.facebook.react.modules.core.DeviceEventManagerModule
9
-
10
- class FlirModule(private val reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
11
-
12
- companion object {
13
- private const val TAG = "FlirModule"
14
- }
15
-
16
- override fun getName(): String = "FlirModule"
17
-
18
- // Required for RN event emitter support
19
- private var listenerCount = 0
20
-
21
- @ReactMethod
22
- fun addListener(eventName: String) {
23
- listenerCount++
24
- Log.d(TAG, "addListener: $eventName (count: $listenerCount)")
25
- }
26
-
27
- @ReactMethod
28
- fun removeListeners(count: Int) {
29
- listenerCount -= count
30
- if (listenerCount < 0) listenerCount = 0
31
- Log.d(TAG, "removeListeners: $count (remaining: $listenerCount)")
32
- }
33
-
34
- // Simple placeholder conversion: converts an ARGB color to a pseudo-temperature value.
35
- // Replace with SDK call when integrating thermalsdk APIs.
36
- @ReactMethod
37
- fun getTemperatureFromColor(color: Int, promise: Promise) {
38
- try {
39
- val r = (color shr 16) and 0xFF
40
- val g = (color shr 8) and 0xFF
41
- val b = color and 0xFF
42
- // Luminance-like value scaled to a plausible temperature range (0°C - 400°C)
43
- val lum = 0.2126 * r + 0.7152 * g + 0.0722 * b
44
- val temp = 0.0 + (lum / 255.0) * 400.0
45
- promise.resolve(temp)
46
- } catch (e: Exception) {
47
- promise.reject("ERR_FLIR_CONVERT", e)
48
- }
49
- }
50
-
51
- @ReactMethod
52
- fun getLatestFramePath(promise: Promise) {
53
- try {
54
- val path = FlirFrameCache.latestFramePath
55
- if (path != null) promise.resolve(path) else promise.resolve(null)
56
- } catch (e: Exception) {
57
- promise.reject("ERR_FLIR_PATH", e)
58
- }
59
- }
60
-
61
- @ReactMethod
62
- fun getTemperatureAt(x: Int, y: Int, promise: Promise) {
63
- try {
64
- val temp = FlirManager.getTemperatureAt(x, y)
65
- if (temp != null) promise.resolve(temp) else promise.reject("ERR_NO_DATA", "No temperature data available")
66
- } catch (e: Exception) {
67
- promise.reject("ERR_FLIR_SAMPLE", e)
68
- }
69
- }
70
-
71
- @ReactMethod
72
- fun isEmulator(promise: Promise) {
73
- try {
74
- promise.resolve(FlirManager.isEmulator())
75
- } catch (e: Exception) {
76
- promise.reject("ERR_FLIR_EMULATOR_CHECK", e)
77
- }
78
- }
79
-
80
- @ReactMethod
81
- fun isDeviceConnected(promise: Promise) {
82
- try {
83
- promise.resolve(FlirManager.isDeviceConnected())
84
- } catch (e: Exception) {
85
- promise.reject("ERR_FLIR_DEVICE_CHECK", e)
86
- }
87
- }
88
-
89
- @ReactMethod
90
- fun getConnectedDeviceInfo(promise: Promise) {
91
- try {
92
- promise.resolve(FlirManager.getConnectedDeviceInfo())
93
- } catch (e: Exception) {
94
- promise.reject("ERR_FLIR_DEVICE_INFO", e)
95
- }
96
- }
97
-
98
- @ReactMethod
99
- fun isSDKDownloaded(promise: Promise) {
100
- try {
101
- val available = FlirSDKLoader.isSDKAvailable(reactContext)
102
- promise.resolve(available)
103
- } catch (e: Exception) {
104
- promise.reject("ERR_FLIR_SDK_CHECK", e)
105
- }
106
- }
107
-
108
- @ReactMethod
109
- fun getSDKStatus(promise: Promise) {
110
- try {
111
- val available = FlirSDKLoader.isSDKAvailable(reactContext)
112
- val arch = FlirSDKLoader.getDeviceArch()
113
- val dexPath = FlirSDKLoader.getDexPath(reactContext)
114
- val nativeLibDir = FlirSDKLoader.getNativeLibDir(reactContext)
115
-
116
- val result = com.facebook.react.bridge.Arguments.createMap()
117
- result.putBoolean("available", available)
118
- result.putString("arch", arch)
119
- result.putString("dexPath", dexPath?.absolutePath ?: "not present (bundled SDK missing)")
120
- result.putString("nativeLibPath", nativeLibDir?.absolutePath ?: "not present (bundled SDK missing)")
121
- result.putBoolean("dexExists", dexPath?.exists() == true)
122
- result.putBoolean("nativeLibsExist", nativeLibDir?.exists() == true)
123
-
124
- promise.resolve(result)
125
- } catch (e: Exception) {
126
- promise.reject("ERR_FLIR_SDK_STATUS", e)
127
- }
128
- }
129
-
130
- @ReactMethod
131
- fun getDiscoveredDevices(promise: Promise) {
132
- try {
133
- val devices = FlirManager.getDiscoveredDevices()
134
- val result = com.facebook.react.bridge.Arguments.createArray()
135
-
136
- devices.forEach { identity ->
137
- val deviceMap = com.facebook.react.bridge.Arguments.createMap()
138
- deviceMap.putString("id", identity.deviceId)
139
- deviceMap.putString("name", identity.deviceId)
140
- deviceMap.putString("communicationType", identity.communicationInterface.name)
141
- deviceMap.putBoolean("isEmulator", identity.communicationInterface.name == "EMULATOR")
142
- result.pushMap(deviceMap)
143
- }
144
-
145
- promise.resolve(result)
146
- } catch (e: Exception) {
147
- promise.reject("ERR_FLIR_DEVICES", e)
148
- }
149
- }
150
-
151
- @ReactMethod
152
- fun startEmulator(emulatorType: String, promise: Promise) {
153
- try {
154
- // Ensure SDK is initialized with context before starting discovery
155
- FlirManager.init(reactContext)
156
- // With simplified API, just start discovery - emulators are discovered like any device
157
- FlirManager.startDiscovery(true)
158
- promise.resolve(true)
159
- } catch (e: Exception) {
160
- promise.reject("ERR_FLIR_EMULATOR", e)
161
- }
162
- }
163
-
164
- @ReactMethod
165
- fun connectToDevice(deviceId: String, promise: Promise) {
166
- try {
167
- // Ensure SDK is initialized with context before connecting
168
- FlirManager.init(reactContext)
169
- FlirManager.connectToDevice(deviceId)
170
- promise.resolve(true)
171
- } catch (e: Exception) {
172
- promise.reject("ERR_FLIR_CONNECT", e)
173
- }
174
- }
175
-
176
- @ReactMethod
177
- fun startDiscovery(promise: Promise) {
178
- try {
179
- // Ensure SDK is initialized with context before starting discovery
180
- FlirManager.init(reactContext)
181
- FlirManager.startDiscovery(true)
182
- promise.resolve(true)
183
- } catch (e: Exception) {
184
- promise.reject("ERR_FLIR_DISCOVERY", e)
185
- }
186
- }
187
-
188
- @ReactMethod
189
- fun stopDiscovery(promise: Promise) {
190
- try {
191
- FlirManager.stopDiscovery()
192
- promise.resolve(true)
193
- } catch (e: Exception) {
194
- promise.reject("ERR_FLIR_STOP_DISCOVERY", e)
195
- }
196
- }
197
-
198
- @ReactMethod
199
- fun stopFlir(promise: Promise) {
200
- try {
201
- FlirManager.stop()
202
- promise.resolve(true)
203
- } catch (e: Exception) {
204
- promise.reject("ERR_FLIR_STOP", e)
205
- }
206
- }
207
-
208
- @ReactMethod
209
- fun initializeSDK(promise: Promise) {
210
- try {
211
- FlirManager.init(reactContext)
212
-
213
- val result = com.facebook.react.bridge.Arguments.createMap()
214
- result.putBoolean("initialized", true)
215
- result.putString("message", "SDK initialized successfully")
216
- promise.resolve(result)
217
- } catch (e: Exception) {
218
- val result = com.facebook.react.bridge.Arguments.createMap()
219
- result.putBoolean("initialized", false)
220
- result.putString("error", e.message ?: "Unknown error")
221
- result.putString("errorType", e.javaClass.simpleName)
222
- promise.resolve(result)
223
- }
224
- }
225
-
226
- @ReactMethod
227
- fun getDebugInfo(promise: Promise) {
228
- try {
229
- val result = com.facebook.react.bridge.Arguments.createMap()
230
-
231
- // SDK availability
232
- result.putBoolean("sdkAvailable", FlirSDKLoader.isSDKAvailable(reactContext))
233
- result.putString("arch", FlirSDKLoader.getDeviceArch())
234
-
235
- // Check if FLIR SDK classes are loadable
236
- val classesLoaded = try {
237
- Class.forName("com.flir.thermalsdk.androidsdk.ThermalSdkAndroid")
238
- Class.forName("com.flir.thermalsdk.live.discovery.DiscoveryFactory")
239
- true
240
- } catch (e: ClassNotFoundException) {
241
- false
242
- }
243
- result.putBoolean("sdkClassesLoaded", classesLoaded)
244
-
245
- // Discovery state
246
- val devices = FlirManager.getDiscoveredDevices()
247
- result.putInt("discoveredDeviceCount", devices.size)
248
- result.putBoolean("isConnected", FlirManager.isConnected())
249
- result.putBoolean("isStreaming", FlirManager.isStreaming())
250
- result.putString("connectedDevice", FlirManager.getConnectedDeviceInfo())
251
-
252
- promise.resolve(result)
253
- } catch (e: Exception) {
254
- promise.reject("ERR_DEBUG_INFO", e)
255
- }
256
- }
257
- }
1
+ package flir.android
2
+
3
+ import android.util.Log
4
+ import com.facebook.react.bridge.Promise
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
7
+ import com.facebook.react.bridge.ReactMethod
8
+ import com.facebook.react.modules.core.DeviceEventManagerModule
9
+
10
+ class FlirModule(private val reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
11
+
12
+ companion object {
13
+ private const val TAG = "FlirModule"
14
+ }
15
+
16
+ override fun getName(): String = "FlirModule"
17
+
18
+ // Required for RN event emitter support
19
+ private var listenerCount = 0
20
+
21
+ @ReactMethod
22
+ fun addListener(eventName: String) {
23
+ listenerCount++
24
+ Log.d(TAG, "addListener: $eventName (count: $listenerCount)")
25
+ }
26
+
27
+ @ReactMethod
28
+ fun removeListeners(count: Int) {
29
+ listenerCount -= count
30
+ if (listenerCount < 0) listenerCount = 0
31
+ Log.d(TAG, "removeListeners: $count (remaining: $listenerCount)")
32
+ }
33
+
34
+ // Simple placeholder conversion: converts an ARGB color to a pseudo-temperature value.
35
+ // Replace with SDK call when integrating thermalsdk APIs.
36
+ @ReactMethod
37
+ fun getTemperatureFromColor(color: Int, promise: Promise) {
38
+ try {
39
+ val r = (color shr 16) and 0xFF
40
+ val g = (color shr 8) and 0xFF
41
+ val b = color and 0xFF
42
+ // Luminance-like value scaled to a plausible temperature range (0°C - 400°C)
43
+ val lum = 0.2126 * r + 0.7152 * g + 0.0722 * b
44
+ val temp = 0.0 + (lum / 255.0) * 400.0
45
+ promise.resolve(temp)
46
+ } catch (e: Exception) {
47
+ promise.reject("ERR_FLIR_CONVERT", e)
48
+ }
49
+ }
50
+
51
+ @ReactMethod
52
+ fun getLatestFramePath(promise: Promise) {
53
+ try {
54
+ val path = FlirFrameCache.latestFramePath
55
+ if (path != null) promise.resolve(path) else promise.resolve(null)
56
+ } catch (e: Exception) {
57
+ promise.reject("ERR_FLIR_PATH", e)
58
+ }
59
+ }
60
+
61
+ @ReactMethod
62
+ fun getTemperatureAt(x: Int, y: Int, promise: Promise) {
63
+ try {
64
+ val temp = FlirManager.getTemperatureAt(x, y)
65
+ if (temp != null) promise.resolve(temp) else promise.reject("ERR_NO_DATA", "No temperature data available")
66
+ } catch (e: Exception) {
67
+ promise.reject("ERR_FLIR_SAMPLE", e)
68
+ }
69
+ }
70
+
71
+ @ReactMethod
72
+ fun isEmulator(promise: Promise) {
73
+ try {
74
+ promise.resolve(FlirManager.isEmulator())
75
+ } catch (e: Exception) {
76
+ promise.reject("ERR_FLIR_EMULATOR_CHECK", e)
77
+ }
78
+ }
79
+
80
+ @ReactMethod
81
+ fun isDeviceConnected(promise: Promise) {
82
+ try {
83
+ promise.resolve(FlirManager.isDeviceConnected())
84
+ } catch (e: Exception) {
85
+ promise.reject("ERR_FLIR_DEVICE_CHECK", e)
86
+ }
87
+ }
88
+
89
+ @ReactMethod
90
+ fun getConnectedDeviceInfo(promise: Promise) {
91
+ try {
92
+ promise.resolve(FlirManager.getConnectedDeviceInfo())
93
+ } catch (e: Exception) {
94
+ promise.reject("ERR_FLIR_DEVICE_INFO", e)
95
+ }
96
+ }
97
+
98
+ @ReactMethod
99
+ fun isSDKDownloaded(promise: Promise) {
100
+ try {
101
+ val available = FlirSDKLoader.isSDKAvailable(reactContext)
102
+ promise.resolve(available)
103
+ } catch (e: Exception) {
104
+ promise.reject("ERR_FLIR_SDK_CHECK", e)
105
+ }
106
+ }
107
+
108
+ @ReactMethod
109
+ fun getSDKStatus(promise: Promise) {
110
+ try {
111
+ val available = FlirSDKLoader.isSDKAvailable(reactContext)
112
+ val arch = FlirSDKLoader.getDeviceArch()
113
+ val dexPath = FlirSDKLoader.getDexPath(reactContext)
114
+ val nativeLibDir = FlirSDKLoader.getNativeLibDir(reactContext)
115
+
116
+ val result = com.facebook.react.bridge.Arguments.createMap()
117
+ result.putBoolean("available", available)
118
+ result.putString("arch", arch)
119
+ result.putString("dexPath", dexPath?.absolutePath ?: "not present (bundled SDK missing)")
120
+ result.putString("nativeLibPath", nativeLibDir?.absolutePath ?: "not present (bundled SDK missing)")
121
+ result.putBoolean("dexExists", dexPath?.exists() == true)
122
+ result.putBoolean("nativeLibsExist", nativeLibDir?.exists() == true)
123
+
124
+ promise.resolve(result)
125
+ } catch (e: Exception) {
126
+ promise.reject("ERR_FLIR_SDK_STATUS", e)
127
+ }
128
+ }
129
+
130
+ @ReactMethod
131
+ fun getDiscoveredDevices(promise: Promise) {
132
+ try {
133
+ val devices = FlirManager.getDiscoveredDevices()
134
+ val result = com.facebook.react.bridge.Arguments.createArray()
135
+
136
+ devices.forEach { identity ->
137
+ val deviceMap = com.facebook.react.bridge.Arguments.createMap()
138
+ deviceMap.putString("id", identity.deviceId)
139
+ deviceMap.putString("name", identity.deviceId)
140
+ deviceMap.putString("communicationType", identity.communicationInterface.name)
141
+ deviceMap.putBoolean("isEmulator", identity.communicationInterface.name == "EMULATOR")
142
+ result.pushMap(deviceMap)
143
+ }
144
+
145
+ promise.resolve(result)
146
+ } catch (e: Exception) {
147
+ promise.reject("ERR_FLIR_DEVICES", e)
148
+ }
149
+ }
150
+
151
+ @ReactMethod
152
+ fun startEmulator(emulatorType: String, promise: Promise) {
153
+ try {
154
+ // Ensure SDK is initialized with context before starting discovery
155
+ FlirManager.init(reactContext)
156
+ // With simplified API, just start discovery - emulators are discovered like any device
157
+ FlirManager.startDiscovery(true)
158
+ promise.resolve(true)
159
+ } catch (e: Exception) {
160
+ promise.reject("ERR_FLIR_EMULATOR", e)
161
+ }
162
+ }
163
+
164
+ @ReactMethod
165
+ fun connectToDevice(deviceId: String, promise: Promise) {
166
+ try {
167
+ // Ensure SDK is initialized with context before connecting
168
+ FlirManager.init(reactContext)
169
+ FlirManager.connectToDevice(deviceId)
170
+ promise.resolve(true)
171
+ } catch (e: Exception) {
172
+ promise.reject("ERR_FLIR_CONNECT", e)
173
+ }
174
+ }
175
+
176
+ @ReactMethod
177
+ fun startDiscovery(promise: Promise) {
178
+ try {
179
+ // Ensure SDK is initialized with context before starting discovery
180
+ FlirManager.init(reactContext)
181
+ FlirManager.startDiscovery(true)
182
+ promise.resolve(true)
183
+ } catch (e: Exception) {
184
+ promise.reject("ERR_FLIR_DISCOVERY", e)
185
+ }
186
+ }
187
+
188
+ @ReactMethod
189
+ fun stopDiscovery(promise: Promise) {
190
+ try {
191
+ FlirManager.stopDiscovery()
192
+ promise.resolve(true)
193
+ } catch (e: Exception) {
194
+ promise.reject("ERR_FLIR_STOP_DISCOVERY", e)
195
+ }
196
+ }
197
+
198
+ @ReactMethod
199
+ fun stopFlir(promise: Promise) {
200
+ try {
201
+ FlirManager.stop()
202
+ promise.resolve(true)
203
+ } catch (e: Exception) {
204
+ promise.reject("ERR_FLIR_STOP", e)
205
+ }
206
+ }
207
+
208
+ @ReactMethod
209
+ fun initializeSDK(promise: Promise) {
210
+ try {
211
+ FlirManager.init(reactContext)
212
+
213
+ val result = com.facebook.react.bridge.Arguments.createMap()
214
+ result.putBoolean("initialized", true)
215
+ result.putString("message", "SDK initialized successfully")
216
+ promise.resolve(result)
217
+ } catch (e: Exception) {
218
+ val result = com.facebook.react.bridge.Arguments.createMap()
219
+ result.putBoolean("initialized", false)
220
+ result.putString("error", e.message ?: "Unknown error")
221
+ result.putString("errorType", e.javaClass.simpleName)
222
+ promise.resolve(result)
223
+ }
224
+ }
225
+
226
+ @ReactMethod
227
+ fun getDebugInfo(promise: Promise) {
228
+ try {
229
+ val result = com.facebook.react.bridge.Arguments.createMap()
230
+
231
+ // SDK availability
232
+ result.putBoolean("sdkAvailable", FlirSDKLoader.isSDKAvailable(reactContext))
233
+ result.putString("arch", FlirSDKLoader.getDeviceArch())
234
+
235
+ // Check if FLIR SDK classes are loadable
236
+ val classesLoaded = try {
237
+ Class.forName("com.flir.thermalsdk.androidsdk.ThermalSdkAndroid")
238
+ Class.forName("com.flir.thermalsdk.live.discovery.DiscoveryFactory")
239
+ true
240
+ } catch (e: ClassNotFoundException) {
241
+ false
242
+ }
243
+ result.putBoolean("sdkClassesLoaded", classesLoaded)
244
+
245
+ // Discovery state
246
+ val devices = FlirManager.getDiscoveredDevices()
247
+ result.putInt("discoveredDeviceCount", devices.size)
248
+ result.putBoolean("isConnected", FlirManager.isConnected())
249
+ result.putBoolean("isStreaming", FlirManager.isStreaming())
250
+ result.putString("connectedDevice", FlirManager.getConnectedDeviceInfo())
251
+
252
+ promise.resolve(result)
253
+ } catch (e: Exception) {
254
+ promise.reject("ERR_DEBUG_INFO", e)
255
+ }
256
+ }
257
+ }
@@ -1,18 +1,18 @@
1
- package flir.android
2
-
3
- import com.facebook.react.ReactPackage
4
- import com.facebook.react.bridge.NativeModule
5
- import com.facebook.react.bridge.ReactApplicationContext
6
- import com.facebook.react.uimanager.ViewManager
7
-
8
- class FlirPackage : ReactPackage {
9
- override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
10
- return listOf(
11
- FlirModule(reactContext)
12
- )
13
- }
14
-
15
- override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
16
- return listOf(FlirViewManager())
17
- }
18
- }
1
+ package flir.android
2
+
3
+ import com.facebook.react.ReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.uimanager.ViewManager
7
+
8
+ class FlirPackage : ReactPackage {
9
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
10
+ return listOf(
11
+ FlirModule(reactContext)
12
+ )
13
+ }
14
+
15
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
16
+ return listOf(FlirViewManager())
17
+ }
18
+ }