Skip to content

Commit

Permalink
Merge pull request #5 from ricohapi/dev/1.2.0
Browse files Browse the repository at this point in the history
Dev/1.2.0
  • Loading branch information
simago authored May 7, 2024
2 parents 228cdf9 + 36bc39e commit f149f71
Show file tree
Hide file tree
Showing 52 changed files with 1,909 additions and 83 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/test-kmp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Test kmp

on:
workflow_dispatch:
workflow_call:

permissions:
contents: read

jobs:
build:
runs-on: macos-13
steps:
- uses: actions/checkout@v3
- name: Select Xcode version
run: sudo xcode-select -s '/Applications/Xcode_15.0.1.app/Contents/Developer'
- name: Show Xcode version
run: xcodebuild -version
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: test-kmm
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: testDebugUnitTest
- name: Archive code coverage results
if: always()
uses: actions/upload-artifact@v1
with:
name: test-kmp-report
path: kotlin-multiplatform/build/reports/tests/testDebugUnitTest
14 changes: 14 additions & 0 deletions .github/workflows/test-pull-request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: pull request unit test

on:
workflow_dispatch:
pull_request:

permissions:
contents: read

jobs:
call-test-kmp:
uses: ./.github/workflows/test-kmp.yaml
call-test-rn:
uses: ./.github/workflows/test-rn.yaml
33 changes: 33 additions & 0 deletions .github/workflows/test-rn.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Test react native

on:
workflow_dispatch:
workflow_call:

permissions:
contents: read

jobs:
build:
runs-on: macos-13
steps:
- uses: actions/checkout@v3
- name: Select Xcode version
run: sudo xcode-select -s '/Applications/Xcode_15.0.1.app/Contents/Developer'
- name: Show Xcode version
run: xcodebuild -version
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: test-rn
run: |
cd ./react-native
yarn install
yarn test --collectCoverage
- name: Archive code coverage results
if: always()
uses: actions/upload-artifact@v1
with:
name: test-react-native-report
path: react-native/coverage
2 changes: 1 addition & 1 deletion demos/demo-android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@ dependencies {

implementation "com.ricoh360.thetaclient:theta-client:1.5.0"

implementation "com.ricoh360.thetableclient:theta-ble-client-android:1.1.0"
implementation "com.ricoh360.thetableclient:theta-ble-client-android:1.2.0"
}
2 changes: 1 addition & 1 deletion demos/demo-ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ target 'demo-ios' do

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

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 @@ -20,7 +20,7 @@
"react-native-safe-area-context": "^4.5.1",
"react-native-safe-area-view": "^1.1.1",
"react-native-screens": "^3.20.0",
"theta-ble-client-react-native": "1.1.0"
"theta-ble-client-react-native": "1.2.0"
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand Down
2 changes: 1 addition & 1 deletion kotlin-multiplatform/THETABleClient.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'THETABleClient'
spec.version = '1.1.0'
spec.version = '1.2.0'
spec.homepage = 'https://github.com/ricohapi/theta-ble-client'
spec.source = { :http=> ''}
spec.authors = 'Ricoh Co, Ltd.'
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 @@ -10,7 +10,7 @@ plugins {
signing
}

val theta_ble_version = "1.1.0"
val theta_ble_version = "1.2.0"

