committed by
Viacheslav Klimov
3 changed files with 50 additions and 2 deletions
@ -0,0 +1,23 @@ |
|||||
|
// 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 **/ |
||||
|
|
||||
|
// Result object with encoded downlink payload |
||||
|
var result = { |
||||
|
// downlink data content type: JSON, TEXT or BINARY (base64 format) |
||||
|
contentType: "TEXT", |
||||
|
// downlink data |
||||
|
data: btoa(msg), |
||||
|
// Optional metadata object presented in key/value format |
||||
|
metadata: { |
||||
|
DevEUI: metadata.cs_eui, |
||||
|
fPort: metadata.cs_fPort |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
return result; |
||||
@ -0,0 +1,23 @@ |
|||||
|
// 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 **/ |
||||
|
|
||||
|
// Result object with encoded downlink payload |
||||
|
var result = { |
||||
|
// downlink data content type: JSON, TEXT or BINARY (base64 format) |
||||
|
contentType: "TEXT", |
||||
|
// downlink data |
||||
|
data: btoa(msg), |
||||
|
// Optional metadata object presented in key/value format |
||||
|
metadata: { |
||||
|
DevEUI: metadata.cs_eui, |
||||
|
fPort: metadata.cs_fPort |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
return result; |
||||
Loading…
Reference in new issue