theta-client-react-native 1.8.0 → 1.9.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 (70) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/java/com/ricoh360/thetaclientreactnative/Converter.kt +151 -9
  3. package/android/src/main/java/com/ricoh360/thetaclientreactnative/ThetaClientSdkModule.kt +76 -50
  4. package/ios/ConvertUtil.swift +138 -29
  5. package/ios/ThetaClientReactNative.m +9 -0
  6. package/ios/ThetaClientReactNative.swift +113 -23
  7. package/lib/commonjs/theta-repository/event-websocket.js +39 -0
  8. package/lib/commonjs/theta-repository/event-websocket.js.map +1 -0
  9. package/lib/commonjs/theta-repository/index.js +11 -0
  10. package/lib/commonjs/theta-repository/index.js.map +1 -1
  11. package/lib/commonjs/theta-repository/options/index.js +33 -0
  12. package/lib/commonjs/theta-repository/options/index.js.map +1 -1
  13. package/lib/commonjs/theta-repository/options/option-ethernet-config.js +6 -0
  14. package/lib/commonjs/theta-repository/options/option-ethernet-config.js.map +1 -0
  15. package/lib/commonjs/theta-repository/options/option-file-format.js +89 -0
  16. package/lib/commonjs/theta-repository/options/option-file-format.js.map +1 -0
  17. package/lib/commonjs/theta-repository/options/option-max-recordable-time.js +28 -0
  18. package/lib/commonjs/theta-repository/options/option-max-recordable-time.js.map +1 -0
  19. package/lib/commonjs/theta-repository/options/options.js +3 -81
  20. package/lib/commonjs/theta-repository/options/options.js.map +1 -1
  21. package/lib/commonjs/theta-repository/theta-repository.js +11 -0
  22. package/lib/commonjs/theta-repository/theta-repository.js.map +1 -1
  23. package/lib/module/theta-repository/event-websocket.js +32 -0
  24. package/lib/module/theta-repository/event-websocket.js.map +1 -0
  25. package/lib/module/theta-repository/index.js +1 -0
  26. package/lib/module/theta-repository/index.js.map +1 -1
  27. package/lib/module/theta-repository/options/index.js +3 -0
  28. package/lib/module/theta-repository/options/index.js.map +1 -1
  29. package/lib/module/theta-repository/options/option-ethernet-config.js +2 -0
  30. package/lib/module/theta-repository/options/option-ethernet-config.js.map +1 -0
  31. package/lib/module/theta-repository/options/option-file-format.js +83 -0
  32. package/lib/module/theta-repository/options/option-file-format.js.map +1 -0
  33. package/lib/module/theta-repository/options/option-max-recordable-time.js +22 -0
  34. package/lib/module/theta-repository/options/option-max-recordable-time.js.map +1 -0
  35. package/lib/module/theta-repository/options/options.js +2 -80
  36. package/lib/module/theta-repository/options/options.js.map +1 -1
  37. package/lib/module/theta-repository/theta-repository.js +10 -0
  38. package/lib/module/theta-repository/theta-repository.js.map +1 -1
  39. package/lib/typescript/theta-repository/event-websocket.d.ts +14 -0
  40. package/lib/typescript/theta-repository/event-websocket.d.ts.map +1 -0
  41. package/lib/typescript/theta-repository/index.d.ts +1 -0
  42. package/lib/typescript/theta-repository/index.d.ts.map +1 -1
  43. package/lib/typescript/theta-repository/options/index.d.ts +3 -0
  44. package/lib/typescript/theta-repository/options/index.d.ts.map +1 -1
  45. package/lib/typescript/theta-repository/options/option-ethernet-config.d.ts +29 -0
  46. package/lib/typescript/theta-repository/options/option-ethernet-config.d.ts.map +1 -0
  47. package/lib/typescript/theta-repository/options/option-file-format.d.ts +102 -0
  48. package/lib/typescript/theta-repository/options/option-file-format.d.ts.map +1 -0
  49. package/lib/typescript/theta-repository/options/option-max-recordable-time.d.ts +22 -0
  50. package/lib/typescript/theta-repository/options/option-max-recordable-time.d.ts.map +1 -0
  51. package/lib/typescript/theta-repository/options/options.d.ts +8 -77
  52. package/lib/typescript/theta-repository/options/options.d.ts.map +1 -1
  53. package/lib/typescript/theta-repository/theta-files.d.ts +1 -1
  54. package/lib/typescript/theta-repository/theta-files.d.ts.map +1 -1
  55. package/lib/typescript/theta-repository/theta-repository.d.ts +2 -0
  56. package/lib/typescript/theta-repository/theta-repository.d.ts.map +1 -1
  57. package/lib/typescript/theta-repository/theta-state/theta-state.d.ts +24 -24
  58. package/lib/typescript/theta-repository/theta-state/theta-state.d.ts.map +1 -1
  59. package/package.json +1 -1
  60. package/src/theta-repository/event-websocket.ts +52 -0
  61. package/src/theta-repository/index.ts +1 -0
  62. package/src/theta-repository/options/index.ts +3 -0
  63. package/src/theta-repository/options/option-ethernet-config.ts +29 -0
  64. package/src/theta-repository/options/option-file-format.ts +90 -0
  65. package/src/theta-repository/options/option-max-recordable-time.ts +23 -0
  66. package/src/theta-repository/options/options.ts +8 -89
  67. package/src/theta-repository/theta-files.ts +1 -1
  68. package/src/theta-repository/theta-repository.ts +13 -0
  69. package/src/theta-repository/theta-state/theta-state.ts +24 -24
  70. package/theta-client-react-native.podspec +1 -1
