wiki:decoderupload
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| wiki:decoderupload [2023/07/28 17:49] – mbrauer | wiki:decoderupload [2023/07/28 18:10] (current) – mbrauer | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Custom JavaScript Decoder Upload Requirements ====== | ====== Custom JavaScript Decoder Upload Requirements ====== | ||
| - | To ensure compatibility, | + | To ensure compatibility, |
| + | |||
| + | ===== Example Custom Decoder Function ===== | ||
| + | |||
| + | Here's a simple example of a custom JavaScript | ||
| + | |||
| + | <code javascript> | ||
| + | /** | ||
| + | * Custom decoder function for decoding data. | ||
| + | * @param bytes - The payload data to be decoded (an array of bytes). | ||
| + | * @param port - The port number used during decoding. | ||
| + | * @returns {string} - The decoded result | ||
| + | */ | ||
| + | function | ||
| + | // Your decoding logic here | ||
| + | let decodedResult = {}; //empty object that holds all UDT tag values | ||
| + | decodedResult.Measurement = bytes[0] | ||
| + | decodedResult.BatteryLevel = bytes[1] | ||
| + | decodedResult.Temperature = bytes[2] | ||
| + | return decodedResult; | ||
| + | } | ||
| + | </ | ||
| ===== Necessities for Uploading a Custom JavaScript Decoder ===== | ===== Necessities for Uploading a Custom JavaScript Decoder ===== | ||
| *** Function Signature**: | *** Function Signature**: | ||
| - | * Other functions can be used in the file can called from the Decoder function, but the Decoder(...) function acts as the main function. | + | * Other functions can be used in the file can called from the Decoder function, but the Decoder function acts as the main function. |
| - | | + | |
| + | * **bytes**: This parameter represents the input data that needs to be decoded. It is an array of bytes that is gathered from an uplink' | ||
| - | - `bytes`: This parameter represents the input data that needs to be decoded. It could be an array of bytes, a string, or any other data structure as per your requirements. | + | * **port**: This parameter denotes the port number that might be used within the decoder function or during the decoding process. |
| - | - `port`: This parameter denotes the port number that might be used within the decoder function or during the decoding process. | + | |
| - | - **Dependency Management**: Ensure that any external dependencies used in your JavaScript code are compatible with GraalVM. | + | - **Runtime Limitations**: Be aware of the runtime limitations and constraints of GraalVM. |
| - | - **Runtime Limitations**: Be aware of the runtime limitations and constraints of GraalVM. For example, certain features or APIs available | + | - **Testing**: Before uploading |
| - | - **Testing**: | ||
| - | ===== Example Custom Decoder Function ===== | ||
| - | |||
| - | Here's a simple example of a custom JavaScript decoder function conforming to the specified function signature: | ||
| - | ```javascript | ||
| - | { | ||
| - | // /** | ||
| - | * Custom decoder function for decoding data. | ||
| - | * @param {Array} bytes - The input data to be decoded (an array of bytes). | ||
| - | * @param {number} port - The port number used during decoding. | ||
| - | * @returns {string} - The decoded result as a string. | ||
| - | */ | ||
| - | function Decoder(bytes, | ||
| - | // Your decoding logic here | ||
| - | | ||
| - | let decodedResult = " | ||
| - | for (let i = 0; i < bytes.length; | ||
| - | decodedResult += String.fromCharCode(bytes[i]); | ||
| - | } | ||
| - | return decodedResult; | ||
| - | } | ||
| - | } | ||
wiki/decoderupload.1690566569.txt.gz · Last modified: 2023/07/28 17:49 by mbrauer