Skip to content

Commit 43d8d47

Browse files
Merge branch 'develop'
2 parents b101150 + 68f4733 commit 43d8d47

File tree

8 files changed

+70
-41
lines changed

8 files changed

+70
-41
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,22 @@ class ExampleViewModel: ViewModel() {
9999
> the suspending API usage within viewModelScope.launch is identical across all Kotlin Multiplatform
100100
> targets._
101101
102+
### V1 Capabilities
103+
To determine capabilities/features of the attached Valentine One, developers can use the
104+
`IESPClient.v1CapabilityInfo` state flow which contains the most recently "calculated"
105+
`V1CapabilityInfo`. This class is made up of `Boolean` flags that are set based on firmware version
106+
of a Valentine One. **KESPL** automatically requests & caches (`StateFlow`) the V1 firmware on
107+
connect.
108+
109+
The following example can be used to determine if the attached Valentine One is a "Gen2":
110+
```Kotlin
111+
espClient
112+
.v1CapabilityInfo
113+
.map { it.isGen2 }
114+
```
115+
"Collecting" from this flow is the recommended way for conditionally enabling/disabling app
116+
features/UI.
117+
102118
### 📦 ESPPacket
103119
All communication on the ESP bus is achieved through
104120
[ESPPacket](library/src/commonMain/kotlin/com/esp/library/packet/ESPPacket.kt). `ESPPacket` is a
@@ -272,6 +288,11 @@ that doesn't timeout. This is ideal for background re/connections.
272288
**KESPL** is based on **v.3.015** of the ESP Specification which can be found on the official Github
273289
repo for [AndroidESPLibrary2](https://github.com/ValentineResearch/AndroidESPLibrary2/tree/master/Specification).
274290

291+
## Stability
292+
The library is currently in beta but the API shape is considered **stable**. I hope for the library
293+
to reach **v.1.0.0** before the end of 2025. Developers are encouraged to play with the library and
294+
provide feedback on ease-of-use and correct behavior.
295+
275296
## ⚖️ License
276297

277298
KESPL is distributed under the **MIT License**. See [LICENSE](LICENSE) for more information.

composeApp/src/commonMain/kotlin/io/github/developrofthings/helloV1/service/IESPService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ interface IESPService {
9999
suspend fun requestWriteV1Volume(
100100
main: Int,
101101
mute: Int,
102-
provideUserFeedBack: Boolean,
102+
provideUserFeedback: Boolean,
103103
skipFeedBackWhenNoChange: Boolean,
104104
saveVolume: Boolean,
105105
): ESPResponse<Unit, ESPFailure>

composeApp/src/commonMain/kotlin/io/github/developrofthings/helloV1/ui/dialog/sweep/SweepInfoPresenter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.github.developrofthings.helloV1.ui.dialog.sweep
22

33
import io.github.developrofthings.helloV1.data.repository.ESPDataLogRepository
4-
import io.github.developrofthings.helloV1.service.ESPService
4+
import io.github.developrofthings.helloV1.service.IESPService
55
import io.github.developrofthings.helloV1.ui.component.SweepDefinitionsColumnState
66
import io.github.developrofthings.helloV1.ui.component.SweepSectionColumnState
77
import io.github.developrofthings.kespl.ESPPacketId
@@ -37,7 +37,7 @@ import kotlin.experimental.or
3737
@Factory
3838
class SweepInfoPresenter(
3939
private val scope: CoroutineScope,
40-
private val espService: ESPService,
40+
private val espService: IESPService,
4141
private val espDataLogRepository: ESPDataLogRepository,
4242
) {
4343
private val sweepSections = MutableStateFlow<List<SweepSection>>(emptyList())

composeApp/src/commonMain/kotlin/io/github/developrofthings/helloV1/ui/dialog/user/UserBytesGuiPresenter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.github.developrofthings.helloV1.ui.dialog.user
22

33
import io.github.developrofthings.helloV1.data.repository.ESPDataLogRepository
4-
import io.github.developrofthings.helloV1.service.ESPService
4+
import io.github.developrofthings.helloV1.service.IESPService
55
import io.github.developrofthings.kespl.ESPDevice
66
import io.github.developrofthings.kespl.ESPResponse
77
import io.github.developrofthings.kespl.packet.data.user.defaultUserBytes
@@ -18,7 +18,7 @@ class UserBytesGuiPresenter(
1818
userBytes: ByteArray,
1919
val targetDevice: ESPDevice,
2020
private val scope: CoroutineScope,
21-
private val espService: ESPService,
21+
private val espService: IESPService,
2222
private val espDataLogRepository: ESPDataLogRepository,
2323
) {
2424
private val _userBytes = espService

composeApp/src/commonMain/kotlin/io/github/developrofthings/helloV1/ui/dialog/volume/VolumePresenter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package io.github.developrofthings.helloV1.ui.dialog.volume
22

33
import io.github.developrofthings.helloV1.combine
44
import io.github.developrofthings.helloV1.data.repository.ESPDataLogRepository
5-
import io.github.developrofthings.helloV1.service.ESPService
5+
import io.github.developrofthings.helloV1.service.IESPService
66
import io.github.developrofthings.kespl.V1CapabilityInfo
77
import io.github.developrofthings.kespl.onFailure
88
import io.github.developrofthings.kespl.packet.data.V1Volume
@@ -23,7 +23,7 @@ import kotlinx.coroutines.launch
2323

2424
class VolumePresenter(
2525
private val scope: CoroutineScope,
26-
private val espService: ESPService,
26+
private val espService: IESPService,
2727
private val espDataLogRepository: ESPDataLogRepository,
2828
) {
2929

library/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ mavenPublishing {
147147

148148
signAllPublications()
149149

150-
coordinates("io.github.developrofthings", "kespl", "0.9.0")
150+
coordinates("io.github.developrofthings", "kespl", "0.9.1")
151151

152152
pom {
153153
name = "KESPL"

library/src/commonMain/kotlin/io/github/developrofthings/kespl/ESPClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ internal class ESPClient(
9797

9898
override val v1CapabilityInfo: StateFlow<V1CapabilityInfo> = flowController
9999
.v1Version
100-
.map(::determineCapabilities)
100+
.map(::V1CapabilityInfo)
101101
.stateIn(
102102
scope = scope,
103103
initialValue = V1CapabilityInfo.DEFAULT,
Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package io.github.developrofthings.kespl
22

3+
import io.github.developrofthings.kespl.packet.data.Version
4+
import io.github.developrofthings.kespl.packet.data.asDouble
35
import io.github.developrofthings.kespl.utilities.V1_GEN2_AUTO_MUTE_SETTING_VERSION
46
import io.github.developrofthings.kespl.utilities.V1_GEN2_PHOTO_RADAR_VERSION
57
import io.github.developrofthings.kespl.utilities.V1_GEN_2_PLATFORM_BASELINE_VERSION
68

7-
data class V1CapabilityInfo(
9+
@ConsistentCopyVisibility
10+
data class V1CapabilityInfo private constructor(
811
val supportsDefaultSweepRequest: Boolean,
912
val supportsReqDefaultSweepDefinitions: Boolean,
1013
// 4.1018
@@ -38,37 +41,42 @@ data class V1CapabilityInfo(
3841
val supportsTemporaryVolume: Boolean,
3942
val supportsDisplayActiveBit: Boolean,
4043
val supportsPhotoRadar: Boolean,
44+
) {
45+
constructor(version: Double) : this(
46+
supportsDefaultSweepRequest = version >= 3.8920,
47+
supportsReqDefaultSweepDefinitions = version >= 3.8950,
48+
isGen2 = version >= V1_GEN_2_PLATFORM_BASELINE_VERSION,
49+
hasInfDisplayDataMuteAndBtIndicator = version >= V1_GEN_2_PLATFORM_BASELINE_VERSION,
50+
supportsKAndKaInEuroAndUsa = version >= V1_GEN_2_PLATFORM_BASELINE_VERSION,
51+
supportsVolumeControl = version >= 4.1027,
52+
supportsDoubleTap = version >= 4.1028,
53+
hasInfDisplayDataLogicMode = version >= 4.1028,
54+
hasInfDisplayDataMuteInformation = version >= 4.1028,
55+
hasInfDisplayDataVolume = version >= 4.1028,
56+
supportsFastLaserDetectionUserSetting = version >= 4.1031,
57+
supportsKaAlwaysPriorityUserSetting = version >= 4.1031,
58+
unmutingAlertsAffectsLaser = version >= 4.1031,
59+
hasAlertDataJunkBit = version >= 4.1032,
60+
supportsMainDisplayRequestAux0Byte = version >= 4.1032,
61+
supportsKaThresholdUserSetting = version >= 4.1032,
62+
supportStartupSequenceUserSetting = version >= 4.1035,
63+
supportsRestingDisplayUserSetting = version >= 4.1035,
64+
supportsAbortAudioDelay = version >= 4.1035,
65+
supportsAutoMuteUserSettings = version >= V1_GEN2_AUTO_MUTE_SETTING_VERSION,
66+
supportsDisplayVolumeRequest = version >= V1_GEN2_AUTO_MUTE_SETTING_VERSION,
67+
supportsAllVolumesRequest = version >= V1_GEN2_PHOTO_RADAR_VERSION,
68+
supportsTemporaryVolume = version >= V1_GEN2_PHOTO_RADAR_VERSION,
69+
supportsDisplayActiveBit = version >= V1_GEN2_PHOTO_RADAR_VERSION,
70+
supportsPhotoRadar = version >= V1_GEN2_PHOTO_RADAR_VERSION,
71+
)
72+
73+
constructor(version: Version) : this(
74+
version = version.takeIf {
75+
it.contains("V", ignoreCase = true) && it.length == 7
76+
}?.asDouble() ?: 0.0
77+
)
4178

42-
) {
4379
companion object {
44-
val DEFAULT: V1CapabilityInfo = determineCapabilities(0.0)
80+
val DEFAULT: V1CapabilityInfo = V1CapabilityInfo(0.0)
4581
}
46-
}
47-
48-
fun determineCapabilities(version: Double): V1CapabilityInfo = V1CapabilityInfo(
49-
supportsDefaultSweepRequest = version >= 3.8920,
50-
supportsReqDefaultSweepDefinitions = version >= 3.8950,
51-
isGen2 = version >= V1_GEN_2_PLATFORM_BASELINE_VERSION,
52-
hasInfDisplayDataMuteAndBtIndicator = version >= V1_GEN_2_PLATFORM_BASELINE_VERSION,
53-
supportsKAndKaInEuroAndUsa = version >= V1_GEN_2_PLATFORM_BASELINE_VERSION,
54-
supportsVolumeControl = version >= 4.1027,
55-
supportsDoubleTap = version >= 4.1028,
56-
hasInfDisplayDataLogicMode = version >= 4.1028,
57-
hasInfDisplayDataMuteInformation = version >= 4.1028,
58-
hasInfDisplayDataVolume = version >= 4.1028,
59-
supportsFastLaserDetectionUserSetting = version >= 4.1031,
60-
supportsKaAlwaysPriorityUserSetting = version >= 4.1031,
61-
unmutingAlertsAffectsLaser = version >= 4.1031,
62-
hasAlertDataJunkBit = version >= 4.1032,
63-
supportsMainDisplayRequestAux0Byte = version >= 4.1032,
64-
supportsKaThresholdUserSetting = version >= 4.1032,
65-
supportStartupSequenceUserSetting = version >= 4.1035,
66-
supportsRestingDisplayUserSetting = version >= 4.1035,
67-
supportsAbortAudioDelay = version >= 4.1035,
68-
supportsAutoMuteUserSettings = version >= V1_GEN2_AUTO_MUTE_SETTING_VERSION,
69-
supportsDisplayVolumeRequest = version >= V1_GEN2_AUTO_MUTE_SETTING_VERSION,
70-
supportsAllVolumesRequest = version >= V1_GEN2_PHOTO_RADAR_VERSION,
71-
supportsTemporaryVolume = version >= V1_GEN2_PHOTO_RADAR_VERSION,
72-
supportsDisplayActiveBit = version >= V1_GEN2_PHOTO_RADAR_VERSION,
73-
supportsPhotoRadar = version >= V1_GEN2_PHOTO_RADAR_VERSION,
74-
)
82+
}

0 commit comments

Comments
 (0)