@bota.dev/react-native-app-sdk 2.0.0-beta.0

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 (173) hide show
  1. package/BotaDeviceSDK.podspec +55 -0
  2. package/LICENSE +21 -0
  3. package/README.md +101 -0
  4. package/android/build.gradle +76 -0
  5. package/android/src/main/AndroidManifest.xml +1 -0
  6. package/android/src/main/java/dev/bota/sdk/reactnative/BotaDeviceSDKAndroidDevices.kt +172 -0
  7. package/android/src/main/java/dev/bota/sdk/reactnative/BotaDeviceSDKAndroidLifecycle.kt +100 -0
  8. package/android/src/main/java/dev/bota/sdk/reactnative/BotaDeviceSDKAndroidLogs.kt +82 -0
  9. package/android/src/main/java/dev/bota/sdk/reactnative/BotaDeviceSDKAndroidModels.kt +476 -0
  10. package/android/src/main/java/dev/bota/sdk/reactnative/BotaDeviceSDKAndroidOTA.kt +58 -0
  11. package/android/src/main/java/dev/bota/sdk/reactnative/BotaDeviceSDKAndroidRecordingUploads.kt +180 -0
  12. package/android/src/main/java/dev/bota/sdk/reactnative/BotaDeviceSDKAndroidRecordings.kt +751 -0
  13. package/android/src/main/java/dev/bota/sdk/reactnative/BotaDeviceSDKAndroidSecurity.kt +509 -0
  14. package/android/src/main/java/dev/bota/sdk/reactnative/BotaDeviceSDKAndroidWiFi.kt +125 -0
  15. package/android/src/main/java/dev/bota/sdk/reactnative/BotaDeviceSDKEncryptedUploadV2Materials.kt +46 -0
  16. package/android/src/main/java/dev/bota/sdk/reactnative/BotaDeviceSDKModule.kt +723 -0
  17. package/android/src/main/java/dev/bota/sdk/reactnative/BotaDeviceSDKPackage.kt +33 -0
  18. package/android/src/test/java/dev/bota/sdk/reactnative/BotaDeviceSDKAndroidDevicesTest.kt +211 -0
  19. package/android/src/test/java/dev/bota/sdk/reactnative/BotaDeviceSDKAndroidLifecycleTest.kt +132 -0
  20. package/android/src/test/java/dev/bota/sdk/reactnative/BotaDeviceSDKAndroidLogsTest.kt +57 -0
  21. package/android/src/test/java/dev/bota/sdk/reactnative/BotaDeviceSDKAndroidOTATest.kt +75 -0
  22. package/android/src/test/java/dev/bota/sdk/reactnative/BotaDeviceSDKAndroidRecordingUploadsTest.kt +147 -0
  23. package/android/src/test/java/dev/bota/sdk/reactnative/BotaDeviceSDKAndroidRecordingsTest.kt +355 -0
  24. package/android/src/test/java/dev/bota/sdk/reactnative/BotaDeviceSDKAndroidSecurityTest.kt +523 -0
  25. package/android/src/test/java/dev/bota/sdk/reactnative/BotaDeviceSDKAndroidWiFiTest.kt +100 -0
  26. package/generated/codegen-contract.json +3593 -0
  27. package/ios/BotaDeviceSDK.mm +1300 -0
  28. package/ios/BotaDeviceSDKAppleBridge.swift +2260 -0
  29. package/ios/BotaDeviceSDKAppleDevices.swift +191 -0
  30. package/ios/BotaDeviceSDKAppleLifecycle.swift +167 -0
  31. package/ios/BotaDeviceSDKAppleLogs.swift +79 -0
  32. package/ios/BotaDeviceSDKAppleOTA.swift +73 -0
  33. package/ios/BotaDeviceSDKAppleRecordingUploads.swift +178 -0
  34. package/ios/BotaDeviceSDKAppleRecordings.swift +670 -0
  35. package/ios/BotaDeviceSDKAppleSecurity.swift +586 -0
  36. package/ios/BotaDeviceSDKAppleWiFi.swift +128 -0
  37. package/ios/BotaDeviceSDKEncryptedUploadV2Materials.swift +99 -0
  38. package/lib/commonjs/BotaClient.js +194 -0
  39. package/lib/commonjs/BotaClient.js.map +1 -0
  40. package/lib/commonjs/ble/constants.js +10 -0
  41. package/lib/commonjs/ble/constants.js.map +1 -0
  42. package/lib/commonjs/ble/deviceLogs.js +50 -0
  43. package/lib/commonjs/ble/deviceLogs.js.map +1 -0
  44. package/lib/commonjs/cache/DeviceStateCache.js +6 -0
  45. package/lib/commonjs/cache/DeviceStateCache.js.map +1 -0
  46. package/lib/commonjs/client.js +746 -0
  47. package/lib/commonjs/client.js.map +1 -0
  48. package/lib/commonjs/compatibility/runtime.js +44 -0
  49. package/lib/commonjs/compatibility/runtime.js.map +1 -0
  50. package/lib/commonjs/index.js +123 -0
  51. package/lib/commonjs/index.js.map +1 -0
  52. package/lib/commonjs/managers/DeviceManager.js +647 -0
  53. package/lib/commonjs/managers/DeviceManager.js.map +1 -0
  54. package/lib/commonjs/managers/OTAManager.js +140 -0
  55. package/lib/commonjs/managers/OTAManager.js.map +1 -0
  56. package/lib/commonjs/managers/RecordingManager.js +444 -0
  57. package/lib/commonjs/managers/RecordingManager.js.map +1 -0
  58. package/lib/commonjs/managers/StreamingSession.js +175 -0
  59. package/lib/commonjs/managers/StreamingSession.js.map +1 -0
  60. package/lib/commonjs/managers/types.js +6 -0
  61. package/lib/commonjs/managers/types.js.map +1 -0
  62. package/lib/commonjs/models/Device.js +2 -0
  63. package/lib/commonjs/models/Device.js.map +1 -0
  64. package/lib/commonjs/models/Recording.js +2 -0
  65. package/lib/commonjs/models/Recording.js.map +1 -0
  66. package/lib/commonjs/models/Status.js +6 -0
  67. package/lib/commonjs/models/Status.js.map +1 -0
  68. package/lib/commonjs/package.json +1 -0
  69. package/lib/commonjs/specs/NativeBotaDeviceSDK.js +9 -0
  70. package/lib/commonjs/specs/NativeBotaDeviceSDK.js.map +1 -0
  71. package/lib/commonjs/sync/syncStatus.js +178 -0
  72. package/lib/commonjs/sync/syncStatus.js.map +1 -0
  73. package/lib/commonjs/utils/errors.js +194 -0
  74. package/lib/commonjs/utils/errors.js.map +1 -0
  75. package/lib/commonjs/utils/logger.js +84 -0
  76. package/lib/commonjs/utils/logger.js.map +1 -0
  77. package/lib/module/BotaClient.js +189 -0
  78. package/lib/module/BotaClient.js.map +1 -0
  79. package/lib/module/ble/constants.js +6 -0
  80. package/lib/module/ble/constants.js.map +1 -0
  81. package/lib/module/ble/deviceLogs.js +45 -0
  82. package/lib/module/ble/deviceLogs.js.map +1 -0
  83. package/lib/module/cache/DeviceStateCache.js +4 -0
  84. package/lib/module/cache/DeviceStateCache.js.map +1 -0
  85. package/lib/module/client.js +740 -0
  86. package/lib/module/client.js.map +1 -0
  87. package/lib/module/compatibility/runtime.js +35 -0
  88. package/lib/module/compatibility/runtime.js.map +1 -0
  89. package/lib/module/index.js +17 -0
  90. package/lib/module/index.js.map +1 -0
  91. package/lib/module/managers/DeviceManager.js +641 -0
  92. package/lib/module/managers/DeviceManager.js.map +1 -0
  93. package/lib/module/managers/OTAManager.js +134 -0
  94. package/lib/module/managers/OTAManager.js.map +1 -0
  95. package/lib/module/managers/RecordingManager.js +438 -0
  96. package/lib/module/managers/RecordingManager.js.map +1 -0
  97. package/lib/module/managers/StreamingSession.js +168 -0
  98. package/lib/module/managers/StreamingSession.js.map +1 -0
  99. package/lib/module/managers/types.js +4 -0
  100. package/lib/module/managers/types.js.map +1 -0
  101. package/lib/module/models/Device.js +2 -0
  102. package/lib/module/models/Device.js.map +1 -0
  103. package/lib/module/models/Recording.js +2 -0
  104. package/lib/module/models/Recording.js.map +1 -0
  105. package/lib/module/models/Status.js +4 -0
  106. package/lib/module/models/Status.js.map +1 -0
  107. package/lib/module/specs/NativeBotaDeviceSDK.js +5 -0
  108. package/lib/module/specs/NativeBotaDeviceSDK.js.map +1 -0
  109. package/lib/module/sync/syncStatus.js +174 -0
  110. package/lib/module/sync/syncStatus.js.map +1 -0
  111. package/lib/module/utils/errors.js +183 -0
  112. package/lib/module/utils/errors.js.map +1 -0
  113. package/lib/module/utils/logger.js +80 -0
  114. package/lib/module/utils/logger.js.map +1 -0
  115. package/lib/typescript/BotaClient.d.ts +40 -0
  116. package/lib/typescript/BotaClient.d.ts.map +1 -0
  117. package/lib/typescript/ble/constants.d.ts +4 -0
  118. package/lib/typescript/ble/constants.d.ts.map +1 -0
  119. package/lib/typescript/ble/deviceLogs.d.ts +10 -0
  120. package/lib/typescript/ble/deviceLogs.d.ts.map +1 -0
  121. package/lib/typescript/cache/DeviceStateCache.d.ts +14 -0
  122. package/lib/typescript/cache/DeviceStateCache.d.ts.map +1 -0
  123. package/lib/typescript/client.d.ts +208 -0
  124. package/lib/typescript/client.d.ts.map +1 -0
  125. package/lib/typescript/compatibility/runtime.d.ts +11 -0
  126. package/lib/typescript/compatibility/runtime.d.ts.map +1 -0
  127. package/lib/typescript/index.d.ts +19 -0
  128. package/lib/typescript/index.d.ts.map +1 -0
  129. package/lib/typescript/managers/DeviceManager.d.ts +117 -0
  130. package/lib/typescript/managers/DeviceManager.d.ts.map +1 -0
  131. package/lib/typescript/managers/OTAManager.d.ts +25 -0
  132. package/lib/typescript/managers/OTAManager.d.ts.map +1 -0
  133. package/lib/typescript/managers/RecordingManager.d.ts +54 -0
  134. package/lib/typescript/managers/RecordingManager.d.ts.map +1 -0
  135. package/lib/typescript/managers/StreamingSession.d.ts +35 -0
  136. package/lib/typescript/managers/StreamingSession.d.ts.map +1 -0
  137. package/lib/typescript/managers/types.d.ts +19 -0
  138. package/lib/typescript/managers/types.d.ts.map +1 -0
  139. package/lib/typescript/models/Device.d.ts +392 -0
  140. package/lib/typescript/models/Device.d.ts.map +1 -0
  141. package/lib/typescript/models/Recording.d.ts +259 -0
  142. package/lib/typescript/models/Recording.d.ts.map +1 -0
  143. package/lib/typescript/models/Status.d.ts +106 -0
  144. package/lib/typescript/models/Status.d.ts.map +1 -0
  145. package/lib/typescript/specs/NativeBotaDeviceSDK.d.ts +393 -0
  146. package/lib/typescript/specs/NativeBotaDeviceSDK.d.ts.map +1 -0
  147. package/lib/typescript/sync/syncStatus.d.ts +123 -0
  148. package/lib/typescript/sync/syncStatus.d.ts.map +1 -0
  149. package/lib/typescript/utils/errors.d.ts +83 -0
  150. package/lib/typescript/utils/errors.d.ts.map +1 -0
  151. package/lib/typescript/utils/logger.d.ts +36 -0
  152. package/lib/typescript/utils/logger.d.ts.map +1 -0
  153. package/package.json +100 -0
  154. package/scripts/bota_device_sdk_spm_workaround.rb +53 -0
  155. package/src/BotaClient.ts +231 -0
  156. package/src/ble/constants.ts +3 -0
  157. package/src/ble/deviceLogs.ts +61 -0
  158. package/src/cache/DeviceStateCache.ts +20 -0
  159. package/src/client.ts +1410 -0
  160. package/src/compatibility/runtime.ts +55 -0
  161. package/src/index.ts +146 -0
  162. package/src/managers/DeviceManager.ts +927 -0
  163. package/src/managers/OTAManager.ts +195 -0
  164. package/src/managers/RecordingManager.ts +578 -0
  165. package/src/managers/StreamingSession.ts +212 -0
  166. package/src/managers/types.ts +36 -0
  167. package/src/models/Device.ts +484 -0
  168. package/src/models/Recording.ts +281 -0
  169. package/src/models/Status.ts +128 -0
  170. package/src/specs/NativeBotaDeviceSDK.ts +542 -0
  171. package/src/sync/syncStatus.ts +243 -0
  172. package/src/utils/errors.ts +327 -0
  173. package/src/utils/logger.ts +122 -0
@@ -0,0 +1,484 @@
1
+ /**
2
+ * Device-related type definitions
3
+ */
4
+
5
+ /**
6
+ * Device type identifier
7
+ */
8
+ export type DeviceType = 'bota_pin' | 'bota_pin_4g' | 'bota_note';
9
+
10
+ /**
11
+ * Pairing state of a device
12
+ */
13
+ export type PairingState = 'unpaired' | 'pairing' | 'paired' | 'error';
14
+
15
+ /**
16
+ * Connection state of a device
17
+ */
18
+ export type ConnectionState =
19
+ | 'disconnected'
20
+ | 'connecting'
21
+ | 'bonding'
22
+ | 'discovering'
23
+ | 'connected'
24
+ | 'disconnecting';
25
+
26
+ /**
27
+ * Device operational state
28
+ */
29
+ export type DeviceState =
30
+ | 'idle'
31
+ | 'recording'
32
+ | 'syncing'
33
+ | 'uploading'
34
+ | 'charging'
35
+ | 'lowBattery'
36
+ | 'storageFull'
37
+ | 'error';
38
+
39
+ /**
40
+ * Device status flags (1-byte bitmask)
41
+ * See: FIRMWARE_INTEGRATION_GUIDE_ZH.md section 3.1 — DeviceFlags enum
42
+ */
43
+ export interface DeviceFlags {
44
+ charging: boolean;
45
+ lowBattery: boolean;
46
+ storageFull: boolean;
47
+ wifiConnected: boolean;
48
+ lteConnected: boolean;
49
+ syncActive: boolean;
50
+ }
51
+
52
+ /**
53
+ * LTE/4G modem status
54
+ */
55
+ export type LteStatus =
56
+ | 'off'
57
+ | 'searching'
58
+ | 'registered'
59
+ | 'connected'
60
+ | 'denied'
61
+ | 'noSim'
62
+ | 'error'
63
+ | 'lowVoltage'
64
+ | 'disabled';
65
+
66
+ /**
67
+ * WiFi radio status
68
+ */
69
+ export type WifiStatus =
70
+ | 'off'
71
+ | 'scanning'
72
+ | 'connecting'
73
+ | 'connected'
74
+ | 'connectFailed'
75
+ | 'noCredentials'
76
+ | 'disabled'
77
+ | 'error';
78
+
79
+ /**
80
+ * Device discovered during Bluetooth scan (not yet connected)
81
+ */
82
+ export interface DiscoveredDevice {
83
+ /** Bluetooth device identifier (platform-specific UUID) */
84
+ id: string;
85
+ /** Device name from advertisement (e.g., "Bota-Pin-A1B2C3") */
86
+ name: string;
87
+ /** Device type parsed from advertisement */
88
+ deviceType: DeviceType;
89
+ /** Firmware version from manufacturer data */
90
+ firmwareVersion: string;
91
+ /** MAC address parsed from manufacturer data (null if firmware doesn't include it) */
92
+ macAddress: string | null;
93
+ /** Pairing state from manufacturer data */
94
+ pairingState: PairingState;
95
+ /** Signal strength (RSSI) */
96
+ rssi: number;
97
+ /** Raw manufacturer data bytes */
98
+ manufacturerData?: Uint8Array;
99
+ /** Timestamp when discovered */
100
+ discoveredAt: Date;
101
+ }
102
+
103
+ /**
104
+ * Device capabilities (bitmask)
105
+ */
106
+ export interface DeviceCapabilities {
107
+ /** Supports Bluetooth Sync (BLE transfer) */
108
+ bleSync: boolean;
109
+ /** Supports WiFi Upload */
110
+ wifiUpload: boolean;
111
+ /** Supports Cellular Upload (4G/LTE) */
112
+ lteUpload: boolean;
113
+ /** Supports Remote Recording Control */
114
+ remoteRecord: boolean;
115
+ }
116
+
117
+ /**
118
+ * Device after successful Bluetooth connection
119
+ */
120
+ export interface ConnectedDevice {
121
+ /** Bluetooth device identifier */
122
+ id: string;
123
+ /** Device serial number (read from Device Info service) */
124
+ serialNumber: string;
125
+ /** Device type */
126
+ deviceType: DeviceType;
127
+ /** Firmware version */
128
+ firmwareVersion: string;
129
+ /** Hardware revision (if available) */
130
+ hardwareRevision?: string;
131
+ /** Whether device has been provisioned with a token */
132
+ isProvisioned: boolean;
133
+ /** Current connection state */
134
+ connectionState: ConnectionState;
135
+ /** Negotiated MTU size */
136
+ mtu: number;
137
+ /** Device capabilities */
138
+ capabilities?: DeviceCapabilities;
139
+ }
140
+
141
+ /**
142
+ * 4G modem debug information (parsed from extended device status)
143
+ */
144
+ export interface ModemInfo {
145
+ imei?: string;
146
+ iccid?: string;
147
+ operator?: string;
148
+ rat?: string;
149
+ band?: string;
150
+ apn?: string;
151
+ simStatus?: string;
152
+ csq?: number;
153
+ ipAddress?: string;
154
+ modemVoltage?: number;
155
+ modemFirmware?: string;
156
+ roaming?: boolean;
157
+ }
158
+
159
+ /**
160
+ * Device status information
161
+ */
162
+ export interface DeviceStatus {
163
+ /** Battery level (0-100) */
164
+ batteryLevel: number;
165
+ /** Battery voltage in millivolts (e.g., 3700 = 3.7V) */
166
+ batteryMv?: number;
167
+ /** Total storage capacity in MB (uint16LE, max 65535) */
168
+ storageTotalMb: number;
169
+ /** Storage used in MB (uint16LE, max 65535) */
170
+ storageUsedMb: number;
171
+ /** Current operational state */
172
+ state: DeviceState;
173
+ /** Number of pending recordings to sync */
174
+ pendingRecordings: number;
175
+ /** Last clock-sync timestamp (when the device's RTC was last set
176
+ * from a time source — NTP, 4G QLTS/CCLK, or app Bluetooth time-sync).
177
+ * This is NOT the last recording-upload timestamp. */
178
+ lastTimeSyncAt: Date | null;
179
+ /** Signal strength (for 4G devices, 0-5) */
180
+ signalStrength?: number;
181
+ /** Status flags */
182
+ flags: DeviceFlags;
183
+ /** Raw timestamp from device */
184
+ timestamp: number;
185
+ /** LTE/4G modem status (for 4G devices) */
186
+ lteStatus?: LteStatus;
187
+ /** LTE signal quality — raw CSQ value 0-31 (99 = unknown) */
188
+ lteSignalQuality?: number;
189
+ /** WiFi radio status (for WiFi devices) */
190
+ wifiStatus?: WifiStatus;
191
+ /** 4G modem debug info (from extended device status read) */
192
+ modemInfo?: ModemInfo;
193
+ }
194
+
195
+ /** A decoded line from the device's debug BLE log stream. */
196
+ export interface DeviceLogEvent {
197
+ level: 'debug' | 'warn';
198
+ message: string;
199
+ isBacklog: boolean;
200
+ }
201
+
202
+ /**
203
+ * Storage information from device
204
+ */
205
+ export interface StorageInfo {
206
+ /** Total storage in KB */
207
+ totalKb: number;
208
+ /** Used storage in KB */
209
+ usedKb: number;
210
+ /** Total recording count */
211
+ totalRecordings: number;
212
+ /** Pending sync count */
213
+ pendingSyncCount: number;
214
+ }
215
+
216
+ /**
217
+ * Options for reconnecting to a previously paired device by serial number
218
+ */
219
+ export interface ReconnectOptions {
220
+ /** Scan timeout in milliseconds (default: 10000) */
221
+ scanTimeout?: number;
222
+ }
223
+
224
+ /**
225
+ * Configuration for device scanning
226
+ */
227
+ export interface ScanOptions {
228
+ /** Timeout in milliseconds (default: 30000) */
229
+ timeout?: number;
230
+ /** Filter by device types */
231
+ deviceTypes?: DeviceType[];
232
+ /** Filter by pairing state */
233
+ pairingState?: PairingState;
234
+ /** Minimum RSSI to include */
235
+ minRssi?: number;
236
+ /** Allow duplicates (same device reported multiple times) */
237
+ allowDuplicates?: boolean;
238
+ }
239
+
240
+ /**
241
+ * Environment for API endpoint configuration
242
+ */
243
+ export type Environment = 'development' | 'gamma' | 'production';
244
+
245
+ /**
246
+ * Provisioning result
247
+ */
248
+ export interface ProvisioningResult {
249
+ success: boolean;
250
+ error?: 'invalid_token' | 'storage_error' | 'chunk_error' | 'already_paired' | 'unknown';
251
+ /** Present on the three-byte authenticated factory-reset success result. */
252
+ localRecordingsDeleted?: number;
253
+ }
254
+
255
+ /** Result returned by the authenticated BLE factory-reset close-loop. */
256
+ export type BleFactoryResetResult =
257
+ | {
258
+ success: true;
259
+ localRecordingsDeleted: number;
260
+ }
261
+ | {
262
+ success: false;
263
+ error: NonNullable<ProvisioningResult['error']>;
264
+ };
265
+
266
+ /**
267
+ * Called after firmware reports a successful wipe and before the SDK sends
268
+ * the explicit result receipt. Reject to leave firmware in its replayable
269
+ * WIPED phase.
270
+ */
271
+ export type BleFactoryResetResultPersister = (
272
+ result: Extract<BleFactoryResetResult, { success: true }>
273
+ ) => Promise<void>;
274
+
275
+ // ============================================================================
276
+ // Remote Recording Control Types
277
+ // ============================================================================
278
+
279
+ /**
280
+ * Recording command type
281
+ */
282
+ export type RecordingCommandType = 'start_recording' | 'stop_recording';
283
+
284
+ /**
285
+ * Recording command status
286
+ */
287
+ export type RecordingCommandStatus =
288
+ | 'pending'
289
+ | 'delivered'
290
+ | 'executed'
291
+ | 'failed'
292
+ | 'expired'
293
+ | 'cancelled';
294
+
295
+ /**
296
+ * Options for starting recording remotely
297
+ */
298
+ export interface StartRecordingOptions {
299
+ /** Maximum recording duration in seconds (auto-stop) */
300
+ maxDurationSec?: number;
301
+ /** Metadata to attach to the recording */
302
+ metadata?: Record<string, unknown>;
303
+ }
304
+
305
+ /**
306
+ * Options for stopping recording remotely
307
+ */
308
+ export interface StopRecordingOptions {
309
+ /** Whether to trigger immediate upload after stopping */
310
+ uploadImmediately?: boolean;
311
+ }
312
+
313
+ /**
314
+ * Recording command result
315
+ */
316
+ export interface RecordingCommandResult {
317
+ /** Command ID from backend */
318
+ commandId: string;
319
+ /** Recording ID (for start_recording) */
320
+ recordingId?: string;
321
+ /** When recording started */
322
+ startedAt?: Date;
323
+ /** When recording stopped */
324
+ stoppedAt?: Date;
325
+ /** Recording duration in seconds */
326
+ durationSeconds?: number;
327
+ }
328
+
329
+ /**
330
+ * Recording command error
331
+ */
332
+ export interface RecordingCommandError {
333
+ code: string;
334
+ message: string;
335
+ }
336
+
337
+ /**
338
+ * Full recording command response
339
+ */
340
+ export interface RecordingCommand {
341
+ id: string;
342
+ deviceId: string;
343
+ type: RecordingCommandType;
344
+ status: RecordingCommandStatus;
345
+ grantToken: string;
346
+ result?: RecordingCommandResult;
347
+ error?: RecordingCommandError;
348
+ expiresAt?: Date;
349
+ createdAt: Date;
350
+ }
351
+
352
+ /**
353
+ * Current recording state of the device
354
+ */
355
+ export interface RecordingState {
356
+ /** Whether device is currently recording */
357
+ active: boolean;
358
+ /** Current recording ID (if recording) */
359
+ recordingId?: string;
360
+ /** When recording started */
361
+ startedAt?: Date;
362
+ /** Duration in seconds (updated periodically) */
363
+ durationSeconds?: number;
364
+ /** Who initiated the recording */
365
+ initiatedBy?: 'local' | 'remote';
366
+ }
367
+
368
+ // ============================================================================
369
+ // Connection Settings Types
370
+ // ============================================================================
371
+
372
+ /**
373
+ * Connection type for network preference ordering
374
+ */
375
+ export type ConnectionType = 'wifi' | 'ble' | 'cellular';
376
+
377
+ /**
378
+ * Per-device connection settings read/written via Bluetooth DEVICE_SETTINGS characteristic
379
+ */
380
+ export interface DeviceConnectionSettings {
381
+ enabled_connections: {
382
+ wifi: boolean;
383
+ cellular: boolean;
384
+ };
385
+ heartbeat_enabled_connections?: {
386
+ wifi: boolean;
387
+ cellular: boolean;
388
+ };
389
+ upload_network_preference: ConnectionType[];
390
+ power_management?: {
391
+ wifi_idle_timeout_seconds?: number | null; // null/omitted=180, -1=always-on, 0=immediate, legacy 1-9=>10, 10-2540=custom
392
+ cellular_idle_timeout_seconds?: number | null; // null/omitted=180, -1=always-on, 0=immediate, legacy 1-9=>10, 10-2540=custom
393
+ };
394
+ streaming_enabled?: boolean; // Upload-while-recording (default: true)
395
+ streaming_flush_interval_seconds?: number; // 0=disabled, 1-128=seconds (default: 60)
396
+ }
397
+
398
+ // ============================================================================
399
+ // WiFi Upload Configuration Types
400
+ // ============================================================================
401
+
402
+ /**
403
+ * WiFi security type
404
+ */
405
+ export type WiFiSecurityType = 'WPA2' | 'WPA3' | 'WEP' | 'OPEN';
406
+
407
+ /**
408
+ * WiFi connection status
409
+ */
410
+ export type WiFiStatus = 'idle' | 'connecting' | 'connected' | 'failed' | 'disconnected';
411
+
412
+ /**
413
+ * WiFi configuration grant from backend
414
+ */
415
+ export interface WiFiConfigGrant {
416
+ /** Grant blob (JWT token) */
417
+ grantBlob: string;
418
+ /** Expiration timestamp */
419
+ expiresAt: Date;
420
+ }
421
+
422
+ /**
423
+ * WiFi credentials to configure
424
+ */
425
+ export interface WiFiCredentials {
426
+ /** WiFi network SSID */
427
+ ssid: string;
428
+ /** WiFi password */
429
+ password: string;
430
+ /** Security type (default: WPA2) */
431
+ securityType?: WiFiSecurityType;
432
+ }
433
+
434
+ /**
435
+ * WiFi configuration result from device
436
+ */
437
+ export interface WiFiConfigResult {
438
+ /** Whether configuration was successful */
439
+ success: boolean;
440
+ /** Error code if failed */
441
+ error?: 'invalid_grant' | 'grant_expired' | 'decryption_error' | 'storage_error' | 'unknown';
442
+ }
443
+
444
+ /**
445
+ * WiFi status information from device
446
+ */
447
+ export interface WiFiStatusInfo {
448
+ /** Current WiFi connection status */
449
+ status: WiFiStatus;
450
+ /** Connected SSID (if connected) */
451
+ ssid?: string;
452
+ /** Signal strength (0-100) */
453
+ signalStrength?: number;
454
+ /** Last connection error (if failed) */
455
+ lastError?: string;
456
+ }
457
+
458
+ // ============================================================================
459
+ // Device-Side WiFi Scanning Types
460
+ // ============================================================================
461
+
462
+ /**
463
+ * A WiFi network discovered by the device's WiFi radio
464
+ */
465
+ export interface WiFiScanNetwork {
466
+ /** Network SSID */
467
+ ssid: string;
468
+ /** Signal quality 0-100 */
469
+ quality: number;
470
+ /** Whether this is the currently connected network */
471
+ isCurrent: boolean;
472
+ /** Open network (no password required) */
473
+ isOpen?: boolean;
474
+ }
475
+
476
+ /**
477
+ * Result of a device-side WiFi scan
478
+ */
479
+ export interface DeviceWiFiScanResult {
480
+ /** Discovered networks sorted by signal quality */
481
+ networks: WiFiScanNetwork[];
482
+ /** SSID of the currently connected network, if any */
483
+ currentSsid: string | null;
484
+ }