Using the decoder on a Milesight gateway via the classic interface
This page explains how to use the decoder for any sensor using the milesight interface (no NodeRED).
To start, go into Network Server, in the Payload Codec tab.
In the payload decoder function input area, insert the content of the main.js file of your sensor, from our Github repository (distrib/yourSensor/main.js).
Below the part you pasted, you'll need to add this function:
function Decode(fPort,bytes) {
var _input = {
"bytes": bytes, // The frame in a bytes list
"fPort": fPort, // The port (Watteco always use 125)
"recvTime": new Date().toISOString() // The date in ISO 8601 format
};
return driver.decodeUplink(_input);
}
It should then look like that (the first line might look different depending on the sensor you are using):

Don't forget to give a name to your Custom Payload Codec, to save, and to apply it to your added sensor.