Looks like this format is not supported yet. Do you have a protocol documentation?
Hi Anton,
Can I use same logic as u did for osmAnd protocol ?
Not sure what you mean by same logic, but OsmAnd is not a good example.
Hi Anton,
Below are the details about protocol, please help me to add this device on server.
$loc START Bytes
, COMMA
363879036739252 IMEI No.
, COMMA
070915012535 Time as per GPS String in DDMMYYHHMMSS in UTC
, COMMA
A GPS FIX either A or V in case not fixed
, COMMA
28.606225 Latitude
, COMMA
N Latitude Cardinal
, COMMA
76.346434 Longitude
, COMMA
E Longitude Cardinal
, COMMA
033 speed in Kmph
, COMMA
53.150 Bearing (Track angle)
, COMMA
09 Number of Satellites
, COMMA
192.20 Altitude
, COMMA
0 Value of Digital input 1
, COMMA
0 Value of Digital input 2
, COMMA
0 Value of Digital input 3 AC ON/OFF
, COMMA
0 Value of Digital input 4
, COMMA
0 Digital Output1
, COMMA
0000 Fuel Sensor
, COMMA
0944 Car Battery Power
, COMMA
0.00 FW Versions
, COMMA
0 Tamper Value
Please copy above details in any file, seems formatting is not working,I was trying to use below code to encode and decode
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "\r\n", "\n", ";"));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectEncoder", new Gps103ProtocolEncoder());
pipeline.addLast("objectDecoder", new Gps103ProtocolDecoder(Gps103Protocol.this));
Is there necessary to write objectEncoder for above string ?
Please provide proper full documentation.
Hi Anton,
I have added new protocol for above device at port 5105.But when I see log, port is not open.
I also added protocol in traccar.xml. Is there any other configuration required ?
No configuration is needed if you created all required classes, mainly Protocol class.
Hi Anton,
I have created all required classes like protocol and decoder and added port no in traccar.xml. but when I check on console
-- sudo netstat -ntlp | grep :5105
No any port is open or listening
but when I check for others like
-- sudo netstat -ntlp | grep :5103
It is showing like below
tcp6 0 0 :::5103 :::* LISTEN 22081/java
Why 5105 is not listening ?
Show me your code on GitHub or somewhere, but please don't paste the whole code here.
Protocol
public void initTrackerServers(List<TrackerServer> serverList) {
serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectDecoder", new TrackingpathProtocolDecoder(TrackingpathProtocol.this));
}
});
}
Decoder
private static final Pattern PATTERN = new PatternBuilder()
.text("$loc,")
.number("(d+),")
.number("(dd)(dd)(dd)(dd)(dd)(dd),")
.expression("([AV]),")
.number("(-?d+.d+),")
.expression("([NS]),")
.number("(-?d+.d+),")
.expression("([EW]),")
.number("(d+),")
.number("(d+.d+),")
.number("(d+),")
.number("(d+.d+),")
.expression("([01]+),")
.expression("([01]+),")
.expression("([01]+),")
.expression("([01]+),")
.expression("([01]+),")
.number("(d+),")
.number("(d+),")
.number("(d+.d+),")
.expression("([01]+)")
.expression("([+-]+)")
.compile();
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
////String msg="$loc,865879026779232,050916092132,A,28.601224,N,77.326833,E,
//033,53.150,09,192.20,0,0,0,0,0,0000,0944,0.0,0+";
Parser parser = new Parser(PATTERN, (String) msg);
if (!parser.matches()) {
return null;
}
Position position = new Position();
position.setProtocol(getProtocolName());
if (!identify(parser.next(), channel, remoteAddress)) {
return null;
}
position.setDeviceId(getDeviceId());
DateBuilder dateBuilder = new DateBuilder()
.setDate(parser.nextInt(), parser.nextInt(), parser.nextInt())
.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
position.setTime(dateBuilder.getDate());
position.setValid(parser.next().equals("A"));
String direction=null;
position.setLatitude(parser.nextDouble());
direction=parser.next();
position.setLongitude(parser.nextDouble());
direction+=parser.next();
//033,53.150,09,192.20,0,0,0,0,0,0000,0944,0.0,0+";
position.set(Event.KEY_DIRECTION, direction);
position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
position.setCourse(parser.nextDouble());
position.set(Event.KEY_SATELLITES, parser.nextInt());
position.set(Event.KEY_ALTITUDE, parser.nextInt());
position.set(Event.KEY_DBI1, parser.nextInt());
position.set(Event.KEY_DBI2, parser.nextInt());
position.set(Event.KEY_DBI3, parser.nextInt());
position.set(Event.KEY_DBI4, parser.nextInt());
position.set(Event.KEY_DBO1, parser.nextInt());
position.set(Event.KEY_FUEL, parser.nextDouble());
position.set(Event.KEY_BATTERY, parser.nextInt());
position.set(Event.KEY_FIRMWARE, parser.nextDouble());
position.set(Event.KEY_TAMPER, parser.nextInt());
position.set(Event.KEY_PACKET_LOC, parser.next());
return position;
}
I explicitly asked you not to post code here and you posted it here.
I need to see all the modifications that you did, including config file. PLEASE DON'T POST CODE HERE.
Hi Anton,
Really sorry,Please delete above post if possible.
Please have a look github link.
https://gist.github.com/amit22786/cf767acd6c457d9ad71917b5f95fc360
https://gist.github.com/amit22786/1e3abd2a63c78952eb69c99b8b178bd1
I added <entry key='trackingpath.port'>5128</entry> in traccar.xml
In the "TrackingpathProtocol" class you have uppercase "Trackingpath", but in the config you use lowercase "trackingpath".
r u talking about this super("Trackingpath"); ? Apart from this is everything ok ?
Hi Anton,
I have purchased a new GPS device from a local vendor, when I connected to Traccar server, getting data in ASCII format.
How can I add this in traccar server.