Browse Source

updated Loriot default decoder and encoder

pull/16300/head
dashevchenko 5 months ago
committed by Viacheslav Klimov
parent
commit
ebe820002e
Failed to extract signature
  1. 6
      ui-ngx/src/app/shared/models/converter.models.ts
  2. 7
      ui-ngx/src/assets/converters/js-loriot-decoder.raw
  3. 30
      ui-ngx/src/assets/converters/js-loriot-encoder.raw
  4. 7
      ui-ngx/src/assets/converters/tbel-loriot-decoder.raw
  5. 30
      ui-ngx/src/assets/converters/tbel-loriot-encoder.raw

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

@ -46,14 +46,16 @@ export const IntegrationTbelDefaultEncodersUrl = new Map<IntegrationType, string
[IntegrationType.TTI, '/assets/converters/tbel-tti-encoder.raw'],
[IntegrationType.TTN, '/assets/converters/tbel-ttn-encoder.raw'],
[IntegrationType.MQTT, '/assets/converters/tbel-mqtt-encoder.raw'],
[IntegrationType.CHIRPSTACK, '/assets/converters/tbel-chirpstack-encoder.raw']
[IntegrationType.CHIRPSTACK, '/assets/converters/tbel-chirpstack-encoder.raw'],
[IntegrationType.LORIOT, '/assets/converters/tbel-loriot-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.MQTT, '/assets/converters/js-mqtt-encoder.raw'],
[IntegrationType.CHIRPSTACK, '/assets/converters/js-chirpstack-encoder.raw']
[IntegrationType.CHIRPSTACK, '/assets/converters/js-chirpstack-encoder.raw'],
[IntegrationType.LORIOT, '/assets/converters/js-loriot-encoder.raw']
])
export const jsDefaultConvertersUrl = new Map<ConverterType, string>([

7
ui-ngx/src/assets/converters/js-loriot-decoder.raw

@ -52,6 +52,13 @@ function decodePayload(input) {
// };
}
// Process only LORIOT uplink messages (cmd == 'rx').
// Skip downlink confirmations (e.g. cmd == 'txd') and other events so they
// are not stored as telemetry. Returning an empty array yields no uplink data.
if (metadata.cmd != 'rx') {
return [];
}
var result = decodePayload(payload);
// Uncomment this code block to overwrite values set in the main configuration window. Useful if you extract device/asset/customer/group names from the payload;
// result.type = 'DEVICE'; // Entity type allows you to choose type of created entity. Can be 'DEVICE' or 'ASSET'.

30
ui-ngx/src/assets/converters/js-loriot-encoder.raw

@ -0,0 +1,30 @@
// Encode downlink data from incoming Rule Engine message.
// msg - JSON message payload (e.g. { "state": "on" })
// msgType - message type, e.g. 'ATTRIBUTES_UPDATED'
// metadata - enriched by the Originator attributes node with device client attributes.
// ThingsBoard prefixes client-scope attributes with "cs_":
// metadata.cs_eui — LORIOT device EUI stored on first uplink (e.g. "466ECD510CF7B021")
// metadata.cs_fPort — LoRaWAN frame port stored on first uplink (e.g. "1")
var eui = metadata.cs_eui;
// Default port to 1 when the device fPort attribute is missing or empty.
var port = (metadata.cs_fPort != null && metadata.cs_fPort != '')
? parseInt(metadata.cs_fPort)
: 1;
var result = {
// Downlink data content type: JSON, TEXT, or BINARY (base64 format).
contentType: "JSON",
// Downlink data — serialise the full message payload as a JSON string.
data: JSON.stringify(msg),
// Metadata required by LORIOT for downlink delivery.
metadata: {
"EUI": eui,
"port": port
}
};
return result;

7
ui-ngx/src/assets/converters/tbel-loriot-decoder.raw

@ -52,6 +52,13 @@ function decodePayload(input) {
// };
}
// Process only LORIOT uplink messages (cmd == 'rx').
// Skip downlink confirmations (e.g. cmd == 'txd') and other events so they
// are not stored as telemetry. Returning an empty array yields no uplink data.
if (metadata.cmd != 'rx') {
return [];
}
var result = decodePayload(payload);
// Uncomment this code block to overwrite values set in the main configuration window. Useful if you extract device/asset/customer/group names from the payload;
// result.type = 'DEVICE'; // Entity type allows you to choose type of created entity. Can be 'DEVICE' or 'ASSET'.

30
ui-ngx/src/assets/converters/tbel-loriot-encoder.raw

@ -0,0 +1,30 @@
// Encode downlink data from incoming Rule Engine message.
// msg - JSON message payload (e.g. { "state": "on" })
// msgType - message type, e.g. 'ATTRIBUTES_UPDATED'
// metadata - enriched by the Originator attributes node with device client attributes.
// ThingsBoard prefixes client-scope attributes with "cs_":
// metadata.cs_eui — LORIOT device EUI stored on first uplink (e.g. "466ECD510CF7B021")
// metadata.cs_fPort — LoRaWAN frame port stored on first uplink (e.g. "1")
var eui = metadata.cs_eui;
// Default port to 1 when the device fPort attribute is missing or empty.
var port = (metadata.cs_fPort != null && metadata.cs_fPort != '')
? parseInt(metadata.cs_fPort)
: 1;
var result = {
// Downlink data content type: JSON, TEXT, or BINARY (base64 format).
contentType: "JSON",
// Downlink data — serialise the full message payload as a JSON string.
data: JSON.stringify(msg),
// Metadata required by LORIOT for downlink delivery.
metadata: {
"EUI": eui,
"port": port
}
};
return result;
Loading…
Cancel
Save