group = "com.ricoh360.thetableclient"
version = theta_ble_version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,18 @@ enum class BleCharacteristic(val bleService: BleService, val uuid: String) {
BleService.SHOOTING_CONTROL_COMMAND,
"D22B7C92-556E-4038-A5EF-A9AD56899B40",
),
FILE_FORMAT(
BleService.SHOOTING_CONTROL_COMMAND,
"E8F0EDD1-6C0F-494A-95C3-3244AE0B9A01",
),
ISO(
BleService.SHOOTING_CONTROL_COMMAND,
"ABB94D51-189F-455B-951D-ABE9B0333080",
),
MAX_RECORDABLE_TIME(
BleService.SHOOTING_CONTROL_COMMAND,
"6EABAB73-7F2B-4061-BE7C-1D71D143CB7D",
),
TAKE_PICTURE(
BleService.SHOOTING_CONTROL_COMMAND,
"FEC1805C-8905-4477-B862-BA5E447528A5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ internal const val MTU_SIZE = 512

internal const val ERROR_MESSAGE_NOT_CONNECTED = "Not connected."
internal const val ERROR_MESSAGE_EMPTY_DATA = "Empty data."
internal const val ERROR_MESSAGE_RESERVED_VALUE = "Reserved value."
internal const val ERROR_MESSAGE_UNKNOWN_VALUE = "Unknown value."
internal const val ERROR_MESSAGE_UNSUPPORTED_VALUE = "Unsupported value."

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ import com.ricoh360.thetableclient.BleCharacteristic
import com.ricoh360.thetableclient.BleService
import com.ricoh360.thetableclient.ERROR_MESSAGE_EMPTY_DATA
import com.ricoh360.thetableclient.ERROR_MESSAGE_NOT_CONNECTED
import com.ricoh360.thetableclient.ERROR_MESSAGE_RESERVED_VALUE
import com.ricoh360.thetableclient.ERROR_MESSAGE_UNKNOWN_VALUE
import com.ricoh360.thetableclient.ThetaBle
import com.ricoh360.thetableclient.ThetaBle.BluetoothException
import com.ricoh360.thetableclient.ThetaBle.ThetaBleApiException
import com.ricoh360.thetableclient.service.data.values.CaptureMode
import com.ricoh360.thetableclient.service.data.values.FileFormat
import com.ricoh360.thetableclient.service.data.values.MaxRecordableTime
import com.ricoh360.thetableclient.toBytes
import com.ricoh360.thetableclient.toShort
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.launch
import kotlinx.coroutines.withTimeout
Expand Down Expand Up @@ -82,6 +86,126 @@ class ShootingControlCommand internal constructor(thetaDevice: ThetaBle.ThetaDev
}
}

/**
* Acquires the recording size (pixels) of the camera.
*
* Service: 1D0F3602-8DFB-4340-9045-513040DAD991
* Characteristic: E8F0EDD1-6C0F-494A-95C3-3244AE0B9A01
*
* @return File format.[FileFormat]
* @exception ThetaBleApiException If an error occurs in library.
* @exception BluetoothException If an error occurs in bluetooth.
*/
@Throws(Throwable::class)
suspend fun getFileFormat(): FileFormat {
val peripheral =
thetaDevice.peripheral ?: throw ThetaBleApiException(
ERROR_MESSAGE_NOT_CONNECTED
)
try {
val data = peripheral.read(BleCharacteristic.FILE_FORMAT)
if (data.isEmpty()) {
throw ThetaBleApiException(ERROR_MESSAGE_EMPTY_DATA)
}
return FileFormat.getFromBle(data[0])
?: throw ThetaBleApiException("$ERROR_MESSAGE_UNKNOWN_VALUE ${data[0]}")
} catch (e: ThetaBleApiException) {
throw e
} catch (e: Throwable) {
throw BluetoothException(e)
}
}

/**
* Set the recording size (pixels) of the camera.
*
* Service: 1D0F3602-8DFB-4340-9045-513040DAD991
* Characteristic: E8F0EDD1-6C0F-494A-95C3-3244AE0B9A01
*
* @param value File format.[FileFormat]
* @exception ThetaBleApiException If an error occurs in library.
* @exception BluetoothException If an error occurs in bluetooth.
*/
@Throws(Throwable::class)
suspend fun setFileFormat(value: FileFormat) {
val peripheral =
thetaDevice.peripheral ?: throw ThetaBleApiException(
ERROR_MESSAGE_NOT_CONNECTED
)

if (value == FileFormat.RESERVED) {
throw ThetaBleApiException(ERROR_MESSAGE_RESERVED_VALUE)
}
value.ble ?: throw ThetaBleApiException(
ERROR_MESSAGE_UNKNOWN_VALUE
)

try {
val data = value.ble.toBytes()
peripheral.write(BleCharacteristic.FILE_FORMAT, data)
} catch (e: Throwable) {
throw BluetoothException(e)
}
}

