// Solicitar datos: AA0330010001 function decodeUplink(input) { var data = {}; var port = input.fPort; var bytes = input.bytes; switch (input.fPort) { case 5: { var freq_band; var sub_band; var sensor; if (bytes[0] == 0x17) sensor = 'SDI12-LB'; data.SENSOR_MODEL = sensor; var firm_ver = (bytes[1] & 0x0f) + '.' + ((bytes[2] >> 4) & 0x0f) + '.' + (bytes[2] & 0x0f); data.FIRMWARE_VERSION = firm_ver; if (bytes[3] == 0x01) freq_band = 'EU868'; else if (bytes[3] == 0x02) freq_band = 'US915'; else if (bytes[3] == 0x03) freq_band = 'IN865'; else if (bytes[3] == 0x04) freq_band = 'AU915'; else if (bytes[3] == 0x05) freq_band = 'KZ865'; else if (bytes[3] == 0x06) freq_band = 'RU864'; else if (bytes[3] == 0x07) freq_band = 'AS923'; else if (bytes[3] == 0x08) freq_band = 'AS923_1'; else if (bytes[3] == 0x09) freq_band = 'AS923_2'; else if (bytes[3] == 0x0a) freq_band = 'AS923_3'; else if (bytes[3] == 0x0f) freq_band = 'AS923_4'; else if (bytes[3] == 0x0b) freq_band = 'CN470'; else if (bytes[3] == 0x0c) freq_band = 'EU433'; else if (bytes[3] == 0x0d) freq_band = 'KR920'; else if (bytes[3] == 0x0e) freq_band = 'MA869'; data.FREQUENCY_BAND = freq_band; if (bytes[4] == 0xff) data.SUB_BAND = 'NULL'; else data.SUB_BAND = bytes[4]; data.bat = ((bytes[5] << 8) | bytes[6]) / 1000; return { data: data, }; break; } case 100: { for (var j = 0; j < bytes.length; j++) { var datas = String.fromCharCode(bytes[j]); if (j == '0') data.datas_sum = datas; else data.datas_sum += datas; } return { data: data, }; break; } default: { data.EXTI_Trigger = bytes[0] & 0x80 ? 'TRUE' : 'FALSE'; data.BatV = (((bytes[0] << 8) | bytes[1]) & 0x7fff) / 1000; data.Payver = bytes[2]; var datas_sum = ""; for (var i = 3; i < bytes.length; i++) { datas_sum += String.fromCharCode(bytes[i]); } var array = datas_sum.trim(); var valores = array.split("+"); if(valores.length > 1){ var calibratedCountsVWC = parseFloat(valores[0]); data.calibratedCountsVWC = calibratedCountsVWC; data.temp_SOIL = parseFloat(valores[1]); data.VWCmineral = parseFloat((3.879E-4*calibratedCountsVWC - 0.6956).toFixed(3)); data.VWCsoilless = parseFloat((6.771E-10*calibratedCountsVWC^3 - 5.105E-6*calibratedCountsVWC^2 + 1.302E-2*calibratedCountsVWC - 10.848).toFixed(3)); data.VWCdielectric = parseFloat(((2.887E-9*calibratedCountsVWC^3 -2.080E-5*calibratedCountsVWC^2 +5.276E-2*calibratedCountsVWC -43.39)^2).toFixed(3)); } else data.datas_sum = array; return { data: data, }; break; } } }