Sensor
function decodeUplink(input){ var data = {}; data.sensorType = 'moisture'; if (input.bytes.length === 0){ data.valid = false; return{ data: data } } data.settingsAllowed = true; data.moisture = 0; data.charging = false; data.battery = 2 + (input.bytes[0] / 10); if (input.fPort === 1){ if (input.bytes.length === 2){ data.valid = true; data.moisture = input.bytes[1]; } else if (input.bytes.length === 6){ data.valid = true; data.moisture = input.bytes[1]; var temp = input.bytes[2]<<24>>16 | input.bytes[3]; data.temperature = temp / 100; } else{ data.valid = false; data.errorcode = -1; } } else if (input.fPort === 3){ data.valid = false; data.charging = true; } return{ data: data } }
This codec is sourced from The Things Network. All rights belong to The Things Network.
This codec is licensed under the GNU General Public License v3 (GPL v3). Modifications, if any, are clearly marked. You are free to use, modify, and distribute the codec under the terms of GPL v3.