Skip to content

Commit ec9d101

Browse files
authored
Merge pull request #6 from matejdro/appmessage
Add AppMessage packets
2 parents 3b0a337 + e8a4f65 commit ec9d101

File tree

32 files changed

+1388
-276
lines changed

32 files changed

+1388
-276
lines changed

src/androidMain/kotlin/main.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
package io.rebble.libpebblecommon
22

3-
@ExperimentalUnsignedTypes
3+
import io.rebble.libpebblecommon.packets.PhoneAppVersion
4+
5+
@OptIn(ExperimentalUnsignedTypes::class)
46
actual fun getPlatform(): PhoneAppVersion.OSType = PhoneAppVersion.OSType.Android

src/androidMain/kotlin/util/DataBuffer.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package io.rebble.libpebblecommon.util
33
import java.nio.ByteBuffer
44
import java.nio.ByteOrder
55

6-
@ExperimentalUnsignedTypes
6+
@OptIn(ExperimentalUnsignedTypes::class)
77
actual class DataBuffer {
88
private val actualBuf: ByteBuffer
99

@@ -24,10 +24,15 @@ actual class DataBuffer {
2424
}
2525
actual fun getShort(): Short = actualBuf.short
2626

27-
actual fun putByte(byte: UByte) {
27+
actual fun putUByte(byte: UByte) {
2828
actualBuf.put(byte.toByte())
2929
}
30-
actual fun getByte(): UByte = actualBuf.get().toUByte()
30+
actual fun getUByte(): UByte = actualBuf.get().toUByte()
31+
32+
actual fun putByte(byte: Byte) {
33+
actualBuf.put(byte)
34+
}
35+
actual fun getByte(): Byte = actualBuf.get()
3136

3237
actual fun putBytes(bytes: UByteArray) {
3338
actualBuf.put(bytes.toByteArray())
@@ -47,6 +52,11 @@ actual class DataBuffer {
4752
}
4853
}
4954

55+
actual fun putInt(int: Int) {
56+
actualBuf.putInt(int)
57+
}
58+
actual fun getInt(): Int = actualBuf.int
59+
5060
actual fun putUInt(uint: UInt) {
5161
actualBuf.putInt(uint.toInt())
5262
}

src/commonMain/kotlin/io/rebble/libpebblecommon/ProtocolHandlerImpl.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package io.rebble.libpebblecommon
22

3+
import io.rebble.libpebblecommon.packets.PhoneAppVersion
34
import io.rebble.libpebblecommon.exceptions.PacketDecodeException
45
import io.rebble.libpebblecommon.protocolhelpers.PacketRegistry
56
import io.rebble.libpebblecommon.protocolhelpers.PebblePacket
67
import io.rebble.libpebblecommon.protocolhelpers.ProtocolEndpoint
7-
import io.rebble.libpebblecommon.PhoneAppVersion.ProtocolCapsFlag
8+
import io.rebble.libpebblecommon.packets.PhoneAppVersion.ProtocolCapsFlag
9+
import io.rebble.libpebblecommon.packets.PingPong
810
import kotlinx.coroutines.sync.Mutex
911
import kotlinx.coroutines.sync.withLock
1012

@@ -19,8 +21,6 @@ class ProtocolHandlerImpl(private val bluetoothConnection: BluetoothConnection)
1921
private val protocolMutex = Mutex()
2022

2123
init {
22-
PacketRegistry.setup()
23-
2424
bluetoothConnection.setReceiveCallback(this::handle)
2525
}
2626

src/commonMain/kotlin/io/rebble/libpebblecommon/blobdb/Timeline.kt

Lines changed: 0 additions & 129 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
package io.rebble.libpebblecommon
22

3+
import io.rebble.libpebblecommon.packets.PhoneAppVersion
4+
35
@OptIn(ExperimentalUnsignedTypes::class)
46
expect fun getPlatform(): PhoneAppVersion.OSType

0 commit comments

Comments
 (0)