diff --git a/Asset/MessageBytes.md b/Asset/MessageBytes.md index f003520..51b2f7c 100644 --- a/Asset/MessageBytes.md +++ b/Asset/MessageBytes.md @@ -1,7 +1,7 @@ # Message Structure ``` +-+ 64 - bits---+----------------+-------------+----------------+-----------------------+ -|0| Version 7 | Message Type 8 | Dev Type 8 | RESERVED 8 | Sign Type 32 | +|0| Version 7 | Message Type 8 | Dev Type 8 | RESERVED 8 | Sign Type 32 | +-+-------------+----------------+-------------+----------------+-----------------------+ | Timestamp 64 | +---------------------------------------------------------------------------------------+ diff --git a/README.md b/README.md index 372fb0c..5ddcf85 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,79 @@ # 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** features +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 up to-512 bits | +| | +| | +| | +| | +| | +| | +| | ++---------------------------------------------------------------------------------------+ +``` + +## 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