ilabs-flir 1.0.3 → 1.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.
- package/android/Flir/build.gradle.kts +14 -27
- package/android/Flir/libs/androidsdk-release.aar +0 -0
- package/android/Flir/libs/thermalsdk-release.aar +0 -0
- package/android/Flir/src/main/java/flir/android/FlirCommands.java +40 -15
- package/android/Flir/src/main/java/flir/android/FlirDownloadManager.kt +26 -46
- package/android/Flir/src/main/java/flir/android/FlirManager.kt +265 -42
- package/android/Flir/src/main/java/flir/android/FlirModule.kt +32 -0
- package/android/Flir/src/main/java/flir/android/FlirSDKLoader.kt +84 -195
- package/android/Flir/src/main/java/flir/android/FlirSdkManager.java +667 -797
- package/package.json +1 -1
- package/sdk-manifest.json +14 -7
- package/src/index.d.ts +21 -1
- package/android/Flir/libs/flir-stubs.jar +0 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/ErrorCodeException.java +0 -14
- package/android/Flir/src/main/java/com/flir/thermalsdk/image/ImageBuffer.java +0 -11
- package/android/Flir/src/main/java/com/flir/thermalsdk/image/JavaImageBuffer.java +0 -35
- package/android/Flir/src/main/java/com/flir/thermalsdk/image/Palette.java +0 -15
- package/android/Flir/src/main/java/com/flir/thermalsdk/image/PaletteManager.java +0 -16
- package/android/Flir/src/main/java/com/flir/thermalsdk/image/Point.java +0 -11
- package/android/Flir/src/main/java/com/flir/thermalsdk/image/ThermalImage.java +0 -23
- package/android/Flir/src/main/java/com/flir/thermalsdk/image/ThermalValue.java +0 -9
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/CameraType.java +0 -8
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/CommunicationInterface.java +0 -16
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/Identity.java +0 -23
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/IpSettings.java +0 -9
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/connectivity/ConnectionStatusListener.java +0 -7
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/remote/OnReceived.java +0 -5
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/remote/OnRemoteError.java +0 -7
- package/android/Flir/src/main/java/flir/android/CameraHandler.java +0 -224
- package/android/Flir/src/main/java/flir/android/FlirConnectionManager.java +0 -354
- package/android/Flir/src/main/java/flir/android/FlirController.kt +0 -11
- package/android/Flir/src/main/java/flir/android/FlirDiscoveryManager.java +0 -236
- package/android/Flir/src/main/java/flir/android/FrameDataHolder.java +0 -14
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
package flir.android;
|
|
2
|
-
|
|
3
|
-
import android.graphics.Bitmap;
|
|
4
|
-
import android.util.Log;
|
|
5
|
-
import com.flir.thermalsdk.ErrorCodeException;
|
|
6
|
-
import com.flir.thermalsdk.androidsdk.image.BitmapAndroid;
|
|
7
|
-
import com.flir.thermalsdk.image.Palette;
|
|
8
|
-
import com.flir.thermalsdk.image.PaletteManager;
|
|
9
|
-
import com.flir.thermalsdk.live.Camera;
|
|
10
|
-
import com.flir.thermalsdk.live.CommunicationInterface;
|
|
11
|
-
import com.flir.thermalsdk.live.ConnectParameters;
|
|
12
|
-
import com.flir.thermalsdk.live.Identity;
|
|
13
|
-
import com.flir.thermalsdk.ErrorCode;
|
|
14
|
-
import com.flir.thermalsdk.live.connectivity.ConnectionStatusListener;
|
|
15
|
-
import com.flir.thermalsdk.live.remote.OnRemoteError;
|
|
16
|
-
import com.flir.thermalsdk.live.remote.OnReceived;
|
|
17
|
-
import com.flir.thermalsdk.live.streaming.Stream;
|
|
18
|
-
import com.flir.thermalsdk.live.streaming.ThermalStreamer;
|
|
19
|
-
import java.net.InetAddress;
|
|
20
|
-
import java.util.List;
|
|
21
|
-
|
|
22
|
-
public class FlirConnectionManager {
|
|
23
|
-
private static final String TAG = "FlirConnectionManager";
|
|
24
|
-
private static FlirConnectionManager instance;
|
|
25
|
-
|
|
26
|
-
private Camera camera;
|
|
27
|
-
private ThermalStreamer thermalStreamer;
|
|
28
|
-
private Identity currentIdentity;
|
|
29
|
-
private boolean isStreaming = false;
|
|
30
|
-
private Palette currentPalette;
|
|
31
|
-
private Bitmap latestFrame;
|
|
32
|
-
|
|
33
|
-
// Event callback interface
|
|
34
|
-
public interface ConnectionEventCallback {
|
|
35
|
-
void onConnectionStatusChanged(boolean connected, String deviceId);
|
|
36
|
-
|
|
37
|
-
void onError(String message);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
private ConnectionEventCallback eventCallback;
|
|
41
|
-
|
|
42
|
-
// Callback for frame updates
|
|
43
|
-
public interface FrameCallback {
|
|
44
|
-
void onFrameReceived(Bitmap frame);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
private FrameCallback frameCallback;
|
|
48
|
-
|
|
49
|
-
private FlirConnectionManager() {
|
|
50
|
-
// Default to Iron palette
|
|
51
|
-
List<Palette> palettes = PaletteManager.getDefaultPalettes();
|
|
52
|
-
currentPalette = palettes.stream()
|
|
53
|
-
.filter(p -> "iron".equalsIgnoreCase(p.name))
|
|
54
|
-
.findFirst()
|
|
55
|
-
.orElse(palettes.get(0));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
public static synchronized FlirConnectionManager getInstance() {
|
|
59
|
-
if (instance == null) {
|
|
60
|
-
instance = new FlirConnectionManager();
|
|
61
|
-
}
|
|
62
|
-
return instance;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
public void setEventCallback(ConnectionEventCallback callback) {
|
|
66
|
-
this.eventCallback = callback;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public void selectDevice(Identity identity) {
|
|
70
|
-
Log.i(TAG, "[FLIR] 📱 Selecting device: " + identity.deviceId);
|
|
71
|
-
|
|
72
|
-
// ALWAYS disconnect from current device first
|
|
73
|
-
if (isStreaming || camera != null) {
|
|
74
|
-
Log.i(TAG, "[FLIR] 🔌 Disconnecting from current device...");
|
|
75
|
-
stopStreaming();
|
|
76
|
-
disconnect();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
currentIdentity = identity;
|
|
80
|
-
|
|
81
|
-
// Connect in background
|
|
82
|
-
new Thread(() -> {
|
|
83
|
-
try {
|
|
84
|
-
connectToDevice();
|
|
85
|
-
startStreaming();
|
|
86
|
-
} catch (Exception e) {
|
|
87
|
-
Log.e(TAG, "[FLIR] Failed to connect/stream", e);
|
|
88
|
-
emitError("Failed to connect: " + e.getMessage());
|
|
89
|
-
}
|
|
90
|
-
}).start();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
private void connectToDevice() throws Exception {
|
|
94
|
-
Log.i(TAG, "[FLIR] 🔌 Connecting to: " + currentIdentity.deviceId);
|
|
95
|
-
|
|
96
|
-
camera = new Camera();
|
|
97
|
-
|
|
98
|
-
// Authenticate for network cameras
|
|
99
|
-
if (currentIdentity.communicationInterface == CommunicationInterface.NETWORK) {
|
|
100
|
-
if (currentIdentity.ipSettings != null) {
|
|
101
|
-
String ipAddress = currentIdentity.ipSettings.ipAddress;
|
|
102
|
-
// Use generic app name or allow injection if needed
|
|
103
|
-
String appName = "ThermalCameraApp";
|
|
104
|
-
Log.d(TAG, "[FLIR] Authenticating network camera at " + ipAddress);
|
|
105
|
-
// authenticate method might vary, assuming simple overload or need to check SDK
|
|
106
|
-
// camera.authenticate(InetAddress.getByName(ipAddress), appName, ...);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Connect to device
|
|
111
|
-
camera.connect(
|
|
112
|
-
currentIdentity,
|
|
113
|
-
errorCode -> {
|
|
114
|
-
Log.w(TAG, "[FLIR] ❌ Connection error: " + errorCode);
|
|
115
|
-
emitError("Connection error: " + errorCode.toString());
|
|
116
|
-
},
|
|
117
|
-
new ConnectParameters());
|
|
118
|
-
|
|
119
|
-
Log.i(TAG, "[FLIR] ✅ Connected successfully");
|
|
120
|
-
emitConnectionStatus(true);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// ... authenticate method ...
|
|
124
|
-
|
|
125
|
-
private void startStreaming() {
|
|
126
|
-
if (camera == null) {
|
|
127
|
-
Log.w(TAG, "[FLIR] Cannot start streaming - no camera connected");
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Find thermal stream
|
|
132
|
-
Stream thermalStream = camera.getStreams().stream()
|
|
133
|
-
.filter(Stream::isThermal)
|
|
134
|
-
.findFirst()
|
|
135
|
-
.orElse(null);
|
|
136
|
-
|
|
137
|
-
if (thermalStream == null) {
|
|
138
|
-
Log.w(TAG, "[FLIR] No thermal stream available");
|
|
139
|
-
emitError("No thermal stream available");
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
Log.i(TAG, "[FLIR] 🎥 Starting thermal stream...");
|
|
144
|
-
|
|
145
|
-
thermalStreamer = new ThermalStreamer(thermalStream);
|
|
146
|
-
|
|
147
|
-
thermalStream.start(
|
|
148
|
-
unused -> {
|
|
149
|
-
// Update stream in background
|
|
150
|
-
new Thread(FlirConnectionManager.this::updateFrame).start();
|
|
151
|
-
},
|
|
152
|
-
error -> {
|
|
153
|
-
Log.w(TAG, "[FLIR] Stream error: " + error);
|
|
154
|
-
emitError("Stream error: " + error.toString());
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
isStreaming = true;
|
|
158
|
-
Log.i(TAG, "[FLIR] ✅ Streaming started");
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
private synchronized void updateFrame() {
|
|
162
|
-
if (thermalStreamer == null)
|
|
163
|
-
return;
|
|
164
|
-
|
|
165
|
-
try {
|
|
166
|
-
thermalStreamer.update();
|
|
167
|
-
} catch (NullPointerException e) {
|
|
168
|
-
// Skip first few frames that may have errors
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Get image buffer
|
|
173
|
-
var imageBuffer = thermalStreamer.getImage();
|
|
174
|
-
if (imageBuffer == null)
|
|
175
|
-
return;
|
|
176
|
-
|
|
177
|
-
// Apply palette and get bitmap
|
|
178
|
-
thermalStreamer.withThermalImage(thermalImage -> {
|
|
179
|
-
if (currentPalette != null) {
|
|
180
|
-
thermalImage.setPalette(currentPalette);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
try {
|
|
184
|
-
// BitmapAndroid.createBitmap accepts ImageBuffer interface
|
|
185
|
-
Bitmap bmp = BitmapAndroid.createBitmap(imageBuffer).getBitMap();
|
|
186
|
-
if (bmp != null) {
|
|
187
|
-
latestFrame = bmp;
|
|
188
|
-
|
|
189
|
-
// Notify callback
|
|
190
|
-
if (frameCallback != null) {
|
|
191
|
-
frameCallback.onFrameReceived(bmp);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
} catch (IllegalArgumentException e) {
|
|
195
|
-
// Ignore invalid frames
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
public void stopStreaming() {
|
|
201
|
-
if (!isStreaming)
|
|
202
|
-
return;
|
|
203
|
-
|
|
204
|
-
Log.i(TAG, "[FLIR] Stopping stream...");
|
|
205
|
-
|
|
206
|
-
if (camera != null && camera.getStreams() != null) {
|
|
207
|
-
camera.getStreams().forEach(stream -> {
|
|
208
|
-
try {
|
|
209
|
-
if (stream.isStreaming()) {
|
|
210
|
-
stream.stop();
|
|
211
|
-
}
|
|
212
|
-
} catch (Exception e) {
|
|
213
|
-
Log.w(TAG, "[FLIR] Error stopping stream", e);
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
thermalStreamer = null;
|
|
219
|
-
isStreaming = false;
|
|
220
|
-
Log.d(TAG, "[FLIR] Stream stopped");
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
public void disconnect() {
|
|
224
|
-
if (camera == null)
|
|
225
|
-
return;
|
|
226
|
-
|
|
227
|
-
Log.i(TAG, "[FLIR] Disconnecting...");
|
|
228
|
-
|
|
229
|
-
stopStreaming();
|
|
230
|
-
|
|
231
|
-
try {
|
|
232
|
-
camera.disconnect();
|
|
233
|
-
} catch (Exception e) {
|
|
234
|
-
Log.w(TAG, "[FLIR] Error disconnecting", e);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
camera = null;
|
|
238
|
-
currentIdentity = null;
|
|
239
|
-
latestFrame = null;
|
|
240
|
-
|
|
241
|
-
emitConnectionStatus(false);
|
|
242
|
-
Log.d(TAG, "[FLIR] Disconnected");
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
public void setPalette(int acol) {
|
|
246
|
-
String paletteName = mapAcolToPalette(acol);
|
|
247
|
-
|
|
248
|
-
List<Palette> palettes = PaletteManager.getDefaultPalettes();
|
|
249
|
-
Palette newPalette = palettes.stream()
|
|
250
|
-
.filter(p -> paletteName.equalsIgnoreCase(p.name))
|
|
251
|
-
.findFirst()
|
|
252
|
-
.orElse(currentPalette);
|
|
253
|
-
|
|
254
|
-
if (newPalette != currentPalette) {
|
|
255
|
-
currentPalette = newPalette;
|
|
256
|
-
Log.i(TAG, "[FLIR] 🎨 Palette changed to: " + paletteName + " (acol=" + acol + ")");
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
private String mapAcolToPalette(int acol) {
|
|
261
|
-
switch (acol) {
|
|
262
|
-
case 1:
|
|
263
|
-
return "iron";
|
|
264
|
-
case 2:
|
|
265
|
-
return "rainbow";
|
|
266
|
-
case 3:
|
|
267
|
-
return "arctic";
|
|
268
|
-
case 4:
|
|
269
|
-
return "lava";
|
|
270
|
-
case 5:
|
|
271
|
-
return "grayscale";
|
|
272
|
-
case 6:
|
|
273
|
-
return "ironbow";
|
|
274
|
-
case 7:
|
|
275
|
-
return "medical";
|
|
276
|
-
case 8:
|
|
277
|
-
return "rainbow_hc";
|
|
278
|
-
case 9:
|
|
279
|
-
return "contrast";
|
|
280
|
-
case 10:
|
|
281
|
-
return "fusion";
|
|
282
|
-
case 11:
|
|
283
|
-
return "arctic2";
|
|
284
|
-
case 12:
|
|
285
|
-
return "coldest";
|
|
286
|
-
case 13:
|
|
287
|
-
return "hottest";
|
|
288
|
-
case 14:
|
|
289
|
-
return "wheel";
|
|
290
|
-
default:
|
|
291
|
-
return "iron";
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
public double getTemperatureAt(int x, int y) {
|
|
296
|
-
if (thermalStreamer == null) {
|
|
297
|
-
Log.w(TAG, "[FLIR] Cannot query temperature - no active stream");
|
|
298
|
-
return Double.NaN;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
try {
|
|
302
|
-
final double[] temp = { Double.NaN };
|
|
303
|
-
|
|
304
|
-
thermalStreamer.withThermalImage(thermalImage -> {
|
|
305
|
-
try {
|
|
306
|
-
// Get image dimensions from ImageBase (parent class)
|
|
307
|
-
int width = thermalImage.getWidth();
|
|
308
|
-
int height = thermalImage.getHeight();
|
|
309
|
-
|
|
310
|
-
// Clamp coordinates
|
|
311
|
-
int clampedX = Math.max(0, Math.min(x, width - 1));
|
|
312
|
-
int clampedY = Math.max(0, Math.min(y, height - 1));
|
|
313
|
-
|
|
314
|
-
// Query temperature using Point
|
|
315
|
-
temp[0] = thermalImage.getValueAt(new com.flir.thermalsdk.image.Point(clampedX, clampedY)).value;
|
|
316
|
-
|
|
317
|
-
Log.d(TAG, "[FLIR] 🌡️ Temperature at (" + x + "," + y + "): " + temp[0] + "°C");
|
|
318
|
-
} catch (Exception e) {
|
|
319
|
-
Log.w(TAG, "[FLIR] Error getting temperature", e);
|
|
320
|
-
}
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
return temp[0];
|
|
324
|
-
} catch (Exception e) {
|
|
325
|
-
Log.w(TAG, "[FLIR] Failed to query temperature", e);
|
|
326
|
-
return Double.NaN;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
public Bitmap getLatestFrame() {
|
|
331
|
-
return latestFrame;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
public void setFrameCallback(FrameCallback callback) {
|
|
335
|
-
this.frameCallback = callback;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
public boolean isStreaming() {
|
|
339
|
-
return isStreaming;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
private void emitConnectionStatus(boolean connected) {
|
|
343
|
-
if (eventCallback != null) {
|
|
344
|
-
eventCallback.onConnectionStatusChanged(connected,
|
|
345
|
-
currentIdentity != null ? currentIdentity.deviceId : null);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
private void emitError(String message) {
|
|
350
|
-
if (eventCallback != null) {
|
|
351
|
-
eventCallback.onError(message);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
}
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
package flir.android;
|
|
2
|
-
|
|
3
|
-
import android.util.Log;
|
|
4
|
-
import com.flir.thermalsdk.ErrorCode;
|
|
5
|
-
import com.flir.thermalsdk.live.CommunicationInterface;
|
|
6
|
-
import com.flir.thermalsdk.live.Identity;
|
|
7
|
-
import com.flir.thermalsdk.live.discovery.DiscoveredCamera;
|
|
8
|
-
import com.flir.thermalsdk.live.discovery.DiscoveryEventListener;
|
|
9
|
-
import com.flir.thermalsdk.live.discovery.DiscoveryFactory;
|
|
10
|
-
import java.util.ArrayList;
|
|
11
|
-
import java.util.List;
|
|
12
|
-
import java.util.concurrent.Executors;
|
|
13
|
-
import java.util.concurrent.ScheduledExecutorService;
|
|
14
|
-
import java.util.concurrent.TimeUnit;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* FLIR Discovery Manager
|
|
18
|
-
* Handles device discovery with 5 second timeout
|
|
19
|
-
* Supports FLIR ONE and FLIR ONE Edge emulators
|
|
20
|
-
* Emits discovered devices to React Native
|
|
21
|
-
*/
|
|
22
|
-
public class FlirDiscoveryManager {
|
|
23
|
-
private static final String TAG = "FlirDiscoveryManager";
|
|
24
|
-
private static FlirDiscoveryManager instance;
|
|
25
|
-
|
|
26
|
-
private final List<Identity> discoveredDevices = new ArrayList<>();
|
|
27
|
-
private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
|
|
28
|
-
private boolean isDiscovering = false;
|
|
29
|
-
private DiscoveryEventListener currentListener;
|
|
30
|
-
|
|
31
|
-
// Configuration variables (set by app)
|
|
32
|
-
private String flirEmulatorType = "FLIR_ONE_EDGE";
|
|
33
|
-
private boolean isEmu = false;
|
|
34
|
-
|
|
35
|
-
// Event callback interface
|
|
36
|
-
public interface DiscoveryEventCallback {
|
|
37
|
-
void onDevicesDiscovered(List<Identity> devices);
|
|
38
|
-
|
|
39
|
-
void onDiscoveryError(String error);
|
|
40
|
-
|
|
41
|
-
// Added missing methods to match usage
|
|
42
|
-
void onCameraFound(String deviceId, String cameraType, String connectionType);
|
|
43
|
-
|
|
44
|
-
void onDiscoveryError(String connectionType, String error);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
private DiscoveryEventCallback eventCallback;
|
|
48
|
-
|
|
49
|
-
private FlirDiscoveryManager() {
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public static synchronized FlirDiscoveryManager getInstance() {
|
|
53
|
-
if (instance == null) {
|
|
54
|
-
instance = new FlirDiscoveryManager();
|
|
55
|
-
}
|
|
56
|
-
return instance;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public void setEmulatorType(String type) {
|
|
60
|
-
this.flirEmulatorType = type;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
public void setIsEmu(boolean isEmu) {
|
|
64
|
-
this.isEmu = isEmu;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
public void setEventCallback(DiscoveryEventCallback callback) {
|
|
68
|
-
this.eventCallback = callback;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Start discovery with 5 second timeout
|
|
73
|
-
* Searches for NETWORK devices and EMULATOR (based on flirEmulatorType)
|
|
74
|
-
* Disconnects any currently connected device first
|
|
75
|
-
*/
|
|
76
|
-
public void startDiscovery() {
|
|
77
|
-
if (isDiscovering) {
|
|
78
|
-
Log.d(TAG, "[FLIR] Discovery already in progress");
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Disconnect current device before starting new discovery
|
|
83
|
-
Log.i(TAG, "[FLIR] 🔌 Disconnecting current device before discovery...");
|
|
84
|
-
FlirConnectionManager.getInstance().disconnect();
|
|
85
|
-
|
|
86
|
-
Log.i(TAG, "[FLIR] 🔍 Starting discovery (timeout based on isEmu)...");
|
|
87
|
-
isDiscovering = true;
|
|
88
|
-
discoveredDevices.clear();
|
|
89
|
-
|
|
90
|
-
// Determine emulator interface based on type
|
|
91
|
-
CommunicationInterface emulatorInterface = getEmulatorInterface();
|
|
92
|
-
Log.d(TAG, "[FLIR] Emulator type: " + flirEmulatorType + " -> " + emulatorInterface);
|
|
93
|
-
|
|
94
|
-
// Create discovery listener
|
|
95
|
-
currentListener = new DiscoveryEventListener() {
|
|
96
|
-
@Override
|
|
97
|
-
public void onCameraFound(DiscoveredCamera discoveredCamera) {
|
|
98
|
-
Identity identity = discoveredCamera.identity; // Field access
|
|
99
|
-
|
|
100
|
-
// Avoid duplicates
|
|
101
|
-
boolean alreadyAdded = false;
|
|
102
|
-
for (Identity existing : discoveredDevices) {
|
|
103
|
-
if (existing.deviceId.equals(identity.deviceId)) {
|
|
104
|
-
alreadyAdded = true;
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (!alreadyAdded) {
|
|
110
|
-
discoveredDevices.add(identity);
|
|
111
|
-
String type = "UNKNOWN";
|
|
112
|
-
if (identity.communicationInterface != null) {
|
|
113
|
-
type = identity.communicationInterface.name();
|
|
114
|
-
}
|
|
115
|
-
Log.i(TAG, "[FLIR] 📡 Device found: " + identity.deviceId + " (" + type + ")");
|
|
116
|
-
|
|
117
|
-
if (eventCallback != null) {
|
|
118
|
-
// Use cameraType field directly (public final field)
|
|
119
|
-
String cameraTypeStr = (identity.cameraType != null) ? identity.cameraType.toString()
|
|
120
|
-
: "UNKNOWN";
|
|
121
|
-
eventCallback.onCameraFound(identity.deviceId, cameraTypeStr, type);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
@Override
|
|
127
|
-
public void onDiscoveryError(CommunicationInterface iface, ErrorCode err) {
|
|
128
|
-
Log.w(TAG, "[FLIR] Discovery error on " + iface + ": " + err);
|
|
129
|
-
if (eventCallback != null) {
|
|
130
|
-
eventCallback.onDiscoveryError(iface.name(), err.toString());
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
// Start scan
|
|
136
|
-
try {
|
|
137
|
-
DiscoveryFactory.getInstance().scan(
|
|
138
|
-
currentListener,
|
|
139
|
-
CommunicationInterface.NETWORK,
|
|
140
|
-
emulatorInterface);
|
|
141
|
-
|
|
142
|
-
// Timeout: 0 seconds if isEmu=true (go straight to emulator), else 5 seconds
|
|
143
|
-
long timeoutSeconds = isEmu ? 0 : 5;
|
|
144
|
-
Log.d(TAG, "[FLIR] Discovery timeout: " + timeoutSeconds + "s (isEmu=" + isEmu + ")");
|
|
145
|
-
|
|
146
|
-
// Schedule timeout
|
|
147
|
-
scheduler.schedule(() -> {
|
|
148
|
-
stopDiscovery();
|
|
149
|
-
onDiscoveryComplete();
|
|
150
|
-
}, timeoutSeconds, TimeUnit.SECONDS);
|
|
151
|
-
|
|
152
|
-
} catch (Exception e) {
|
|
153
|
-
Log.e(TAG, "[FLIR] Failed to start discovery", e);
|
|
154
|
-
isDiscovering = false;
|
|
155
|
-
if (eventCallback != null) {
|
|
156
|
-
eventCallback.onDiscoveryError("Failed to start discovery: " + e.getMessage());
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Stop discovery
|
|
163
|
-
*/
|
|
164
|
-
public void stopDiscovery() {
|
|
165
|
-
if (!isDiscovering) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
Log.d(TAG, "[FLIR] Stopping discovery...");
|
|
170
|
-
try {
|
|
171
|
-
DiscoveryFactory.getInstance().stop();
|
|
172
|
-
} catch (Exception e) {
|
|
173
|
-
Log.w(TAG, "[FLIR] Error stopping discovery", e);
|
|
174
|
-
}
|
|
175
|
-
isDiscovering = false;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Called when discovery completes (timeout or manual stop)
|
|
180
|
-
*/
|
|
181
|
-
private void onDiscoveryComplete() {
|
|
182
|
-
Log.i(TAG, "[FLIR] ✅ Discovery complete - found " + discoveredDevices.size() + " device(s)");
|
|
183
|
-
|
|
184
|
-
// Notify callback
|
|
185
|
-
if (eventCallback != null) {
|
|
186
|
-
eventCallback.onDevicesDiscovered(new ArrayList<>(discoveredDevices));
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// Auto-select first device
|
|
190
|
-
if (!discoveredDevices.isEmpty()) {
|
|
191
|
-
Identity firstDevice = discoveredDevices.get(0);
|
|
192
|
-
Log.i(TAG, "[FLIR] Auto-selecting first device: " + firstDevice.deviceId);
|
|
193
|
-
FlirConnectionManager.getInstance().selectDevice(firstDevice);
|
|
194
|
-
} else {
|
|
195
|
-
Log.w(TAG, "[FLIR] No devices found after timeout");
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Get emulator communication interface based on flirEmulatorType
|
|
201
|
-
*/
|
|
202
|
-
private CommunicationInterface getEmulatorInterface() {
|
|
203
|
-
if ("FLIR_ONE".equals(flirEmulatorType)) {
|
|
204
|
-
return CommunicationInterface.EMULATOR;
|
|
205
|
-
} else {
|
|
206
|
-
// Default to FLIR_ONE_EDGE
|
|
207
|
-
return CommunicationInterface.EMULATOR;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Get discovered device by ID
|
|
213
|
-
*/
|
|
214
|
-
public Identity getDeviceById(String deviceId) {
|
|
215
|
-
for (Identity identity : discoveredDevices) {
|
|
216
|
-
if (identity.deviceId.equals(deviceId)) {
|
|
217
|
-
return identity;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
return null;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Get list of all discovered devices
|
|
225
|
-
*/
|
|
226
|
-
public List<Identity> getDiscoveredDevices() {
|
|
227
|
-
return new ArrayList<>(discoveredDevices);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Check if discovery is in progress
|
|
232
|
-
*/
|
|
233
|
-
public boolean isDiscovering() {
|
|
234
|
-
return isDiscovering;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
package flir.android;
|
|
2
|
-
|
|
3
|
-
import android.graphics.Bitmap;
|
|
4
|
-
|
|
5
|
-
public class FrameDataHolder {
|
|
6
|
-
|
|
7
|
-
public final Bitmap msxBitmap;
|
|
8
|
-
public final Bitmap dcBitmap;
|
|
9
|
-
|
|
10
|
-
public FrameDataHolder(Bitmap msxBitmap, Bitmap dcBitmap) {
|
|
11
|
-
this.msxBitmap = msxBitmap;
|
|
12
|
-
this.dcBitmap = dcBitmap;
|
|
13
|
-
}
|
|
14
|
-
}
|