Skip to content
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 .github/workflows/test-kmp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
arguments: testDebugUnitTest
- name: Archive code coverage results
if: always()
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: test-kmp-report
path: kotlin-multiplatform/build/reports/tests/testDebugUnitTest
2 changes: 1 addition & 1 deletion .github/workflows/test-rn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
yarn test --collectCoverage
- name: Archive code coverage results
if: always()
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: test-react-native-report
path: react-native/coverage
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
arguments: testDebugUnitTest
- name: Archive code coverage results
if: always()
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: kotlin-multiplatform/build/reports/tests/testDebugUnitTest
10 changes: 8 additions & 2 deletions demos/demo-android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ dependencies {
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"

implementation "com.ricoh360.thetaclient:theta-client:1.5.0"
implementation "com.ricoh360.thetaclient:theta-client:1.9.0"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3"
implementation "io.ktor:ktor-client-android:$ktor_version"
implementation "io.ktor:ktor-client-logging:$ktor_version"
implementation "io.ktor:ktor-client-content-negotiation:$ktor_version"
implementation "io.ktor:ktor-serialization-kotlinx-json:$ktor_version"
implementation 'org.slf4j:slf4j-android:1.7.36'

implementation "com.ricoh360.thetableclient:theta-ble-client-android:1.2.0"
implementation "com.ricoh360.thetableclient:theta-ble-client-android:1.3.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.ricoh360.thetaclient.ThetaRepository
import com.ricoh360.thetableclient.ThetaBle
import com.ricoh360.thetableclient.service.CameraStatusCommand
import com.ricoh360.thetableclient.service.data.GpsInfo
Expand All @@ -14,12 +13,12 @@ import com.ricoh360.thetableclient.service.data.values.CameraPower
import com.ricoh360.thetableclient.service.data.values.CaptureMode
import com.ricoh360.thetableclient.service.data.values.ChargingState
import com.ricoh360.thetableclient.service.data.values.PluginPowerStatus
import com.ricoh360.thetaclient.ThetaRepository
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.lang.StringBuilder

class ThetaViewModel : ViewModel() {
private val _infoText = MutableLiveData("Initialized")
Expand All @@ -44,30 +43,38 @@ class ThetaViewModel : ViewModel() {
private val uuid = APP_UUID
private var thetaDevice: ThetaBle.ThetaDevice? = null

fun getBleThetaName(info: ThetaInfo): String {
return when (info.model) {
"RICOH360 THETA A1" -> "AA" + info.serialNumber.takeLast(8)
else -> info.serialNumber.takeLast(8)
}
}

fun connectWifi() {
scope.launch {
var thetaRepository: ThetaRepository? = null
val thetaRepository: ThetaRepository?
try {
thetaRepository = ThetaRepository.newInstance("http://192.168.1.1")
thetaRepository.let {
val info = it.getThetaInfo()
val devName = info.serialNumber.takeLast(8)
val info = getThetaInfoApi()
val devName = getBleThetaName(info)
setDevice(devName, false)
setInfoText("wifi connected. $devName")
}
} catch (e: Throwable) {
e.printStackTrace()
return@launch
}
try {
thetaRepository?.let {
thetaRepository.let {
val name = it.setBluetoothDevice(uuid)
setDevice(name, true)
}
} catch (e: Throwable) {
e.printStackTrace()
}
try {
thetaRepository?.let {
thetaRepository.let {
val options =
ThetaRepository.Options(bluetoothPower = ThetaRepository.BluetoothPowerEnum.ON)
it.setOptions(options)
Expand Down Expand Up @@ -369,6 +376,7 @@ class ThetaViewModel : ViewModel() {
null
}
}

fun setPluginControl(value: PluginPowerStatus) {
scope.launch {
val device = thetaDevice
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.ricoh360.thetableclient.thetaBleClientDemo

import io.ktor.client.HttpClient
import io.ktor.client.call.body
import io.ktor.client.engine.android.Android
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.client.plugins.logging.LogLevel
import io.ktor.client.plugins.logging.Logging
import io.ktor.client.request.get
import io.ktor.client.statement.HttpResponse
import io.ktor.serialization.kotlinx.json.json
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json

const val ENDPOINT = "http://192.168.1.1:80"

@OptIn(ExperimentalSerializationApi::class)
fun newHttpClient(): HttpClient {
return HttpClient(Android) {
engine {
connectTimeout = 30_000
socketTimeout = 30_000
}
install(ContentNegotiation) {
json(
Json {
encodeDefaults = true
explicitNulls = false
ignoreUnknownKeys = true
}
)
}
install(Logging) {
level = LogLevel.ALL
}
}
}

suspend fun get(path: String): HttpResponse {
val httpClient = newHttpClient()
val response = httpClient.get(ENDPOINT + path)
return response
}

@Serializable
data class ThetaInfo(
val model: String,
val serialNumber: String,
)

suspend fun getThetaInfoApi(): ThetaInfo {
return get("/osc/info").body()
}
2 changes: 2 additions & 0 deletions demos/demo-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ buildscript {
compose_version = '1.5.3' // depends on Kotlin 1.9.10
kotlin_version = '1.9.10'
coroutines_version = '1.7.3'
ktor_version = "2.3.9"
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
Expand All @@ -15,6 +16,7 @@ plugins {
id 'com.android.application' version '8.1.2' apply false
id 'com.android.library' version '8.1.2' apply false
id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
}

task clean(type: Delete) {
Expand Down
4 changes: 2 additions & 2 deletions demos/demo-ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ target 'demo-ios' do
use_frameworks!

# Pods for demo-ios
pod 'THETAClient', '1.4.0'
pod 'THETABleClient', '1.2.0'
pod 'THETAClient', '1.9.0'
pod 'THETABleClient', '1.3.0'

end
4 changes: 4 additions & 0 deletions demos/demo-ios/demo-ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
1A5CA7899BC0D829943A7117 /* Pods_demo_ios.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9813411A213924B4238F293E /* Pods_demo_ios.framework */; };
C9434D072AD63E8100FC7903 /* CameraControlCommandV2View.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9434D062AD63E8100FC7903 /* CameraControlCommandV2View.swift */; };
C9717B552C042C8F002EA4CD /* WebApiUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9717B542C042C8F002EA4CD /* WebApiUtil.swift */; };
C98E162529C1DABF00054429 /* ThetaBleApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = C98E162429C1DABF00054429 /* ThetaBleApi.swift */; };
C993A6F029C1D8ED00E2631D /* demo_iosApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = C993A6EF29C1D8ED00E2631D /* demo_iosApp.swift */; };
C993A6F229C1D8ED00E2631D /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C993A6F129C1D8ED00E2631D /* ContentView.swift */; };
Expand All @@ -22,6 +23,7 @@
5B617CB2EB69FF6F4ACAF615 /* Pods-demo-ios.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-demo-ios.release.xcconfig"; path = "Target Support Files/Pods-demo-ios/Pods-demo-ios.release.xcconfig"; sourceTree = "<group>"; };
9813411A213924B4238F293E /* Pods_demo_ios.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_demo_ios.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C9434D062AD63E8100FC7903 /* CameraControlCommandV2View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraControlCommandV2View.swift; sourceTree = "<group>"; };
C9717B542C042C8F002EA4CD /* WebApiUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebApiUtil.swift; sourceTree = "<group>"; };
C98E162429C1DABF00054429 /* ThetaBleApi.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThetaBleApi.swift; sourceTree = "<group>"; };
C993A6EC29C1D8ED00E2631D /* demo-ios.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "demo-ios.app"; sourceTree = BUILT_PRODUCTS_DIR; };
C993A6EF29C1D8ED00E2631D /* demo_iosApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = demo_iosApp.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -88,6 +90,7 @@
C9CEC3B729ED350100EA12D5 /* CameraStatusView.swift */,
C993A6F329C1D8F000E2631D /* Assets.xcassets */,
C993A6F529C1D8F000E2631D /* Preview Content */,
C9717B542C042C8F002EA4CD /* WebApiUtil.swift */,
);
path = "demo-ios";
sourceTree = "<group>";
Expand Down Expand Up @@ -217,6 +220,7 @@
C98E162529C1DABF00054429 /* ThetaBleApi.swift in Sources */,
C9CEC3B829ED350100EA12D5 /* CameraStatusView.swift in Sources */,
C993A6F229C1D8ED00E2631D /* ContentView.swift in Sources */,
C9717B552C042C8F002EA4CD /* WebApiUtil.swift in Sources */,
C993A6F029C1D8ED00E2631D /* demo_iosApp.swift in Sources */,
C9434D072AD63E8100FC7903 /* CameraControlCommandV2View.swift in Sources */,
);
Expand Down
11 changes: 5 additions & 6 deletions demos/demo-ios/demo-ios/CameraControlCommandV2View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import SwiftUI
import THETABleClient

struct CameraControlCommandV2View: View {

@ObservedObject var thetaBleApi: ThetaBleApi

var body: some View {
VStack {
Button("Get Info") {
Expand All @@ -21,21 +20,21 @@ struct CameraControlCommandV2View: View {
}
}
.buttonStyle(.borderedProminent)

Button("Get State") {
Task {
try? await thetaBleApi.cameraControlCommandV2GetState()
}
}
.buttonStyle(.borderedProminent)

Button("Get State2") {
Task {
try? await thetaBleApi.cameraControlCommandV2GetState2()
}
}
.buttonStyle(.borderedProminent)

Button("Set State Notify") {
Task {
thetaBleApi.cameraControlCommandV2SetStateNotify()
Expand Down Expand Up @@ -65,6 +64,6 @@ struct CameraControlCommandV2View: View {

struct CameraControlCommandV2View_Previews: PreviewProvider {
static var previews: some View {
ContentView( thetaBleApi: ThetaBleApi())
ContentView(thetaBleApi: ThetaBleApi())
}
}
3 changes: 1 addition & 2 deletions demos/demo-ios/demo-ios/CameraStatusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import SwiftUI
import THETABleClient

struct CameraStatusView: View {

@ObservedObject var thetaBleApi: ThetaBleApi

var body: some View {
Expand Down Expand Up @@ -106,6 +105,6 @@ struct CameraStatusView: View {

struct CameraStatusView_Previews: PreviewProvider {
static var previews: some View {
ContentView( thetaBleApi: ThetaBleApi())
ContentView(thetaBleApi: ThetaBleApi())
}
}
Loading
Loading