Protocol Identification Uniguard GPS Tracker for bicycle

Berna Maxim4 years ago
Anton Tananaev4 years ago

Try S168 protocl.

Berna Maxim4 years ago
 String content = values[4];
        String[] fragments = content.split(";");
        for (String fragment : fragments) {

            int dataIndex = fragment.indexOf(':');
            String type = fragment.substring(0, dataIndex);
            values = fragment.substring(dataIndex + 1).split(",");
            int index = 0;

            switch (type) {
                case "GDATA":
                    position.setValid(values[index++].equals("A"));
                    position.set(Position.KEY_SATELLITES, Integer.parseInt(values[index++]));
                    DateFormat dateFormat = new SimpleDateFormat("yyMMddHHmmss");
                    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
                    position.setTime(dateFormat.parse(values[index++]));
                    position.setLatitude(Double.parseDouble(values[index++]));
                    position.setLongitude(Double.parseDouble(values[index++]));
                    position.setSpeed(UnitsConverter.knotsFromKph(Double.parseDouble(values[index++])));
                    position.setCourse(Integer.parseInt(values[index++]));
                    position.setAltitude(Integer.parseInt(values[index++]));
                    break;
                default:
                    break;
            }
        }

        return position.getAttributes().containsKey(Position.KEY_SATELLITES) ? position : null;
    }

I think the code above is suitable with the protocol documentation. I will try it. Thanks Anton.