Class MqttCodec

java.lang.Object
com.framed.interop.mqtt.MqttCodec

public final class MqttCodec extends Object
Encodes/decodes the self-describing JSON payload carried on MQTT.

A payload always carries the EAV coordinates (value, timestamp, channelID, deviceID, className); when the channel is mapped it also carries the coded concept (code, system, unit) so the stream is interoperable without an out-of-band mapping.

  • Method Details

    • encode

      public static byte[] encode(DataPoint<?> dp, CodedConcept concept)
      Encodes a datapoint (with optional coded concept) to a JSON payload.
      Parameters:
      dp - the datapoint
      concept - the coded concept, or null if the channel is unmapped
      Returns:
      the UTF-8 JSON payload bytes
    • decode

      public static org.json.JSONObject decode(byte[] payload)
      Decodes a JSON payload.
      Parameters:
      payload - the UTF-8 JSON payload bytes
      Returns:
      the parsed object