# Message-Utils Here you can find all the libraries related to the message structure for transmitting [`FarmToad-IoT-Messages`](#message-structure) ## Swift-MessageUtils It's a library in swift to serialize and deserialize a message. However, it has been only carefully tested for **Serialization** of the message and **Deserialization** without signature checks. ## Typescript-MessageUtils It's a Typescript library (Compatible with JavaScript too) that aims to offer only the **Deserialization** along a **Signature Check**. However, here it is not offered any type of **Serialization** feature as deemed unnecessary during the development of the project. # Message Structure Messages were left with a broad margin for versions, signatures, and fields, to ensure a high degree of flexibility in the project. Here it is described the message structure for each `FarmToad-IoT-Messages`. ## Index - [`Main Corpus`](#main-corpus) - [`Fields`](#fields) ## Main corpus ``` +-+ 64 - bits---+----------------+-------------+----------------+-----------------------+ |0| Version 7 | Message Type 8 | Dev Type 8 | RESERVED 8 | Sign Type 32 | +-+-------------+----------------+-------------+----------------+-----------------------+ | Timestamp 64 | +---------------------------------------------------------------------------------------+ | DevID 128 bits | | | +---------------------------------------------------------------------------------------+ | Location 192 bits | | | | | +---------------------------------------------------------------------------------------+ \ / | Fields -----------------------------------------------------------------------------| / \ +---------------------------------------------------------------------------------------+ | 0 Padding 64 - n | +---------------------------------------------------------------------------------------+ | Signature - arbitrary number of bit | | | | | | | | | | | | | | | +---------------------------------------------------------------------------------------+ ``` ## Fields each field can be at most 8 * 2^32 bits of length: - 34359738368 bits - 4294967296 Bytes ``` +-- 64 - bits--------------------------+----------------------------------------+ | Key-Length 32 | Value-Length 32 | +--------------------------------------+----------------------------------------+ \ Key / |-----------------------------------------------------------------------------| / Value \ +-------------------------------------------------------------------------------+ ``` ## Key **MUST** be a `String` ## Value It's up to the Application to decide whether the value is a string or another type of datum