TakPacketV2Serializer

Serializes/deserializes TakPacketV2Data to/from protobuf wire format using Wire-generated Kotlin classes (com.squareup.wire).

Forward-compatibility contract

Any enum field (CotType, CotHow, Team, MemberRole, GeoPointSource) that carries a value outside the enum's known range is mapped to the "unspecified" sentinel for that enum: CotType.CotType_Other, CotHow.CotHow_Unspecified, Team.Unspecifed_Color, MemberRole.Unspecifed, GeoPointSource.GeoPointSource_Unspecified.

This is by design so that a v2 receiver can decode packets produced by a v2.1 sender that added a new enum value — the receiver loses the new semantic label but the rest of the packet still round-trips. For CotType specifically, the full type string is preserved in cot_type_str (field

  1. whenever the enum can't represent it, so the reconstructed CoT XML carries the correct type="..." attribute even when the enum downgrades.

Callers that need to detect the downgrade — e.g. to surface a "newer peer detected" warning — should check cot_type_id == CotType_Other && cot_type_str.isNotEmpty() on the deserialized packet.

Wire vs protobuf-lite

The SDK previously used protobuf-lite Java codegen with builder chains (TAKPacketV2.newBuilder().setX(...).build()) and .hasXxx() / .getXxxValue() accessors. Wire generates immutable Kotlin data classes with snake_case field names and an .ADAPTER for encode/decode. Oneof fields are flattened to nullable properties (boxOneOfsMinSize = 5000 in build.gradle.kts), so proto.chat != null replaces the old proto.hasChat() check. The public API of this class — serialize(data) / deserialize(bytes) — is unchanged.

Functions

Link copied to clipboard

Decode TAKPacketV2 protobuf wire bytes into a TakPacketV2Data.

Link copied to clipboard

Encode a TakPacketV2Data to TAKPacketV2 protobuf wire bytes.