-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pbz reading, fw update messages, putbytes sendfwpart
- Loading branch information
Showing
9 changed files
with
174 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
kotlin.code.style=official | ||
|
||
group=io.rebble.libpebblecommon | ||
version=0.1.8 | ||
version=0.1.9 | ||
org.gradle.jvmargs=-Xms128M -Xmx1G -XX:ReservedCodeCacheSize=200M | ||
kotlin.native.binary.memoryModel=experimental | ||
kotlin.mpp.androidSourceSetLayoutVersion=2 |
79 changes: 55 additions & 24 deletions
79
src/commonMain/kotlin/io/rebble/libpebblecommon/metadata/WatchHardwarePlatform.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,64 @@ | ||
package io.rebble.libpebblecommon.metadata | ||
|
||
enum class WatchHardwarePlatform(val protocolNumber: UByte, val watchType: WatchType) { | ||
PEBBLE_ONE_EV_1(1u, WatchType.APLITE), | ||
PEBBLE_ONE_EV_2(2u, WatchType.APLITE), | ||
PEBBLE_ONE_EV_2_3(3u, WatchType.APLITE), | ||
PEBBLE_ONE_EV_2_4(4u, WatchType.APLITE), | ||
PEBBLE_ONE_POINT_FIVE(5u, WatchType.APLITE), | ||
PEBBLE_ONE_POINT_ZERO(6u, WatchType.APLITE), | ||
PEBBLE_SNOWY_EVT_2(7u, WatchType.BASALT), | ||
PEBBLE_SNOWY_DVT(8u, WatchType.BASALT), | ||
PEBBLE_BOBBY_SMILES(10u, WatchType.BASALT), | ||
PEBBLE_ONE_BIGBOARD_2(254u, WatchType.APLITE), | ||
PEBBLE_ONE_BIGBOARD(255u, WatchType.APLITE), | ||
PEBBLE_SNOWY_BIGBOARD(253u, WatchType.BASALT), | ||
PEBBLE_SNOWY_BIGBOARD_2(252u, WatchType.BASALT), | ||
PEBBLE_SPALDING_EVT(9u, WatchType.CHALK), | ||
PEBBLE_SPALDING_PVT(11u, WatchType.CHALK), | ||
PEBBLE_SPALDING_BIGBOARD(251u, WatchType.CHALK), | ||
PEBBLE_SILK_EVT(12u, WatchType.DIORITE), | ||
PEBBLE_SILK(14u, WatchType.DIORITE), | ||
PEBBLE_SILK_BIGBOARD(250u, WatchType.DIORITE), | ||
PEBBLE_SILK_BIGBOARD_2_PLUS(248u, WatchType.DIORITE), | ||
PEBBLE_ROBERT_EVT(13u, WatchType.EMERY), | ||
PEBBLE_ROBERT_BIGBOARD(249u, WatchType.EMERY), | ||
PEBBLE_ROBERT_BIGBOARD_2(247u, WatchType.EMERY); | ||
import kotlinx.serialization.SerializationException | ||
import kotlinx.serialization.Serializer | ||
import kotlinx.serialization.descriptors.PrimitiveKind | ||
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor | ||
import kotlinx.serialization.descriptors.SerialDescriptor | ||
import kotlinx.serialization.encoding.Decoder | ||
import kotlinx.serialization.encoding.Encoder | ||
import kotlin.reflect.KClass | ||
|
||
enum class WatchHardwarePlatform(val protocolNumber: UByte, val watchType: WatchType, val revision: String) { | ||
PEBBLE_ONE_EV_1(1u, WatchType.APLITE, "ev1"), | ||
PEBBLE_ONE_EV_2(2u, WatchType.APLITE, "ev2"), | ||
PEBBLE_ONE_EV_2_3(3u, WatchType.APLITE, "ev2_3"), | ||
PEBBLE_ONE_EV_2_4(4u, WatchType.APLITE, "ev2_4"), | ||
PEBBLE_ONE_POINT_FIVE(5u, WatchType.APLITE, "v1_5"), | ||
PEBBLE_ONE_POINT_ZERO(6u, WatchType.APLITE, "v1_0"), | ||
PEBBLE_SNOWY_EVT_2(7u, WatchType.BASALT, "snowy_evt2"), | ||
PEBBLE_SNOWY_DVT(8u, WatchType.BASALT, "snowy_dvt"), | ||
PEBBLE_BOBBY_SMILES(10u, WatchType.BASALT, "snowy_s3"), | ||
PEBBLE_ONE_BIGBOARD_2(254u, WatchType.APLITE, "unk"), | ||
PEBBLE_ONE_BIGBOARD(255u, WatchType.APLITE, "unk"), | ||
PEBBLE_SNOWY_BIGBOARD(253u, WatchType.BASALT, "unk"), | ||
PEBBLE_SNOWY_BIGBOARD_2(252u, WatchType.BASALT, "unk"), | ||
PEBBLE_SPALDING_EVT(9u, WatchType.CHALK, "spalding_evt"), | ||
PEBBLE_SPALDING_PVT(11u, WatchType.CHALK, "spalding"), | ||
PEBBLE_SPALDING_BIGBOARD(251u, WatchType.CHALK, "unk"), | ||
PEBBLE_SILK_EVT(12u, WatchType.DIORITE, "silk_evt"), | ||
PEBBLE_SILK(14u, WatchType.DIORITE, "silk"), | ||
PEBBLE_SILK_BIGBOARD(250u, WatchType.DIORITE, "unk"), | ||
PEBBLE_SILK_BIGBOARD_2_PLUS(248u, WatchType.DIORITE, "unk"), | ||
PEBBLE_ROBERT_EVT(13u, WatchType.EMERY, "robert_evt"), | ||
PEBBLE_ROBERT_BIGBOARD(249u, WatchType.EMERY, "unk"), | ||
PEBBLE_ROBERT_BIGBOARD_2(247u, WatchType.EMERY, "unk"); | ||
|
||
companion object { | ||
fun fromProtocolNumber(number: UByte): WatchHardwarePlatform? { | ||
return values().firstOrNull { it.protocolNumber == number } | ||
} | ||
|
||
fun fromHWRevision(revision: String): WatchHardwarePlatform? { | ||
if (revision == "unk") return null | ||
return values().firstOrNull() { it.revision == revision } | ||
} | ||
} | ||
} | ||
|
||
@Serializer(WatchHardwarePlatform::class) | ||
class WatchHardwarePlatformSerializer { | ||
override val descriptor: SerialDescriptor | ||
get() = PrimitiveSerialDescriptor("WatchHardwarePlatform", PrimitiveKind.STRING) | ||
|
||
override fun deserialize(decoder: Decoder): WatchHardwarePlatform { | ||
val revision = decoder.decodeString() | ||
return WatchHardwarePlatform.fromHWRevision(revision) ?: throw SerializationException("Unknown hardware revision $revision") | ||
} | ||
|
||
override fun serialize(encoder: Encoder, value: WatchHardwarePlatform) { | ||
val revision = value.revision | ||
encoder.encodeString(revision) | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
src/commonMain/kotlin/io/rebble/libpebblecommon/metadata/pbz/manifest/JsTooling.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.rebble.libpebblecommon.metadata.pbz.manifest | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class JsTooling( | ||
@SerialName("bytecode_version") | ||
val bytecodeVersion: Int | ||
) |
20 changes: 20 additions & 0 deletions
20
src/commonMain/kotlin/io/rebble/libpebblecommon/metadata/pbz/manifest/PbzFirmware.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.rebble.libpebblecommon.metadata.pbz.manifest | ||
|
||
import io.rebble.libpebblecommon.metadata.WatchHardwarePlatform | ||
import io.rebble.libpebblecommon.metadata.WatchHardwarePlatformSerializer | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class PbzFirmware( | ||
val name: String, | ||
val type: String, | ||
val timestamp: Long, | ||
val commit: String, | ||
@Serializable(with = WatchHardwarePlatformSerializer::class) | ||
@SerialName("hwrev") | ||
val hwRev: WatchHardwarePlatform, | ||
val size: Long, | ||
val crc: Long, | ||
val versionTag: String | ||
) |
18 changes: 18 additions & 0 deletions
18
src/commonMain/kotlin/io/rebble/libpebblecommon/metadata/pbz/manifest/PbzManifest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.rebble.libpebblecommon.metadata.pbz.manifest | ||
|
||
import io.rebble.libpebblecommon.metadata.pbw.manifest.Debug | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class PbzManifest( | ||
val manifestVersion: Int, | ||
val generatedAt: Long, | ||
val generatedBy: String, | ||
val debug: Debug, | ||
val firmware: PbzFirmware, | ||
val resources: SystemResources, | ||
@SerialName("js_tooling") | ||
val jsTooling: JsTooling, | ||
val type: String | ||
) |
11 changes: 11 additions & 0 deletions
11
src/commonMain/kotlin/io/rebble/libpebblecommon/metadata/pbz/manifest/SystemResources.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.rebble.libpebblecommon.metadata.pbz.manifest | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class SystemResources( | ||
val name: String, | ||
val timestamp: Long, | ||
val size: Long, | ||
val crc: Long | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters