Package com.framed.interop.mqtt
Class MqttCodec
java.lang.Object
com.framed.interop.mqtt.MqttCodec
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 Summary
Modifier and TypeMethodDescriptionstatic org.json.JSONObjectdecode(byte[] payload) Decodes a JSON payload.static byte[]encode(DataPoint<?> dp, CodedConcept concept) Encodes a datapoint (with optional coded concept) to a JSON payload.
-
Method Details
-
encode
Encodes a datapoint (with optional coded concept) to a JSON payload.- Parameters:
dp- the datapointconcept- the coded concept, ornullif 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
-
