Skip to content

Commit 932064d

Browse files
committed
Move AppVersionRequest handling to a callback
1 parent 5a4cc6e commit 932064d

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

src/commonMain/kotlin/io/rebble/libpebblecommon/services/SystemService.kt

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import kotlinx.coroutines.channels.Channel
1717
*/
1818
class SystemService(private val protocolHandler: ProtocolHandler) : ProtocolService {
1919
val receivedMessages = Channel<SystemPacket>(Channel.BUFFERED)
20+
public final var appVersionRequestHandler: (suspend () -> PhoneAppVersion.AppVersionResponse)? = null
2021

2122
private var watchVersionCallback: CompletableDeferred<WatchVersion.WatchVersionResponse>? = null
2223
private var watchModelCallback: CompletableDeferred<UByteArray>? = null
@@ -72,28 +73,8 @@ class SystemService(private val protocolHandler: ProtocolHandler) : ProtocolServ
7273
watchModelCallback?.completeExceptionally(Exception("Failed to fetch watch model"))
7374
watchModelCallback = null
7475
}
75-
is PhoneAppVersion -> {
76-
val responsePacket = PhoneAppVersion.AppVersionResponse(
77-
UInt.MAX_VALUE,
78-
79-
0u,
80-
PhoneAppVersion.PlatformFlag.makeFlags(
81-
getPlatform(), emptyList()
82-
),
83-
2u,
84-
4u,
85-
4u,
86-
2u,
87-
ProtocolCapsFlag.makeFlags(
88-
listOf(
89-
ProtocolCapsFlag.Supports8kAppMessage,
90-
ProtocolCapsFlag.SupportsExtendedMusicProtocol
91-
)
92-
)
93-
94-
)
95-
96-
protocolHandler.send(responsePacket)
76+
is PhoneAppVersion.AppVersionRequest -> {
77+
appVersionRequestHandler?.invoke()
9778
}
9879
else -> receivedMessages.offer(packet)
9980
}

0 commit comments

Comments
 (0)