Skip to content

Commit 80c0cf1

Browse files
committed
add PhoneControl packets
1 parent c829d17 commit 80c0cf1

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package io.rebble.libpebblecommon.packets
2+
3+
import io.rebble.libpebblecommon.protocolhelpers.PacketRegistry
4+
import io.rebble.libpebblecommon.protocolhelpers.PebblePacket
5+
import io.rebble.libpebblecommon.protocolhelpers.ProtocolEndpoint
6+
import io.rebble.libpebblecommon.structmapper.*
7+
8+
9+
sealed class PhoneControl(message: Message, cookie: UInt) : PebblePacket(endpoint) {
10+
enum class Message(val value: UByte) {
11+
Unknown(0u),
12+
Answer(0x01u),
13+
Hangup(0x02u),
14+
GetState(0x03u),
15+
IncomingCall(0x04u),
16+
OutgoingCall(0x05u),
17+
MissedCall(0x06u),
18+
Ring(0x07u),
19+
Start(0x08u),
20+
End(0x09u)
21+
}
22+
companion object {
23+
val endpoint = ProtocolEndpoint.PHONE_CONTROL
24+
}
25+
26+
val command = SUByte(m, message.value)
27+
val cookie = SUInt(m, cookie)
28+
29+
class IncomingCall(cookie: UInt = 0u, callerNumber: String = "", callerName: String = "") : PhoneControl(Message.IncomingCall, cookie) {
30+
val callerNumber = SString(m, callerNumber)
31+
val callerName = SString(m, callerName)
32+
}
33+
class MissedCall(cookie: UInt = 0u, callerNumber: String = "", callerName: String = "") : PhoneControl(Message.MissedCall, cookie) {
34+
val callerNumber = SString(m, callerNumber)
35+
val callerName = SString(m, callerName)
36+
}
37+
class Ring(cookie: UInt = 0u) : PhoneControl(Message.Ring, cookie)
38+
class Start(cookie: UInt = 0u) : PhoneControl(Message.Start, cookie)
39+
class End(cookie: UInt = 0u) : PhoneControl(Message.End, cookie)
40+
41+
class Answer(cookie: UInt = 0u) : PhoneControl(Message.Answer, cookie)
42+
class Hangup(cookie: UInt = 0u) : PhoneControl(Message.Hangup, cookie)
43+
}
44+
45+
fun phoneControlPacketsRegister() {
46+
PacketRegistry.register(
47+
PhoneControl.endpoint,
48+
PhoneControl.Message.Answer.value,
49+
) { PhoneControl.Answer() }
50+
PacketRegistry.register(
51+
PhoneControl.endpoint,
52+
PhoneControl.Message.Hangup.value,
53+
) { PhoneControl.Hangup() }
54+
}

src/commonMain/kotlin/io/rebble/libpebblecommon/protocolhelpers/PacketRegistry.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ object PacketRegistry {
2828
appReorderIncomingRegister()
2929
screenshotPacketsRegister()
3030
appLogPacketsRegister()
31+
phoneControlPacketsRegister()
3132
}
3233

3334
/**

0 commit comments

Comments
 (0)