@@ -135,7 +135,7 @@ dependencies {
135
135
  implementation "com.facebook.react:react-native:+"
136
136
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
137
137
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3"
138
- implementation "com.ricoh360.thetaclient:theta-client:1.8.0"
138
+ implementation "com.ricoh360.thetaclient:theta-client:1.9.0"
139
139
 
140
140
  // From node_modules
141
141
  }
@@ -9,10 +9,12 @@ import com.facebook.react.bridge.WritableArray
9
9
  import com.ricoh360.thetaclient.DigestAuth
10
10
  import com.ricoh360.thetaclient.ThetaRepository.*
11
11
  import com.ricoh360.thetaclient.capture.*
12
+ import com.ricoh360.thetaclient.websocket.CameraEvent
12
13
 
13
14
  const val KEY_NOTIFY_NAME = "name"
14
15
  const val KEY_NOTIFY_PARAMS = "params"
15
16
  const val KEY_NOTIFY_PARAM_COMPLETION = "completion"
17
+ const val KEY_NOTIFY_PARAM_EVENT = "event"
16
18
  const val KEY_NOTIFY_PARAM_MESSAGE = "message"
17
19
  const val KEY_GPS_INFO = "gpsInfo"
18
20
  const val KEY_STATE_EXTERNAL_GPS_INFO = "externalGpsInfo"
@@ -39,6 +41,7 @@ val optionItemNameToEnum: Map<String, OptionNameEnum> = mutableMapOf(
39
41
  "compositeShootingTime" to OptionNameEnum.CompositeShootingTime,
40
42
  "continuousNumber" to OptionNameEnum.ContinuousNumber,
41
43
  "dateTimeZone" to OptionNameEnum.DateTimeZone,
44
+ "ethernetConfig" to OptionNameEnum.EthernetConfig,
42
45
  "exposureCompensation" to OptionNameEnum.ExposureCompensation,
43
46
  "exposureDelay" to OptionNameEnum.ExposureDelay,
44
47
  "exposureProgram" to OptionNameEnum.ExposureProgram,
@@ -99,6 +102,12 @@ fun toCaptureProgressNotifyParam(value: Float): WritableMap {
99
102
  return result
100
103
  }
101
104
 
105
+ fun toEventWebSocketEventNotifyParam(value: CameraEvent): WritableMap {
106
+ val result = Arguments.createMap()
107
+ result.putMap(KEY_NOTIFY_PARAM_EVENT, toResult(value))
108
+ return result
109
+ }
110
+
102
111
  fun toMessageNotifyParam(value: String): WritableMap {
103
112
  val result = Arguments.createMap()
104
113
  result.putString(KEY_NOTIFY_PARAM_MESSAGE, value)
@@ -305,6 +314,10 @@ fun toResult(options: Options): WritableMap {
305
314
  options.burstOption?.let {
306
315
  result.putMap("burstOption", toResult(burstOption = it))
307
316
  }
317
+ } else if (name == OptionNameEnum.EthernetConfig) {
318
+ options.ethernetConfig?.let {
319
+ result.putMap("ethernetConfig", toResult(ethernetConfig = it))
320
+ }
308
321
  } else if (name == OptionNameEnum.GpsInfo) {
309
322
  options.gpsInfo?.let {
310
323
  result.putMap("gpsInfo", toResult(gpsInfo = it))
@@ -351,16 +364,23 @@ fun <T : Enum<T>> addOptionsEnumToMap(options: Options, name: OptionNameEnum, ob
351
364
  }
352
365
 
353
366
  fun <T> addOptionsValueToMap(options: Options, name: OptionNameEnum, objects: WritableMap) {
354
- val key = optionNameEnumToItemName[name]
355
- if (key == null) return
367
+ val key = optionNameEnumToItemName[name] ?: return
356
368
  options.getValue<T>(name)?.let { value ->
357
- if (value is Int) {
358
- objects.putInt(key, value)
359
- } else {
360
- (value as? String)?.toDouble()?.let {
361
- objects.putDouble(key, it)
362
- } ?: run {
363
- objects.putString(key, (value as String))
369
+ when (value) {
370
+ is String -> {
371
+ objects.putString(key, value)
372
+ }
373
+
374
+ is Int -> {
375
+ objects.putInt(key, value)
376
+ }
377
+
378
+ is Number -> {
379
+ objects.putDouble(key, value.toDouble())
380
+ }
381
+
382
+ else -> {
383
+ objects.putString(key, value.toString())
364
384
  }
365
385
  }
366
386
  }
@@ -485,6 +505,24 @@ fun toResult(fileInfo: FileInfo): ReadableMap {
485
505
  return result
486
506
  }
487
507
 
508
+ fun toResult(ethernetConfig: EthernetConfig): WritableMap {
509
+ val result = Arguments.createMap()
510
+ result.putBoolean("usingDhcp", ethernetConfig.usingDhcp)
511
+ ethernetConfig.ipAddress?.let { ipAddress ->
512
+ result.putString("ipAddress", ipAddress)
513
+ }
514
+ ethernetConfig.subnetMask?.let { subnetMask ->
515
+ result.putString("subnetMask", subnetMask)
516
+ }
517
+ ethernetConfig.defaultGateway?.let { defaultGateway ->
518
+ result.putString("defaultGateway", defaultGateway)
519
+ }
520
+ ethernetConfig.proxy?.let { proxy ->
521
+ result.putMap("proxy", toResult(proxy = proxy))
522
+ }
523
+ return result
524
+ }
525
+
488
526
  fun toResult(gpsInfo: GpsInfo): WritableMap {
489
527
  val result = Arguments.createMap()
490
528
  result.putDouble("latitude", gpsInfo.latitude.toDouble())
@@ -534,6 +572,94 @@ fun toResult(timeShift: TimeShiftSetting): WritableMap {
534
572
  return result
535
573
  }
536
574
 
575
+ fun toResult(state: ThetaState): WritableMap {
576
+ val result = Arguments.createMap()
577
+ state.fingerprint?.let {
578
+ result.putString("fingerprint", it)
579
+ }
580
+ state.batteryLevel?.let {
581
+ result.putDouble("batteryLevel", it.toDouble())
582
+ }
583
+ state.storageUri?.let {
584
+ result.putString("storageUri", it)
585
+ }
586
+ state.storageID?.let {
587
+ result.putString("storageID", it)
588
+ }
589
+ state.captureStatus?.let {
590
+ result.putString("captureStatus", it.toString())
591
+ }
592
+ state.recordedTime?.let {
593
+ result.putInt("recordedTime", it)
594
+ }
595
+ state.recordableTime?.let {
596
+ result.putInt("recordableTime", it)
597
+ }
598
+ state.capturedPictures?.let {
599
+ result.putInt("capturedPictures", it)
600
+ }
601
+ state.compositeShootingElapsedTime?.let {
602
+ result.putString("compositeShootingElapsedTime", it.toString())
603
+ }
604
+ state.latestFileUrl?.let {
605
+ result.putString("latestFileUrl", it)
606
+ }
607
+ state.chargingState?.let {
608
+ result.putString("chargingState", it.toString())
609
+ }
610
+ state.apiVersion?.let {
611
+ result.putInt("apiVersion", it)
612
+ }
613
+ state.isPluginRunning?.let {
614
+ result.putBoolean("isPluginRunning", it)
615
+ }
616
+ state.isPluginWebServer?.let {
617
+ result.putBoolean("isPluginWebServer", it)
618
+ }
619
+ state.function?.let {
620
+ result.putString("function", it.toString())
621
+ }
622
+ state.isMySettingChanged?.let {
623
+ result.putBoolean("isMySettingChanged", it)
624
+ }
625
+ state.currentMicrophone?.let {
626
+ result.putString("currentMicrophone", it.toString())
627
+ }
628
+ state.isSdCard?.let {
629
+ result.putBoolean("isSdCard", it)
630
+ }
631
+ state.cameraError?.let { list ->
632
+ result.putArray("cameraError", Arguments.makeNativeArray(list.map { it.toString() }))
633
+ }
634
+ state.isBatteryInsert?.let {
635
+ result.putString("isBatteryInsert", it.toString())
636
+ }
637
+ state.externalGpsInfo?.let {
638
+ result.putMap(KEY_STATE_EXTERNAL_GPS_INFO, toResult(it))
639
+ }
640
+ state.internalGpsInfo?.let {
641
+ result.putMap(KEY_STATE_INTERNAL_GPS_INFO, toResult(it))
642
+ }
643
+ state.boardTemp?.let {
644
+ result.putInt(KEY_STATE_BOARD_TEMP, it)
645
+ }
646
+ state.batteryTemp?.let {
647
+ result.putInt(KEY_STATE_BATTERY_TEMP, it)
648
+ }
649
+ return result
650
+ }
651
+
652
+ fun toResult(cameraEvent: CameraEvent): WritableMap {
653
+ val result = Arguments.createMap()
654
+ cameraEvent.options?.let {
655
+ result.putMap("options", toResult(it))
656
+ }
657
+ cameraEvent.state?.let {
658
+ result.putMap("state", toResult(it))
659
+ }
660
+ return result
661
+ }
662
+
537
663
  fun toSetOptionsParam(optionsMap: ReadableMap): Options {
538
664
  val result = Options()
539
665
  val iterator = optionsMap.keySetIterator()
@@ -598,6 +724,10 @@ fun setOptionValue(options: Options, name: OptionNameEnum, optionsMap: ReadableM
598
724
  optionsMap.getMap(key)?.let {
599
725
  options.setValue(name, toBurstOption(map = it))
600
726
  }
727
+ } else if (name == OptionNameEnum.EthernetConfig) {
728
+ optionsMap.getMap(key)?.let {
729
+ options.setValue(name, toEthernetConfig(map = it) as Any)
730
+ }
601
731
  } else if (name == OptionNameEnum.GpsInfo) {
602
732
  optionsMap.getMap(key)?.let {
603
733
  options.setValue(name, toGpsInfo(map = it))
@@ -710,6 +840,18 @@ fun toAutoBracket(list: ReadableArray): BracketSettingList {
710
840
  return autoBracket
711
841
  }
712
842
 
843
+ fun toEthernetConfig(map: ReadableMap?): EthernetConfig? {
844
+ return map?.let {
845
+ EthernetConfig(
846
+ usingDhcp = if (it.hasKey("usingDhcp")) it.getBoolean("usingDhcp") else true,
847
+ ipAddress = if (it.hasKey("ipAddress")) it.getString("ipAddress") else null,
848
+ subnetMask = if (it.hasKey("subnetMask")) it.getString("subnetMask") else null,
849
+ defaultGateway = if (it.hasKey("defaultGateway")) it.getString("defaultGateway") else null,
850
+ proxy = if (it.hasKey("proxy")) toProxy(map = it.getMap("proxy")) else null
851
+ )
852
+ }
853
+ }
854
+
713
855
  fun toProxy(map: ReadableMap?): Proxy? {
714
856
  return map?.let {
715
857
  Proxy(
@@ -5,6 +5,8 @@ import com.facebook.react.modules.core.DeviceEventManagerModule
5
5
  import com.ricoh360.thetaclient.ThetaRepository
6
6
  import com.ricoh360.thetaclient.ThetaRepository.*
7
7
  import com.ricoh360.thetaclient.capture.*
8
+ import com.ricoh360.thetaclient.websocket.CameraEvent
9
+ import com.ricoh360.thetaclient.websocket.EventWebSocket
8
10
  import kotlinx.coroutines.*
9
11
  import java.util.*
10
12
  import kotlin.coroutines.*
@@ -46,6 +48,7 @@ class ThetaClientReactNativeModule(
46
48
  var multiBracketCapturing: MultiBracketCapturing? = null
47
49
  var continuousCaptureBuilder: ContinuousCapture.Builder? = null
48
50
  var continuousCapture: ContinuousCapture? = null
51
+ var eventWebSocket: EventWebSocket? = null
49
52
  var theta: ThetaRepository? = null
50
53
  var listenerCount: Int = 0
51
54
 
@@ -78,7 +81,7 @@ class ThetaClientReactNativeModule(
78
81
  }
79
82
 
80
83
  /**
81
- * retreive constant
84
+ * retrieve constant
82
85
  */
83
86
  override fun getConstants(): MutableMap<String, Any> =
84
87
  hashMapOf("DEFAULT_EVENT_NAME" to EVENT_NAME)
@@ -119,6 +122,8 @@ class ThetaClientReactNativeModule(
119
122
  multiBracketCapturing = null
120
123
  continuousCaptureBuilder = null
121
124
  continuousCapture = null
125
+ eventWebSocket?.stop()
126
+ eventWebSocket = null
122
127
 
123
128
  theta = ThetaRepository.newInstance(
124
129
  endpoint,
@@ -214,55 +219,7 @@ class ThetaClientReactNativeModule(
214
219
  launch {
215
220
  try {
216
221
  val state = theta.getThetaState()
217
- val result = Arguments.createMap()
218
- result.putString("fingerprint", state.fingerprint)
219
- result.putDouble("batteryLevel", state.batteryLevel.toDouble())
220
- result.putString("storageUri", state.storageUri)
221
- result.putString("storageID", state.storageID)
222
- result.putString("captureStatus", state.captureStatus.toString())
223
- result.putInt("recordedTime", state.recordedTime)
224
- result.putInt("recordableTime", state.recordableTime)
225
- state.capturedPictures?.also {
226
- result.putInt("capturedPictures", state.capturedPictures!!)
227
- } ?: result.putNull("capturedPictures")
228
- state.compositeShootingElapsedTime?.also {
229
- result.putString("compositeShootingElapsedTime", state.compositeShootingElapsedTime.toString())
230
- } ?: result.putNull("compositeShootingElapsedTime")
231
- result.putString("latestFileUrl", state.latestFileUrl)
232
- result.putString("chargingState", state.chargingState.toString())
233
- result.putInt("apiVersion", state.apiVersion)
234
- state.isPluginRunning?.also {
235
- result.putBoolean("isPluginRunning", state.isPluginRunning!!)
236
- } ?: result.putNull("isPluginRunning")
237
- state.isPluginWebServer?.also {
238
- result.putBoolean("isPluginWebServer", state.isPluginWebServer!!)
239
- } ?: result.putNull("isPluginWebServer")
240
- state.function?.also {
241
- result.putString("function", state.function.toString())
242
- } ?: result.putNull("function")
243
- state.isMySettingChanged?.also {
244
- result.putBoolean("isMySettingChanged", state.isMySettingChanged!!)
245
- } ?: result.putNull("isMySettingChanged")
246
- result.putString("currentMicrophone", state.currentMicrophone?.toString())
247
- result.putBoolean("isSdCard", state.isSdCard)
248
- state.cameraError?.also {
249
- result.putArray("cameraError", Arguments.makeNativeArray(state.cameraError!!.map { it.toString() }))
250
- } ?: result.putNull("cameraError")
251
- state.isBatteryInsert?.also {
252
- result.putString("isBatteryInsert", state.isBatteryInsert.toString())
253
- } ?: result.putNull("isBatteryInsert")
254
- state.externalGpsInfo?.also {
255
- result.putMap(KEY_STATE_EXTERNAL_GPS_INFO, toResult(it))
256
- } ?: result.putNull(KEY_STATE_EXTERNAL_GPS_INFO)
257
- state.internalGpsInfo?.also {
258
- result.putMap(KEY_STATE_INTERNAL_GPS_INFO, toResult(it))
259
- } ?: result.putNull(KEY_STATE_INTERNAL_GPS_INFO)
260
- state.boardTemp?.also {
261
- result.putInt(KEY_STATE_BOARD_TEMP, it)
262
- } ?: result.putNull(KEY_STATE_BOARD_TEMP)
263
- state.batteryTemp?.also {
264
- result.putInt(KEY_STATE_BATTERY_TEMP, it)
265
- } ?: result.putNull(KEY_STATE_BATTERY_TEMP)
222
+ val result = toResult(state)
266
223
  promise.resolve(result)
267
224
  } catch (t: Throwable) {
268
225
  promise.reject(t)
@@ -2035,6 +1992,73 @@ class ThetaClientReactNativeModule(
2035
1992
  }
2036
1993
  }
2037
1994
 
1995
+ @ReactMethod
1996
+ fun getEventWebSocket(promise: Promise) {
1997
+ val theta = this.theta
1998
+ if (theta == null) {
1999
+ promise.reject(Exception(messageNotInit))
2000
+ return
2001
+ }
2002
+ launch {
2003
+ eventWebSocket?.stop()
2004
+ eventWebSocket = theta.getEventWebSocket()
2005
+ promise.resolve(true)
2006
+ }
2007
+ }
2008
+
2009
+ @ReactMethod
2010
+ fun eventWebSocketStart(promise: Promise) {
2011
+ val theta = this.theta
2012
+ if (theta == null) {
2013
+ promise.reject(Exception(messageNotInit))
2014
+ return
2015
+ }
2016
+ val eventWebSocket = this.eventWebSocket
2017
+ if (eventWebSocket == null) {
2018
+ promise.reject(Exception("no eventWebSocket"))
2019
+ return
2020
+ }
2021
+ launch {
2022
+ eventWebSocket.stop()
2023
+ try {
2024
+ eventWebSocket.start(object : EventWebSocket.Callback {
2025
+ override fun onClose() {
2026
+ sendNotifyEvent(
2027
+ toNotify(NOTIFY_EVENT_WEBSOCKET_CLOSE, null)
2028
+ )
2029
+ }
2030
+
2031
+ override fun onReceive(event: CameraEvent) {
2032
+ sendNotifyEvent(
2033
+ toNotify(NOTIFY_EVENT_WEBSOCKET_EVENT, toEventWebSocketEventNotifyParam(event))
2034
+ )
2035
+ }
2036
+ })
2037
+ promise.resolve(true)
2038
+ } catch (t: Throwable) {
2039
+ promise.reject(t)
2040
+ }
2041
+ }
2042
+ }
2043
+
2044
+ @ReactMethod
2045
+ fun eventWebSocketStop(promise: Promise) {
2046
+ val theta = this.theta
2047
+ if (theta == null) {
2048
+ promise.reject(Exception(messageNotInit))
2049
+ return
2050
+ }
2051
+ val eventWebSocket = this.eventWebSocket
2052
+ if (eventWebSocket == null) {
2053
+ promise.reject(Exception("no eventWebSocket"))
2054
+ return
2055
+ }
2056
+ launch {
2057
+ eventWebSocket.stop()
2058
+ promise.resolve(true)
2059
+ }
2060
+ }
2061
+
2038
2062
  companion object {
2039
2063
  const val NAME = "ThetaClientReactNative"
2040
2064
  const val EVENT_NAME = "ThetaFrameEvent"
@@ -2052,5 +2076,7 @@ class ThetaClientReactNativeModule(
2052
2076
  const val NOTIFY_MULTI_BRACKET_PROGRESS = "MULTI-BRACKET-PROGRESS"
2053
2077
  const val NOTIFY_MULTI_BRACKET_STOP_ERROR = "MULTI-BRACKET-STOP-ERROR"
2054
2078
  const val NOTIFY_CONTINUOUS_PROGRESS = "CONTINUOUS-PROGRESS"
2079
+ const val NOTIFY_EVENT_WEBSOCKET_EVENT = "EVENT-WEBSOCKET-EVENT"
2080
+ const val NOTIFY_EVENT_WEBSOCKET_CLOSE = "EVENT-WEBSOCKET-CLOSE"
2055
2081
  }
2056
2082
  }
@@ -5,6 +5,7 @@ let KEY_CLIENT_MODE = "clientMode"
5
5
  let KEY_NOTIFY_NAME = "name"
6
6
  let KEY_NOTIFY_PARAMS = "params"
7
7
  let KEY_NOTIFY_PARAM_COMPLETION = "completion"
8
+ let KEY_NOTIFY_PARAM_EVENT = "event"
8
9
  let KEY_NOTIFY_PARAM_IMAGE = "image"
9
10
  let KEY_NOTIFY_PARAM_MESSAGE = "message"
10
11
  let KEY_DATETIME = "dateTime"
@@ -63,6 +64,12 @@ let KEY_STATE_EXTERNAL_GPS_INFO = "externalGpsInfo"
63
64
  let KEY_STATE_INTERNAL_GPS_INFO = "internalGpsInfo"
64
65
  let KEY_STATE_BOARD_TEMP = "boardTemp"
65
66
  let KEY_STATE_BATTERY_TEMP = "batteryTemp"
67
+ let KEY_PROXY = "proxy"
68
+ let KEY_IP_ADDRESS = "ipAddress"
69
+ let KEY_SUBNET_MASK = "subnetMask"
70
+ let KEY_DEFAULT_GATEWAY = "defaultGateway"
71
+ let KEY_OPTIONS = "options"
72
+ let KEY_STATE = "state"
66
73
 
67
74
  public class ConvertUtil: NSObject {}
68
75
 
@@ -89,6 +96,7 @@ let optionItemNameToEnum = [
89
96
  "compositeShootingTime": ThetaRepository.OptionNameEnum.compositeshootingtime,
90
97
  "continuousNumber": ThetaRepository.OptionNameEnum.continuousnumber,
91
98
  "dateTimeZone": ThetaRepository.OptionNameEnum.datetimezone,
99
+ "ethernetConfig": ThetaRepository.OptionNameEnum.ethernetconfig,
92
100
  "exposureCompensation": ThetaRepository.OptionNameEnum.exposurecompensation,
93
101
  "exposureDelay": ThetaRepository.OptionNameEnum.exposuredelay,
94
102
  "exposureProgram": ThetaRepository.OptionNameEnum.exposureprogram,
@@ -225,6 +233,10 @@ func setOptionsValue(options: ThetaRepository.Options, name: String, value: Any)
225
233
  options.exposureCompensation = getEnumValue(
226
234
  values: ThetaRepository.ExposureCompensationEnum.values(), name: value as! String
227
235
  )!
236
+ case ThetaRepository.OptionNameEnum.ethernetconfig.name:
237
+ if let params = value as? [String: Any] {
238
+ options.ethernetConfig = toEthernetConfig(params: params)
239
+ }
228
240
  case ThetaRepository.OptionNameEnum.exposuredelay.name:
229
241
  options.exposureDelay = getEnumValue(
230
242
  values: ThetaRepository.ExposureDelayEnum.values(), name: value as! String
@@ -383,6 +395,10 @@ func convertResult(options: ThetaRepository.Options) -> [String: Any] {
383
395
  let burstOption = value as? ThetaRepository.BurstOption
384
396
  {
385
397
  result[key] = convertResult(burstOption: burstOption)
398
+ } else if value is ThetaRepository.EthernetConfig,
399
+ let ethernetConfig = value as? ThetaRepository.EthernetConfig
400
+ {
401
+ result[key] = convertResult(ethernetConfig: ethernetConfig)
386
402
  } else if value is ThetaRepository.GpsInfo {
387
403
  let gpsInfo = value as! ThetaRepository.GpsInfo
388
404
  result[key] = convertResult(gpsInfo: gpsInfo)
@@ -429,6 +445,12 @@ func toCaptureProgressNotifyParam(value: Float) -> [String: Any] {
429
445
  ]
430
446
  }
431
447
 
448
+ func toEventWebSocketEventNotifyParam(value: CameraEvent) -> [String: Any] {
449
+ return [
450
+ KEY_NOTIFY_PARAM_EVENT: convertResult(cameraEvent: value),
451
+ ]
452
+ }
453
+
432
454
  func toMessageNotifyParam(value: String) -> [String: Any] {
433
455
  return [
434
456
  KEY_NOTIFY_PARAM_MESSAGE: value,
@@ -825,31 +847,73 @@ func convertResult(cameraErrorList: [ThetaRepository.CameraErrorEnum]?) -> [Stri
825
847
  }
826
848
 
827
849
  func convertResult(thetaState: ThetaRepository.ThetaState) -> [String: Any?] {
828
- var result = [
829
- "fingerprint": thetaState.fingerprint,
830
- "batteryLevel": thetaState.batteryLevel,
831
- "storageUri": thetaState.storageUri,
832
- "storageID": thetaState.storageID,
833
- "captureStatus": thetaState.captureStatus.name,
834
- "recordedTime": thetaState.recordedTime,
835
- "recordableTime": thetaState.recordableTime,
836
- "capturedPictures": thetaState.capturedPictures,
837
- "compositeShootingElapsedTime": thetaState.compositeShootingElapsedTime,
838
- "latestFileUrl": thetaState.latestFileUrl,
839
- "chargingState": thetaState.chargingState.name,
840
- "apiVersion": thetaState.apiVersion,
841
- "isPluginRunning": convertKotlinBooleanToBool(value: thetaState.isPluginRunning),
842
- "isPluginWebServer": convertKotlinBooleanToBool(value: thetaState.isPluginWebServer),
843
- "function": thetaState.function?.name,
844
- "isMySettingChanged": convertKotlinBooleanToBool(value: thetaState.isMySettingChanged),
845
- "currentMicrophone": thetaState.currentMicrophone?.name,
846
- "isSdCard": convertKotlinBooleanToBool(value: thetaState.isSdCard),
847
- "cameraError": convertResult(cameraErrorList: thetaState.cameraError),
848
- "isBatteryInsert": convertKotlinBooleanToBool(value: thetaState.isBatteryInsert),
849
- KEY_STATE_BOARD_TEMP: thetaState.boardTemp,
850
- KEY_STATE_BATTERY_TEMP: thetaState.batteryTemp,
851
- ] as [String: Any?]
852
-
850
+ var result: [String: Any] = [:]
851
+ if let value = thetaState.fingerprint {
852
+ result["fingerprint"] = value
853
+ }
854
+ if let value = thetaState.batteryLevel {
855
+ result["batteryLevel"] = value
856
+ }
857
+ if let value = thetaState.storageUri {
858
+ result["storageUri"] = value
859
+ }
860
+ if let value = thetaState.storageID {
861
+ result["storageID"] = value
862
+ }
863
+ if let value = thetaState.captureStatus {
864
+ result["captureStatus"] = value.name
865
+ }
866
+ if let value = thetaState.recordedTime {
867
+ result["recordedTime"] = value
868
+ }
869
+ if let value = thetaState.recordableTime {
870
+ result["recordableTime"] = value
871
+ }
872
+ if let value = thetaState.capturedPictures {
873
+ result["capturedPictures"] = value
874
+ }
875
+ if let value = thetaState.compositeShootingElapsedTime {
876
+ result["compositeShootingElapsedTime"] = value
877
+ }
878
+ if let value = thetaState.latestFileUrl {
879
+ result["latestFileUrl"] = value
880
+ }
881
+ if let value = thetaState.chargingState {
882
+ result["chargingState"] = value.name
883
+ }
884
+ if let value = thetaState.apiVersion {
885
+ result["apiVersion"] = value
886
+ }
887
+ if let value = thetaState.isPluginRunning {
888
+ result["isPluginRunning"] = convertKotlinBooleanToBool(value: value)
889
+ }
890
+ if let value = thetaState.isPluginWebServer {
891
+ result["isPluginWebServer"] = convertKotlinBooleanToBool(value: value)
892
+ }
893
+ if let value = thetaState.function {
894
+ result["function"] = value.name
895
+ }
896
+ if let value = thetaState.isMySettingChanged {
897
+ result["isMySettingChanged"] = convertKotlinBooleanToBool(value: value)
898
+ }
899
+ if let value = thetaState.currentMicrophone {
900
+ result["currentMicrophone"] = value.name
901
+ }
902
+ if let value = thetaState.isSdCard {
903
+ result["isSdCard"] = convertKotlinBooleanToBool(value: value)
904
+ }
905
+ if let value = thetaState.cameraError {
906
+ result["cameraError"] = convertResult(cameraErrorList: value)
907
+ }
908
+ if let value = thetaState.isBatteryInsert {
909
+ result["isBatteryInsert"] = convertKotlinBooleanToBool(value: value)
910
+ }
911
+ if let value = thetaState.boardTemp {
912
+ result[KEY_STATE_BOARD_TEMP] = value
913
+ }
914
+ if let value = thetaState.batteryTemp {
915
+ result[KEY_STATE_BATTERY_TEMP] = value
916
+ }
853
917
  if let externalGpsInfo = thetaState.externalGpsInfo {
854
918
  result[KEY_STATE_EXTERNAL_GPS_INFO] = convertResult(stateGpsInfo: externalGpsInfo)
855
919
  }
@@ -917,6 +981,23 @@ func convertResult(autoBracket: ThetaRepository.BracketSettingList) -> [[String:
917
981
  return resultList
918
982
  }
919
983
 
984
+ func convertResult(ethernetConfig: ThetaRepository.EthernetConfig) -> [String: Any] {
985
+ var result: [String: Any] = ["usingDhcp": ethernetConfig.usingDhcp]
986
+ if let ipAddress = ethernetConfig.ipAddress {
987
+ result[KEY_IP_ADDRESS] = ipAddress
988
+ }
989
+ if let subnetMask = ethernetConfig.subnetMask {
990
+ result[KEY_SUBNET_MASK] = subnetMask
991
+ }
992
+ if let defaultGateway = ethernetConfig.defaultGateway {
993
+ result[KEY_DEFAULT_GATEWAY] = defaultGateway
994
+ }
995
+ if let proxy = ethernetConfig.proxy {
996
+ result[KEY_PROXY] = convertResult(proxy: proxy)
997
+ }
998
+ return result
999
+ }
1000
+
920
1001
  func convertResult(gpsInfo: ThetaRepository.GpsInfo) -> [String: Any] {
921
1002
  return [
922
1003
  "latitude": gpsInfo.latitude,
@@ -1020,16 +1101,16 @@ func convertResult(accessPointList: [ThetaRepository.AccessPoint]) -> [[String:
1020
1101
  result["connectionPriority"] = accessPoint.connectionPriority
1021
1102
  result["usingDhcp"] = accessPoint.usingDhcp
1022
1103
  if let ipAddress = accessPoint.ipAddress {
1023
- result["ipAddress"] = ipAddress
1104
+ result[KEY_IP_ADDRESS] = ipAddress
1024
1105
  }
1025
1106
  if let subnetMask = accessPoint.subnetMask {
1026
- result["subnetMask"] = subnetMask
1107
+ result[KEY_SUBNET_MASK] = subnetMask
1027
1108
  }
1028
1109
  if let defaultGateway = accessPoint.defaultGateway {
1029
- result["defaultGateway"] = defaultGateway
1110
+ result[KEY_DEFAULT_GATEWAY] = defaultGateway
1030
1111
  }
1031
1112
  if let proxy = accessPoint.proxy {
1032
- result["proxy"] = convertResult(proxy: proxy)
1113
+ result[KEY_PROXY] = convertResult(proxy: proxy)
1033
1114
  }
1034
1115
  resultList.append(result)
1035
1116
  }
@@ -1056,6 +1137,19 @@ func toPluginInfosResult(pluginInfoList: [ThetaRepository.PluginInfo]) -> [[Stri
1056
1137
  return resultList
1057
1138
  }
1058
1139
 
1140
+ func convertResult(cameraEvent: CameraEvent) -> [String: Any]
1141
+ {
1142
+ var result = [String: Any]()
1143
+ if let value = cameraEvent.options {
1144
+ result[KEY_OPTIONS] = convertResult(options: value)
1145
+ }
1146
+ if let value = cameraEvent.state {
1147
+ result[KEY_STATE] = convertResult(thetaState: value)
1148
+ }
1149
+
1150
+ return result
1151
+ }
1152
+
1059
1153
  // MARK: - Convert to theta-client object
1060
1154
 
1061
1155
  func toBitrate(value: Any) -> ThetaRepositoryBitrate? {
@@ -1221,6 +1315,21 @@ func toAutoBracket(params: [[String: Any]]) -> ThetaRepository.BracketSettingLis
1221
1315
  return autoBracket
1222
1316
  }
1223
1317
 
1318
+ func toEthernetConfig(params: [String: Any]) -> ThetaRepository.EthernetConfig {
1319
+ var proxy: ThetaRepository.Proxy? = nil
1320
+ if let data = params[KEY_PROXY] as? [String: Any] {
1321
+ proxy = toProxy(params: data)
1322
+ }
1323
+
1324
+ return ThetaRepository.EthernetConfig(
1325
+ usingDhcp: params["usingDhcp"] as? Bool ?? true,
1326
+ ipAddress: params[KEY_IP_ADDRESS] as? String,
1327
+ subnetMask: params[KEY_SUBNET_MASK] as? String,
1328
+ defaultGateway: params[KEY_DEFAULT_GATEWAY] as? String,
1329
+ proxy: proxy
1330
+ )
1331
+ }
1332
+
1224
1333
  func toGpsInfo(params: [String: Any]) -> ThetaRepository.GpsInfo? {
1225
1334
  guard let latitude = params[KEY_GPS_LATITUDE] as? Double,
1226
1335
  let longitude = params[KEY_GPS_LONGITUDE] as? Double,
@@ -276,6 +276,15 @@ RCT_EXTERN_METHOD(setBluetoothDevice:(NSString *)uuid
276
276
  withResolver:(RCTPromiseResolveBlock)resolve
277
277
  withRejecter:(RCTPromiseRejectBlock)reject)
278
278
 
279
+ RCT_EXTERN_METHOD(getEventWebSocket:(RCTPromiseResolveBlock)resolve
280
+ withRejecter:(RCTPromiseRejectBlock)reject)
281
+
282
+ RCT_EXTERN_METHOD(eventWebSocketStart:(RCTPromiseResolveBlock)resolve
283
+ withRejecter:(RCTPromiseRejectBlock)reject)
284
+
285
+ RCT_EXTERN_METHOD(eventWebSocketStop:(RCTPromiseResolveBlock)resolve
286
+ withRejecter:(RCTPromiseRejectBlock)reject)
287
+
279
288
  + (BOOL)requiresMainQueueSetup
280
289
  {
281
290
  return NO;