Garmin BLOB Serialization¶
This describes the binary wire layout for serializing and deserializing structured data values. It is, for example, used for persisting Connect IQ app settings and to serialize HTTP communication.
Frame Architecture and Endianness¶
All multibyte numeric primitives, lengths, offsets, and floating-point values are encoded in standard network byte order (big-endian).
A complete transmission payload consists of an optional String Block followed by a mandatory Data Block.
+-------------------------------------------------------+
| Optional String Block |
| - 4 bytes: Sentinel Header (-1412584499 / 0xABCDABCD)|
| - 4 bytes: Payload Length (Ls) |
| - Ls bytes: String Table Entries |
+-------------------------------------------------------+
| Mandatory Data Block |
| - 4 bytes: Sentinel Header (-629482886 / 0xDA7ADA7A) |
| - 4 bytes: Payload Length (Ld) |
| - Ld bytes: Tagged Data Records |
+-------------------------------------------------------+
Section Headers¶
String Block Header(8 bytes, omitted if no strings exist):Sentinel: 32-bit signed integer constant-1412584499(0xABCDABCD).Length: 32-bit signed integer specifying the total byte length of the string table payload excluding this 8-byte header.Data Block Header(8 bytes, always present):Sentinel: 32-bit signed integer constant-629482886(0xDA7ADA7A).Length: 32-bit signed integer specifying the total byte length of the data records payload excluding this 8-byte header.
String Table Encoding
String instances are pooled and deduplicated within the String Block. Equal strings share one entry.
Strings are registered by a depth-first walk of the object graph before data records are emitted. String-table order is therefore not the breadth-first order of the data stream. A decoder must not assume the two orders match.
The string block is omitted when its payload would be empty.
Each entry in the string table payload is serialized as:
+-------------------+-----------------------------+------+
| Length (2 bytes) | UTF-8 Encoded Bytes (N - 1) | 0x00 |
+-------------------+-----------------------------+------+
Length: 16-bit signed integer indicating the total byte count of the string payload including the trailing null byte (N).Nmust fit in a signed short, soN <= 32767. Block lengths (Ls,Ld) are likewise signed 32-bit integers.Content:N - 1bytes containing validUTF-8encoded character data.Null Terminator: Single byte0x00.
Within data records, a string value is referenced via a 32-bit signed integer offset pointing directly to the beginning of the target entry's 2-byte length field relative to byte 0 of the string table payload (not the sentinel). A well-formed entry is at least 3 bytes (2-byte length plus 0x00), so a start offset of Ls - 2 can hold a length field but not a complete entry.
Data Record Formats
Every data item begins with a 1-byte type tag identifying its schema and size.
| Type Tag | Name | Payload Structure | Total Wire Size |
|---|---|---|---|
0x00 (0)
| Null
| None | 1 byte
|
0x01 (1)
| Integer
| 32-bit signed two's-complement integer | 5 bytes
|
0x02 (2)
| Float
| 32-bit IEEE-754 single-precision float | 5 bytes
|
0x03 (3)
| String Reference
| 32-bit signed integer byte offset into String Block | 5 bytes
|
0x05 (5)
| Array
| 32-bit signed integer element count N (children follow in payload stream)
| 5 bytes header + children
|
0x09 (9)
| Boolean
| 1 byte (serialized: 0x00 = false, 0x01 = true; deserialized as signed: values greater than 0 = true, otherwise false)
| 2 bytes
|
0x0B (11)
| Dictionary / Map
| 32-bit signed integer pair count N (key/value pairs follow in payload stream)
| 5 bytes header + children
|
0x0E (14)
| Long Integer
| 64-bit signed two's-complement integer | 9 bytes
|
0x0F (15)
| Double
| 64-bit IEEE-754 double-precision float | 9 bytes
|
0x13 (19)
| Character
| 32-bit signed integer (see Character semantics below) | 5 bytes
|
0x14 (20)
| Byte Array
| 32-bit signed integer count B followed by B raw binary bytes
| 5 + B bytes
|
Although the tag is named Character, its payload is a 32-bit signed integer. Deserialization does not validate the value as a Unicode scalar.
Encoder Type Mapping
- A
Longin[-2147483648, 2147483647]is emitted as an integer (0x01), not a long (0x0E). - A
Doubleis emitted as a float (0x02) whenabs(float(d) - d) < 1.0E-5; otherwise it is a double (0x0F). - A non-empty
Listwhose elements are allByteis a byte array (0x14), not an array (0x05). An empty list is an array. Abyte[]is a byte array.
Object Graph Serialization & Breadth-First Order
Arrays preserve element order. Dictionaries do not. Serialization output is deterministic for arrays and is not deterministic for maps.
- Flat / Primitive Types: Serialized immediately as
[Tag][Value]. - Container Serialization (
Array,Dictionary / Map): - The container descriptor (
[Tag][Count]) is written to the record stream. Byte-array payloads are inline (countplus raw bytes), not a breadth-first child sequence. - For arrays and dictionaries, child elements are not stored inline inside a nested bounding container; instead, they are scheduled in a queue and emitted using breadth-first traversal.
- Reconstruction Semantics:
- A decoder reads the root record descriptor.
- If the record is an
Arraywith countN, the decoder consumes the subsequentNsequential records from the queue/stream as its elements. - If the record is a
Dictionary / Mapwith pair countN, the decoder consumes the subsequent2Nsequential records as alternatingkeyandvaluepairs. - Any nested container encountered during consumption is placed into a secondary queue to resolve its respective child elements from the remaining stream in breadth-first sequence.
Parsing and Validation Rules
- Header Verification: The string-block sentinel (
0xABCDABCD) is checked when a string block is present. The data-block sentinel (0xDA7ADA7Aexpected) is checked. If the following length field fits the buffer is checked. - Bounds Enforcement: A declared block that runs past the buffer raises an exception. Trailing bytes beyond
8 + Ls + 8 + Ld(or8 + Ldif the string block is absent) are left unread. They are ignored, not rejected. - String Resolution: Offsets are bounds-checked against
[0, Ls). An offset is resolved only if it is the start of a recorded string-table entry. Any other offset, including one outside the payload, resolves to null.