Skip to content

Commit c0fa36d

Browse files
committed
doc: Add recvTime to decodeUplink() input
1 parent 0e6b660 commit c0fa36d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

doc/content/integrations/payload-formatters/javascript/uplink/_index.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ function decodeUplink(input) {
1818
// {
1919
// "bytes": [1, 2, 3], // FRMPayload (byte array)
2020
// "fPort": 1
21+
// "recvTime": "Thu Jan 16 2025 17:29:37 GMT+0200 (Eastern European Standard Time)" // receivedAt (Date object)
2122
// }
2223
return {
2324
data: {
@@ -183,6 +184,7 @@ function decodeUplink(input) {
183184
3: "motion",
184185
4: "button",
185186
};
187+
data.recvTime = input.recvTime.toString();
186188
data.event = events[input.fPort];
187189
data.battery = (input.bytes[0] << 8) + input.bytes[1];
188190
data.light = (input.bytes[2] << 8) + input.bytes[3];
@@ -213,7 +215,7 @@ function normalizeUplink(input) {
213215

214216
For example, the end device observed an event and performed some measurements. The end device transmitted the following binary payload: `0C B2 04 80 F7 AE` (hex encoded) on FPort 4. The Base64 equivalent of that binary payload is `DLIEgPeu` and the JavaScript byte array is `[ 12, 178, 4, 128, 247, 174 ]`. This is all the same, just a different representation.
215217

216-
The uplink decoder gets the JavaScript byte array of the binary payload and FPort as input. {{% tts %}} sets `frm_payload` to the Base64 representation of the binary payload, and `decoded_payload` to the output `data` of the uplink decoder. If there are warnings, they are set in `decoded_payload_warnings`.
218+
The uplink decoder gets the JavaScript byte array of the binary payload, the FPort and the time of receipt (recvTime) as input. {{% tts %}} sets `frm_payload` to the Base64 representation of the binary payload, and `decoded_payload` to the output `data` of the uplink decoder. If there are warnings, they are set in `decoded_payload_warnings`.
217219

218220
The `data.uplink_message` object of the `as.up.data.forward` event will contain:
219221

@@ -226,6 +228,7 @@ The `data.uplink_message` object of the `as.up.data.forward` event will contain:
226228
"battery": 3250,
227229
"event": "setup",
228230
"light": 1152,
231+
"recvTime": "Tue Jan 21 2025 17:56:54 GMT+0100 (CET)",
229232
"temperature": -21.3
230233
},
231234
"decoded_payload_warnings": ["it's cold"],

0 commit comments

Comments
 (0)