User Tools

Site Tools


wiki:decoderupload

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
wiki:decoderupload [2023/07/28 17:49] mbrauerwiki: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, follow these guidelines when uploading a custom JavaScript decoder. The decoder function should be denoted as `Decoder(bytes, port)`.+To ensure compatibility, follow these guidelines when uploading a custom JavaScript decoder.
  
-===== Necessities for Uploading a Custom JavaScript Decoder =====+===== Example Custom Decoder Function =====
  
-  *** Function Signature**: The decoder function must have the following signature: function Decoder(bytes, port) { //Your decoding logic here// } +Here's a simple example of a custom JavaScript decoder function conforming to the required 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.+
  
-  *** GraalVM Support**: Ensure that the JavaScript code used in the decoder is compatible with GraalVM's JavaScript engineGraalVM supports most ECMAScript 5.1 features and some ECMAScript 2015 (ES6featuresRefer to GraalVM's documentation for the specific version details and supported features.+<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 as a string. 
 +*/ 
 +function Decoder(bytes, port
 +  // 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; 
 +
 +</code>
  
 +===== Necessities for Uploading a Custom JavaScript Decoder =====
  
-- `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. +  *** Function Signature**The decoder function must have the following signature: function Decoder(bytes, port) { //Your decoding logic here// } 
-- `port`: This parameter denotes the port number that might be used within the decoder function or during the decoding process.+      * Other functions can be used in the file can called from the Decoder function, but the Decoder function acts as the main function
  
-**Dependency Management**: Ensure that any external dependencies used in your JavaScript code are compatible with GraalVM. Double-check that any libraries or modules you include are compatible with the JavaScript engine in GraalVM.+      * **Return Value**: The decoder must return an **object** that represents the desired tag structure of the UDT.
  
-**Runtime Limitations**: Be aware of the runtime limitations and constraints of GraalVM. For example, certain features or APIs available in other JavaScript engines may not be present in GraalVMRefer to the GraalVM documentation for any restrictions you should consider while writing your custom decoder.+      * **bytes**: This parameter represents the input data that needs to be decodedIt is an array of bytes that is gathered from an uplink's payload.
  
-**Testing**: Before uploading the custom JavaScript decoder, thoroughly test it in a GraalVM environment. Ensure that it performs as expected and adheres to the function signature mentioned above.+      * **port**: This parameter denotes the port number that might be used within the decoder function or during the decoding process.
  
-===== Example Custom Decoder Function =====+- **Runtime Limitations**: Be aware of the runtime limitations and constraints of GraalVM. For example, certain features or APIs available in other JavaScript engines may not be present in GraalVM. Refer to the GraalVM documentation for any restrictions you should consider while uploading your custom decoder. 
 + 
 +- **Testing**: Before uploading the custom JavaScript decoder, thoroughly test it in a separate environment. Ensure that it performs as expected and adheres to the function signature mentioned above.
  
-Here's a simple example of a custom JavaScript decoder function conforming to the specified function signature: 
  
-<code javascript> 
-function addNumbers(a, b) { 
-    return a + b; 
-} 
-</code> 
wiki/decoderupload.1690566599.txt.gz · Last modified: 2023/07/28 17:49 by mbrauer