From d55e5afc92c89ab23318958206961a2633a0bbc4 Mon Sep 17 00:00:00 2001 From: Orne Brocaar Date: Thu, 21 Apr 2022 13:26:58 +0100 Subject: [PATCH] Add encode / decode JS templates on device-profile create. --- .../device-profiles/CreateDeviceProfile.tsx | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/ui/src/views/device-profiles/CreateDeviceProfile.tsx b/ui/src/views/device-profiles/CreateDeviceProfile.tsx index 83fdfcd1..aebebb0f 100644 --- a/ui/src/views/device-profiles/CreateDeviceProfile.tsx +++ b/ui/src/views/device-profiles/CreateDeviceProfile.tsx @@ -28,7 +28,33 @@ class CreateDeviceProfile extends Component { } render() { - const deviceProfile = new DeviceProfile(); + const encodeScript = `// Encode encodes the given object into an array of bytes. +// +// Input is an object with the following fields: +// - f_port = LoRaWAN fPort +// - variables = Device variables +// - object = Input object, e.g. {"temperature": 22.5} +// +// This function must return an array of bytes, e.g. [225, 230, 255, 0] +export function Encode(input) { + return []; +}`; + + const decodeScript = `// Decode decodes an array of bytes into an object. +// +// Input is an object with the following fields: +// - f_port = LoRaWAN fPort +// - variables = Device variables +// - bytes = Input byte array, e.g. [225, 230, 255, 0] +// +// This function must return an object, e.g. {"temperature": 22.5} +export function Decode(input) { + return {}; +}`; + + let deviceProfile = new DeviceProfile(); + deviceProfile.setPayloadEncoderConfig(encodeScript); + deviceProfile.setPayloadDecoderConfig(decodeScript); return(