Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/1.7.1 #64

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demos/demo-android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ dependencies {
implementation 'com.jakewharton.timber:timber:5.0.1'
implementation 'io.coil-kt:coil-compose:2.2.2'
implementation "io.ktor:ktor-client-cio:2.1.3"
implementation "com.ricoh360.thetaclient:theta-client:1.7.0"
implementation "com.ricoh360.thetaclient:theta-client:1.7.1"

testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0'
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"
Expand Down
2 changes: 1 addition & 1 deletion demos/demo-ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ target 'SdkSample' do
use_frameworks!

# Pods for SdkSample
pod 'THETAClient', '1.7.0'
pod 'THETAClient', '1.7.1'
end
2 changes: 1 addition & 1 deletion demos/demo-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@react-navigation/native": "^6.1.0",
"@react-navigation/native-stack": "^6.9.5",
"theta-client-react-native": "1.7.0",
"theta-client-react-native": "1.7.1",
"react": "18.2.0",
"react-native": "0.71.14",
"react-native-safe-area-context": "^4.4.1",
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial-android.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- モジュールの`build.gradle`の`dependencies`に次を追加します。
```
implementation "com.ricoh360.thetaclient:theta-client:1.7.0"
implementation "com.ricoh360.thetaclient:theta-client:1.7.1"
```
- 本 SDK を使用したアプリケーションが動作するスマートフォンと THETA を無線 LAN 接続しておきます。

Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial-android.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- Add following descriptions to the `dependencies` of your module's `build.gradle`.

```
implementation "com.ricoh360.thetaclient:theta-client:1.7.0"
implementation "com.ricoh360.thetaclient:theta-client:1.7.1"
```

- Connect the wireless LAN between THETA and the smartphone that runs on the application using this SDK.
Expand Down
2 changes: 1 addition & 1 deletion flutter/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ dependencies {
implementation("io.ktor:ktor-serialization-kotlinx-json:2.1.2")
implementation("com.soywiz.korlibs.krypto:krypto:3.4.0")

implementation("com.ricoh360.thetaclient:theta-client:1.7.0")
implementation("com.ricoh360.thetaclient:theta-client:1.7.1")
}
4 changes: 2 additions & 2 deletions flutter/ios/theta_client_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
Pod::Spec.new do |s|
s.name = 'theta_client_flutter'
s.version = '1.7.0'
s.version = '1.7.1'
s.summary = 'theta-client plugin project.'
s.description = <<-DESC
theta-client Flutter plugin project.
Expand All @@ -17,7 +17,7 @@ Pod::Spec.new do |s|
s.dependency 'Flutter'
s.platform = :ios, '15.0'

s.dependency 'THETAClient', '1.7.0'
s.dependency 'THETAClient', '1.7.1'

# Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
Expand Down
4 changes: 4 additions & 0 deletions flutter/lib/theta_client_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,10 @@ enum MicrophoneOptionEnum {

/// Camera error
enum CameraErrorEnum {
/// Camera error
/// Undefined value
unknown('UNKNOWN'),

/// Camera error
/// Insufficient memory
noMemory('NO_MEMORY'),
Expand Down
2 changes: 1 addition & 1 deletion flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: theta_client_flutter
description: THETA Client Flutter plugin project.
version: 1.7.0
version: 1.7.1
homepage:

environment:
Expand Down
1 change: 1 addition & 0 deletions flutter/test/enum_name_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ void main() {

test('CameraErrorEnum', () async {
List<List<dynamic>> data = [
[CameraErrorEnum.unknown, 'UNKNOWN'],
[CameraErrorEnum.noMemory, 'NO_MEMORY'],
[CameraErrorEnum.fileNumberOver, 'FILE_NUMBER_OVER'],
[CameraErrorEnum.noDateSetting, 'NO_DATE_SETTING'],
Expand Down
2 changes: 1 addition & 1 deletion kotlin-multiplatform/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies {
dokkaPlugin("org.jetbrains.dokka:versioning-plugin:1.9.10")
}

val thetaClientVersion = "1.7.0"
val thetaClientVersion = "1.7.1"
group = "com.ricoh360.thetaclient"
version = thetaClientVersion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6181,6 +6181,11 @@ class ThetaRepository internal constructor(val endpoint: String, config: Config?
* Camera error
*/
enum class CameraErrorEnum {
/**
* Undefined value
*/
UNKNOWN,

/**
* Camera error
* Insufficient memory
Expand Down Expand Up @@ -6323,6 +6328,7 @@ class ThetaRepository internal constructor(val endpoint: String, config: Config?
*/
internal fun get(cameraError: CameraError): CameraErrorEnum {
return when (cameraError) {
CameraError.UNKNOWN -> UNKNOWN
CameraError.NO_MEMORY -> NO_MEMORY
CameraError.FILE_NUMBER_OVER -> FILE_NUMBER_OVER
CameraError.NO_DATE_SETTING -> NO_DATE_SETTING
Expand All @@ -6344,7 +6350,7 @@ class ThetaRepository internal constructor(val endpoint: String, config: Config?
CameraError.HIGH_TEMPERATURE_WARNING -> HIGH_TEMPERATURE_WARNING
CameraError.HIGH_TEMPERATURE -> HIGH_TEMPERATURE
CameraError.BATTERY_HIGH_TEMPERATURE -> BATTERY_HIGH_TEMPERATURE
CameraError.COMPASS_CALIBRATION -> COMPASS_CALIBRATION
CameraError.COMPASS_CALIBRATION, CameraError.ELECTRONIC_COMPASS_CALIBRATION -> COMPASS_CALIBRATION
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,24 @@ internal object NumbersAsLongsSerializer : KSerializer<List<Long>> {
return result
}
}

internal abstract class EnumIgnoreUnknownSerializer<T : Enum<T>>(
values: List<T>,
private val defaultValue: T,
) : KSerializer<T> {
override val descriptor: SerialDescriptor =
PrimitiveSerialDescriptor(values.first()::class.qualifiedName!!, PrimitiveKind.STRING)
private val lookup = values.associateBy({ it }, { it.serialName })
private val revLookup = values.associateBy { it.serialName }

private val Enum<T>.serialName: String
get() = name

override fun serialize(encoder: Encoder, value: T) {
encoder.encodeString(lookup.getValue(value))
}

override fun deserialize(decoder: Decoder): T {
return revLookup[decoder.decodeString()] ?: defaultValue
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package com.ricoh360.thetaclient.transferred
import io.ktor.http.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonNames

/**
* /osc/state api request
Expand Down Expand Up @@ -330,11 +331,20 @@ internal enum class StorageOption {
SD,
}

internal object CameraErrorSerializer :
EnumIgnoreUnknownSerializer<CameraError>(CameraError.entries, CameraError.UNKNOWN)

/**
* Camera error
*/
@Serializable
@Serializable(with = CameraErrorSerializer::class)
internal enum class CameraError {
/**
* Undefined value
*/
@SerialName("UNKNOWN")
UNKNOWN,

/**
* RICOH THETA X or later
* 0x00000001: Insufficient memory
Expand Down Expand Up @@ -483,6 +493,14 @@ internal enum class CameraError {
@SerialName("COMPASS_CALIBRATION")
COMPASS_CALIBRATION,

/**
* 0x00000010: Electronic compass error
* for RICOH THETA X
* Same as COMPASS_CALIBRATION and will be deleted.
*/
@SerialName("ELECTRONIC_COMPASS_CALIBRATION")
ELECTRONIC_COMPASS_CALIBRATION,

// 0x00000800: Plug-in start warning (IoT technical standards
// compliance)
// PLUGIN_BOOT_ERROR("PLUGIN_BOOT_ERROR"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,110 @@ class GetThetaStateTest {
assertTrue(thetaState.isBatteryInsert!!, "state isBatteryInsert")
}

/**
* Camera error of ELECTRONIC_COMPASS_CALIBRATION for THETA X.
*/
@Test
fun electronicCompassCalibrationErrorTest() = runTest {
// setup
val jsonString =
Resource("src/commonTest/resources/state/state_x_electronic_compass_calibration.json").readText()
MockApiClient.onRequest = { request ->
assertEquals(request.url.encodedPath, "/osc/state", "request path")
ByteReadChannel(jsonString)
}

// test
val thetaRepository = ThetaRepository(endpoint)
val thetaState = thetaRepository.getThetaState()

// check
assertTrue(thetaState.fingerprint.isNotEmpty(), "state fingerprint")
assertTrue(thetaState.batteryLevel > 0, "state batteryLevel")
assertTrue(thetaState.storageUri!!.startsWith("http://"), "state storageUri")
assertTrue(thetaState.storageID!!.isNotEmpty(), "state storageUri")
assertEquals(thetaState.captureStatus, ThetaRepository.CaptureStatusEnum.IDLE, "state captureStatus")
assertTrue(thetaState.recordedTime >= 0, "state recordedTime")
assertTrue(thetaState.recordableTime >= 0, "state recordableTime")
assertTrue(thetaState.capturedPictures!! >= 0, "state capturedPictures")
assertNull(thetaState.compositeShootingElapsedTime, "compositeShootingElapsedTime")
assertTrue(thetaState.latestFileUrl.startsWith("http://"), "state latestFileUrl")
assertEquals(thetaState.chargingState, ThetaRepository.ChargingStateEnum.NOT_CHARGING, "state chargingState")
assertEquals(thetaState.apiVersion, 2, "state apiVersion")
assertTrue(!thetaState.isPluginRunning!!, "state isPluginRunning")
assertTrue(thetaState.isPluginWebServer!!, "state isPluginWebServer")
assertEquals(thetaState.function, ThetaRepository.ShootingFunctionEnum.NORMAL, "state function")
assertTrue(!thetaState.isMySettingChanged!!, "state isMySettingChanged")
assertEquals(thetaState.currentMicrophone!!, ThetaRepository.MicrophoneOptionEnum.INTERNAL, "state currentMicrophone")
assertTrue(!thetaState.isSdCard, "state isSdCard")
assertEquals(
thetaState.cameraError!![0],
ThetaRepository.CameraErrorEnum.COMPASS_CALIBRATION,
"state cameraError"
)
assertTrue(thetaState.isBatteryInsert!!, "state isBatteryInsert")
}

/**
* Camera error of ELECTRONIC_COMPASS_CALIBRATION for THETA X.
*/
@Test
fun unknownErrorTest() = runTest {
// setup
val jsonString =
Resource("src/commonTest/resources/state/state_x_unknown_camera_error.json").readText()
MockApiClient.onRequest = { request ->
assertEquals(request.url.encodedPath, "/osc/state", "request path")
ByteReadChannel(jsonString)
}

// test
val thetaRepository = ThetaRepository(endpoint)
val thetaState = thetaRepository.getThetaState()

// check
assertTrue(thetaState.fingerprint.isNotEmpty(), "state fingerprint")
assertTrue(thetaState.batteryLevel > 0, "state batteryLevel")
assertTrue(thetaState.storageUri!!.startsWith("http://"), "state storageUri")
assertTrue(thetaState.storageID!!.isNotEmpty(), "state storageUri")
assertEquals(
thetaState.captureStatus,
ThetaRepository.CaptureStatusEnum.IDLE,
"state captureStatus"
)
assertTrue(thetaState.recordedTime >= 0, "state recordedTime")
assertTrue(thetaState.recordableTime >= 0, "state recordableTime")
assertTrue(thetaState.capturedPictures!! >= 0, "state capturedPictures")
assertNull(thetaState.compositeShootingElapsedTime, "compositeShootingElapsedTime")
assertTrue(thetaState.latestFileUrl.startsWith("http://"), "state latestFileUrl")
assertEquals(
thetaState.chargingState,
ThetaRepository.ChargingStateEnum.NOT_CHARGING,
"state chargingState"
)
assertEquals(thetaState.apiVersion, 2, "state apiVersion")
assertTrue(!thetaState.isPluginRunning!!, "state isPluginRunning")
assertTrue(thetaState.isPluginWebServer!!, "state isPluginWebServer")
assertEquals(
thetaState.function,
ThetaRepository.ShootingFunctionEnum.NORMAL,
"state function"
)
assertTrue(!thetaState.isMySettingChanged!!, "state isMySettingChanged")
assertEquals(
thetaState.currentMicrophone!!,
ThetaRepository.MicrophoneOptionEnum.INTERNAL,
"state currentMicrophone"
)
assertTrue(!thetaState.isSdCard, "state isSdCard")
assertEquals(
thetaState.cameraError!![0],
ThetaRepository.CameraErrorEnum.UNKNOWN,
"state cameraError"
)
assertTrue(thetaState.isBatteryInsert!!, "state isBatteryInsert")
}

/**
* Check setting of ThetaState.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"fingerprint": "FIG_0001",
"state": {
"_apiVersion": 2,
"_batteryInsert": true,
"batteryLevel": 0.33,
"_batteryState": "disconnect",
"_cameraError": ["ELECTRONIC_COMPASS_CALIBRATION"],
"_captureStatus": "idle",
"_capturedPictures": 0,
"_currentMicrophone": "Internal",
"_currentStorage": "IN",
"_function": "normal",
"_latestFileUrl": "http://192.168.1.1/files/100RICOH/R0010015.JPG",
"_mySettingChanged": false,
"_pluginRunning": false,
"_pluginWebServer": true,
"_recordableTime": 0,
"_recordedTime": 0,
"_storageID": "90014a68423861503e030277e0c2b500",
"storageUri": "http://192.168.1.1/files/"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"fingerprint": "FIG_0001",
"state": {
"_apiVersion": 2,
"_batteryInsert": true,
"batteryLevel": 0.33,
"_batteryState": "disconnect",
"_cameraError": ["error_unknown"],
"_captureStatus": "idle",
"_capturedPictures": 0,
"_currentMicrophone": "Internal",
"_currentStorage": "IN",
"_function": "normal",
"_latestFileUrl": "http://192.168.1.1/files/100RICOH/R0010015.JPG",
"_mySettingChanged": false,
"_pluginRunning": false,
"_pluginWebServer": true,
"_recordableTime": 0,
"_recordedTime": 0,
"_storageID": "90014a68423861503e030277e0c2b500",
"storageUri": "http://192.168.1.1/files/"
}
}
2 changes: 1 addition & 1 deletion react-native/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ dependencies {
implementation "com.facebook.react:react-native:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
implementation "com.ricoh360.thetaclient:theta-client:1.7.0"
implementation "com.ricoh360.thetaclient:theta-client:1.7.1"

// From node_modules
}
Expand Down
2 changes: 1 addition & 1 deletion react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "theta-client-react-native",
"version": "1.7.0",
"version": "1.7.1",
"description": "This library provides a way to control RICOH THETA using.",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
Loading
Loading