Created
June 3, 2019 07:22
-
-
Save AlexDoanTB/b91dac7922ae3a542dc60fb4601ea944 to your computer and use it in GitHub Desktop.
Downlink Encoder function for RPC call to device via MQTT Integration on ThingsBoard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** Encoder **/ | |
| var value = parseInt(msg.params.replace(/"/g,"")); | |
| var data = {value: value} | |
| // Result object with encoded downlink payload | |
| var result = { | |
| // downlink data content type: JSON, TEXT or BINARY (base64 format) | |
| contentType: "JSON", | |
| // downlink data | |
| data: JSON.stringify(data), | |
| // Optional metadata object presented in key/value format | |
| metadata: { | |
| topic: 'tb/mqtt-integration-guide/sensors/'+metadata['deviceName']+'/rx' | |
| } | |
| }; | |
| return result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment