MQTT Payload Manual for Bits and Integers

This manual provides guidance on the payload structure and commands for working with bits and integers in MQTT (Message Queuing Telemetry Transport). Bits and integers represent binary states and numerical values respectively in an iNELS environment.

Topics and Payload Format

Status Topic

The status topic is used to retrieve the current state of bits and integers.

Topic Structure:

inels/status/<mac_ID>/bits/<topic_ID>
inels/status/<mac_ID>/integers/<topic_ID>

Payload Format:

{
    "last_seen": "<timestamp>",
    "state": {
        "<ID_1>": <value_1>,
        "<ID_2>": <value_2>,
        ...
        "<ID_n>": <value_n>
    }
}
  • <timestamp>: Time when the status was last updated.

  • <ID>: Unique identifier for the bit or integer.

  • <value>: Binary state (for bits) or numerical value (for integers).

Set Topic

The set topic is used to send commands to control bits and integers.

Topic Structure:

inels/set/<mac_ID>/bits/<topic_ID>
inels/set/<mac_ID>/integers/<topic_ID>

Command Format:

{
    "cmd": {
        "<ID_1>": "<command_1>",
        "<ID_2>": "<command_2>",
        ...
        "<ID_n>": "<command_n>"
    }
}
  • <ID>: Unique identifier for the bit or integer.

  • <command>: Action to be performed on the corresponding bit or integer.

Commands

For Bits

  • 0: Turn off the bit.

  • 1: Turn on the bit.

  • toggle: Toggle the current state of the bit.

For Integers

  • Set a specific value for the integer.

Limitations

  • Maximum 40 bits or 20 integers can be included in one topic.

  • If there are more bits or integers, they will be displayed in additional topics.

Example

Status Topic Payload (Bits)

Topic: inels/status/2C6A6F104825/bits/000001

Payload:

{
    "last_seen": "2024-03-15T13:02:07.+0100Z",
    "state": {
        "000": 1,
        "001": 0,
        "002": 0,
        ...
        "040": 0
    }
}

Set Topic Command (Bits)

Topic: inels/set/2C6A6F104825/bits/000001

Command:

{
    "cmd": {
        "005": "toggle"
    }
}

Status Topic Payload (Integers)

Topic: inels/status/2C6A6F104825/integers/000001

Payload:

{
    "last_seen": "2024-03-15T13:11:33.+0100Z",
    "state": {
        "000": 2556,
        "001": 0,
        "002": 97,
        ...
        "020": 0
    }
}

Set Topic Command (Integers)

Topic: inels/set/2C6A6F104825/integers/000001

Command:

{
    "cmd": {
        "002": 97
    }
}

Conclusion

This manual provides a clear understanding of the payload structure and commands for interacting with bits and integers over MQTT. It facilitates efficient communication and control in IoT applications.

Last updated