Browse Source

added specific encoder for MQTT integration

pull/16300/head
dashevchenko 5 months ago
committed by Viacheslav Klimov
parent
commit
90fdfa4442
Failed to extract signature
  1. 6
      ui-ngx/src/app/shared/models/converter.models.ts
  2. 20
      ui-ngx/src/assets/converters/js-mqtt-encoder.raw
  3. 20
      ui-ngx/src/assets/converters/tbel-mqtt-encoder.raw

6
ui-ngx/src/app/shared/models/converter.models.ts

@ -44,12 +44,14 @@ export const IntegrationJSDefaultConvertersUrl = new Map<IntegrationType, string
export const IntegrationTbelDefaultEncodersUrl = new Map<IntegrationType, string>([
[IntegrationType.OPC_UA, '/assets/converters/tbel-opc-ua-encoder.raw'],
[IntegrationType.TTI, '/assets/converters/tbel-tti-encoder.raw'],
[IntegrationType.TTN, '/assets/converters/tbel-ttn-encoder.raw']
[IntegrationType.TTN, '/assets/converters/tbel-ttn-encoder.raw'],
[IntegrationType.MQTT, '/assets/converters/tbel-mqtt-encoder.raw']
])
export const IntegrationJSDefaultEncodersUrl = new Map<IntegrationType, string>([
[IntegrationType.TTI, '/assets/converters/js-tti-encoder.raw'],
[IntegrationType.TTN, '/assets/converters/js-ttn-encoder.raw']
[IntegrationType.TTN, '/assets/converters/js-ttn-encoder.raw'],
[IntegrationType.MQTT, '/assets/converters/js-mqtt-encoder.raw']
])
export const jsDefaultConvertersUrl = new Map<ConverterType, string>([

20
ui-ngx/src/assets/converters/js-mqtt-encoder.raw

@ -0,0 +1,20 @@
// Encode downlink data from incoming Rule Engine message
// msg - JSON message payload downlink message json
// msgType - type of message, for ex. 'ATTRIBUTES_UPDATED', 'POST_TELEMETRY_REQUEST', etc.
// metadata - list of key-value pairs with additional data about the message
// integrationMetadata - list of key-value pairs with additional data defined in Integration executing this converter
/** Encoder **/
// Publish the ThingsBoard message as JSON to the device command topic.
// metadata.topic is read by the integration when Downlink topic pattern is ${topic}.
var result = {
contentType: "JSON",
data: JSON.stringify(msg),
metadata: {
topic: metadata['deviceType']+'/'+metadata['deviceName']+'/upload'
}
};
return result;

20
ui-ngx/src/assets/converters/tbel-mqtt-encoder.raw

@ -0,0 +1,20 @@
// Encode downlink data from incoming Rule Engine message
// msg - JSON message payload downlink message json
// msgType - type of message, for ex. 'ATTRIBUTES_UPDATED', 'POST_TELEMETRY_REQUEST', etc.
// metadata - list of key-value pairs with additional data about the message
// integrationMetadata - list of key-value pairs with additional data defined in Integration executing this converter
/** Encoder **/
// Publish the ThingsBoard message as JSON to the device command topic.
// metadata.topic is read by the integration when Downlink topic pattern is ${topic}.
var result = {
contentType: "JSON",
data: JSON.stringify(msg),
metadata: {
topic: metadata['deviceType'] + '/' + metadata['deviceName'] + '/upload'
}
};
return result;
Loading…
Cancel
Save