How to Use Payload Codec on Linovision Gateway (Old)


This article will guide you how to add decoders and custom uplink contents when using Linovision gateway built-in network server. 


  • Linovision LoRaWAN Gateway: IOT-G8x(firmware version and later), IOT-G65/IOT-G67 (firmware version and before), IOT-G56, IOT-G63

For IOT-G65/IOT-G67 with firmware version and later, please refer to How to Use Payload Codec on Linovision Gateway.



Login Linovision Gateway’s web interface, create an application in Network Server->Applications page.


Select the Payload Codec type as Custom and type the Javascript code to custom the uplink contents.

Note: This payload codec is only applied for the devices under this application. If you need to use other decoders, please create a new application.



Take IOT-S500-TH as example, here are 3 situations for uplink content customization.

1. Only upload decoded sensor data.

Copy IOT-S500-TH decoder and paste it to Payload decoder function box.

Note: If you configure the sensor from other company, please contact their support to get the Decoder Script (Java Script), then ensure the script header is function Decode(fPort, bytes) when paste.



{ "battery": 92, "temperature": 30.8, "humidity": 50.5,}

2. Upload specific attribute items and raw data.

Click here to know all attribute items in one package. Milesight gateways provide function LoRaOject to call every item you require. If you need to send dev EUI, RSSI, SNR and raw data, edit this example coder:

function Decode(fPort, bytes) {var decoded = {};decoded.devEUI = LoRaObject.devEUI;decoded.rssi = LoRaObject.rxInfo[0].rssi;decoded.snr = LoRaObject.rxInfo[0].loRaSNR; =;return decoded;}


{"devEUI":24e1611234567890"rssi": -5,"snr": 11,"data": AXVkA2cgAQRoeg==}


3. Upload specific attribute items and decoded data.

Copy IOT-S500-TH decoder and paste it to Payload decoder function box, then add attribute items before return decoded statement:

function Decode(fPort, bytes) { var decoded = {}; //Data decoder for (var i = 0; i < bytes.length;) { var channel_id = bytes[i++]; var channel_type = bytes[i++]; // BATTERY if (channel_id === 0x01 && channel_type === 0x75) { decoded.battery = bytes[i]; i += 1; } // TEMPERATURE else if (channel_id === 0x03 && channel_type === 0x67) { decoded.temperature = readInt16LE(bytes.slice(i, i + 2)) / 10; i += 2; } // HUMIDITY else if (channel_id === 0x04 && channel_type === 0x68) { decoded.humidity = bytes[i] / 2; i += 1; } else { break; } } decoded.devEUI = LoRaObject.devEUI; return decoded;}/* ****************************************** * bytes to number ********************************************/function readUInt16LE(bytes) { var value = (bytes[1] << 8) + bytes[0]; return value & 0xffff;}function readInt16LE(bytes) { var ref = readUInt16LE(bytes); return ref > 0x7fff ? ref - 0x10000 : ref;}


{ "battery": 92, "temperature": 30.8, "humidity": 50.5,"devEUI":24e1611234567890}

Note: If you need to add all attribute items, add decoded.obj= LoRaObject; before return decoded statement.