https://www.zane.hu/en/webshop/ztrack-tube/
visit
regards
gerhard
function Decoder(b,port)
{
var decode = {};
var decode204 = {};
var decode205 = {};
var decode207 = {};
if(port===204)
{
decode204.payload = b;
decode204.porta = port;
decode.lat = b[0]<<24>>8 | b[1]<<8 | b[2];
decode.lng = b[3]<<24>>8 | b[4]<<8 | b[5];
decode204.altitude = b[6]<<8 | b[7];
decode204.hdop = b[8];
decode204.battery =(b[11]>>4)*10;
decode204.battery+=(b[11]&0x0F);
decode204.latitude = (decode.lat / 8388606) * 90;
decode204.longitude = (decode.lng / 8388606) * 180;
return decode204;
}
else if(port===205)
{
decode205.payload = b;
decode205.porta = port;
decode205.battery=(b[2]>>4)*10;
decode205.battery+=(b[2]&0x0F);
return decode205;
}
else if(port===207)
{
decode207.payload = b;
decode207.porta = port;
decode207.battery=(b[2]>>4)*10;
decode207.battery+=(b[2]&0x0F);
return decode207;
}
else
{
decode.porta = port;
decode.payload = b;
return decode;
}
}
function Decoder(b,port)
{
var decode = {};
var decode204 = {};
var decode205 = {};
var decode207 = {};
decode204.payload = b;
decode204.porta = port;
decode.lat = b[0]<<24>>8 | b[1]<<8 | b[2];
decode.lng = b[3]<<24>>8 | b[4]<<8 | b[5];
decode204.altitude = b[6]<<8 | b[7];
decode204.hdop = b[8];
decode204.battery =(b[11]>>4)*10;
decode204.battery+=(b[11]&0x0F);
decode204.latitude = (decode.lat / 8388606) * 90;
decode204.longitude = (decode.lng / 8388606) * 180;
return {
longitude: decode204.longitude,
latitude: decode204.latitude,
altitude: decode204.altitude,
hdop: decode204.hdop,
}
}
Works well too
with hdop . ok
In your Google document, it states:
- artificial hdop added, because ttnmapper.org is in demand for this value and not provided here
- according to CEO this will be added in new firmware version
So, are you saying that hdop is not currently expected in the payload?
And, for port = 204, the Google document uses the same bytes[8]
for part of the temperature instead:
temp = (bytes[8] & 0x0F) * 100;
temp += ((bytes[9] & 0xF0) >> 4 ) * 10;
temp += bytes[9] & 0x0F;
if( bytes[8] & 80)
temp /= -10;
else
temp /= 10;
Also, the Google document extracts a battery value from bytes[10]
for port = 204, while the version by @mid-walesha uses bytes[11]
?
bat = ((bytes[10] & 0xF0) >> 4) * 10;
bat += bytes[10] & 0x0F
So, some mismatchs there?
(I don’t own this device. The Google document also extracts a temperature from bytes[0]
and bytes[1]
for the other port numbers, but that’s extra data, not a conflict.)
“So, are you saying that hdop is not currently expected in the payload?”
yes.
got this from the manufacturer. needs to be revised, obviously.