Created
June 3, 2019 07:23
-
-
Save AlexDoanTB/0fbac0598ac346392f1c4114b7ece15c to your computer and use it in GitHub Desktop.
The Encoder function for simulated two-way RPC downlink
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/twoway' | |
| } | |
| }; | |
| return result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment