function datalog(i,bytes){ var aa= parseFloat(((bytes[4+i]<<24>>16 | bytes[5+i])/10).toFixed(1)); var bb= parseFloat(((bytes[2+i]<<24>>16 | bytes[3+i])/10).toFixed(1)); var cc= (bytes[6+i]&0x02) ? "High":"Low"; var dd= (bytes[6+i]&0x01) ? "True":"False"; var ee= getMyDate((bytes[7+i]<<24 | bytes[8+i]<<16 | bytes[9+i]<<8 | bytes[10+i]).toString(10)); var string='['+aa+','+bb+','+cc+','+dd+','+ee+']'+','; return string; } function getzf(c_num){ if(parseInt(c_num) < 10) c_num = '0' + c_num; return c_num; } function getMyDate(str){ var c_Date; if(str > 9999999999) c_Date = new Date(parseInt(str)); else c_Date = new Date(parseInt(str) * 1000); var c_Year = c_Date.getFullYear(), c_Month = c_Date.getMonth()+1, c_Day = c_Date.getDate(), c_Hour = c_Date.getHours(), c_Min = c_Date.getMinutes(), c_Sen = c_Date.getSeconds(); var c_Time = c_Year +'-'+ getzf(c_Month) +'-'+ getzf(c_Day) +' '+ getzf(c_Hour) +':'+ getzf(c_Min) +':'+getzf(c_Sen); return c_Time; } function Decoder(bytes, port) { //LTC2-LB Decode if(port==0x02) { var decode = {}; decode.BatV=(bytes[0]<<8 | bytes[1])/1000; decode.Interrupt_flag=(bytes[2] & 0x01)? "TRUE":"FALSE"; decode.Interrupt_level=(bytes[2] & 0x02)? "HIGH":"LOW"; decode.TEMP1H_flag= (bytes[2] &0x10)? "True":"False"; decode.TEMP1L_flag= (bytes[2] &0x20)? "True":"False"; decode.TEMP2H_flag= (bytes[2] &0x04)? "True":"False"; decode.TEMP2L_flag= (bytes[2] &0x08)? "True":"False"; var Temp_Channel1=parseFloat(((bytes[3]<<24>>16 | bytes[4])/10).toFixed(1)); if (Temp_Channel1>2000 | Temp_Channel1<-2000) { decode.Temp_Channel1 = 0; } else { decode.Temp_Channel1 = Temp_Channel1; } var Temp_Channel2=parseFloat(((bytes[5]<<24>>16 | bytes[6])/10).toFixed(1)); if (Temp_Channel2>2000 | Temp_Channel2<-2000) { decode.Temp_Channel2 = 0; } else { decode.Temp_Channel2 = Temp_Channel2; } decode.Data_time= getMyDate((bytes[7]<<24 | bytes[8]<<16 | bytes[9]<<8 | bytes[10]).toString(10)); if(bytes.length==11) return decode; } else if(port==3) { var pnack= ((bytes[6]>>7)&0x01) ? "True":"False"; for(var i=0;i>4&0x0f)+'.'+(bytes[2]&0x0f); 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"; if(bytes[4]==0xff) sub_band="NULL"; else sub_band=bytes[4]; var bat= (bytes[5]<<8 | bytes[6])/1000; return { SENSOR_MODEL:sensor, FIRMWARE_VERSION:firm_ver, FREQUENCY_BAND:freq_band, SUB_BAND:sub_band, BAT:bat, } } }