/**
* Acquires the maximum recordable time (in seconds) of the camera.
*
* Service: 1D0F3602-8DFB-4340-9045-513040DAD991
* Characteristic: 6EABAB73-7F2B-4061-BE7C-1D71D143CB7D
*
* @return Maximum recordable time.[MaxRecordableTime]
* @exception ThetaBleApiException If an error occurs in library.
* @exception BluetoothException If an error occurs in bluetooth.
*/
@Throws(Throwable::class)
suspend fun getMaxRecordableTime(): MaxRecordableTime {
val peripheral =
thetaDevice.peripheral ?: throw ThetaBleApiException(
ERROR_MESSAGE_NOT_CONNECTED
)
try {
val data = peripheral.read(BleCharacteristic.MAX_RECORDABLE_TIME)
if (data.isEmpty()) {
throw ThetaBleApiException(ERROR_MESSAGE_EMPTY_DATA)
}
val shortValue = data.toShort()
return MaxRecordableTime.getFromBle(shortValue)
?: throw ThetaBleApiException("$ERROR_MESSAGE_UNKNOWN_VALUE $shortValue")
} catch (e: ThetaBleApiException) {
throw e
} catch (e: Throwable) {
throw BluetoothException(e)
}
}

/**
* Set the maximum recordable time (in seconds) of the camera.
*
* Service: 1D0F3602-8DFB-4340-9045-513040DAD991
* Characteristic: 6EABAB73-7F2B-4061-BE7C-1D71D143CB7D
*
* @param value Maximum recordable time.[MaxRecordableTime]
* @exception ThetaBleApiException If an error occurs in library.
* @exception BluetoothException If an error occurs in bluetooth.
*/
@Throws(Throwable::class)
suspend fun setMaxRecordableTime(value: MaxRecordableTime) {
val peripheral =
thetaDevice.peripheral ?: throw ThetaBleApiException(
ERROR_MESSAGE_NOT_CONNECTED
)
value.ble ?: throw ThetaBleApiException(
ERROR_MESSAGE_UNKNOWN_VALUE
)
try {
val data = value.ble.toBytes()
peripheral.write(BleCharacteristic.MAX_RECORDABLE_TIME, data)
} catch (e: Throwable) {
throw BluetoothException(e)
}
}

/**
* Instructs the camera to start shooting a still image. Also, acquires the shooting status.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ enum class CameraPower(internal val ble: Byte?) {
/**
* Search by bluetooth value.
*
* @param ble Return value of bluetooth api.
* @param bleData Return value of bluetooth api.
* @return CameraPower
*/
internal fun getFromBle(ble: Byte): CameraPower? {
return CameraPower.values().firstOrNull { it.ble == ble }
internal fun getFromBle(bleData: Byte): CameraPower? {
return entries.firstOrNull { it.ble == bleData }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ enum class CaptureMode(internal val ble: Byte?) {
/**
* Search by bluetooth value.
*
* @param ble Return value of bluetooth api.
* @param bleData Return value of bluetooth api.
* @return CaptureMode
*/
internal fun getFromBle(ble: Byte): CaptureMode? {
return values().firstOrNull { it.ble == ble }
internal fun getFromBle(bleData: Byte): CaptureMode? {
return entries.firstOrNull { it.ble == bleData }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ enum class ChargingState(internal val ble: Byte?) : SerialNameEnum {
/**
* Search by bluetooth value.
*
* @param ble Return value of bluetooth api.
* @param bleData Return value of bluetooth api.
* @return ChargingState
*/
internal fun getFromBle(ble: Byte): ChargingState? {
return ChargingState.values().firstOrNull { it.ble == ble }
internal fun getFromBle(bleData: Byte): ChargingState? {
return entries.firstOrNull { it.ble == bleData }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ enum class CommandErrorDescription(internal val ble: Byte?) {
/**
* Search by bluetooth value.
*
* @param ble Return value of bluetooth api.
* @param bleData Return value of bluetooth api.
* @return CommandErrorDescription
*/
internal fun getFromBle(ble: Byte): CommandErrorDescription? {
return CommandErrorDescription.values().firstOrNull { it.ble == ble }
internal fun getFromBle(bleData: Byte): CommandErrorDescription? {
return entries.firstOrNull { it.ble == bleData }
}
}
}
Loading

0 comments on commit f149f71

Please sign in to comment.