Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extended Info GPS103 #155

Closed
Jeferex opened this issue Mar 4, 2013 · 25 comments
Closed

Extended Info GPS103 #155

Jeferex opened this issue Mar 4, 2013 · 25 comments

Comments

@Jeferex
Copy link

Jeferex commented Mar 4, 2013

I've checked the code for GPS 103 protocol and I see there is a code to handle ALARM messages. But, in my installation, traccar don't store alarm messages and in my MySQL database, the positions table doesn't have any extended info column.

@tananaev
Copy link
Member

tananaev commented Mar 4, 2013

What about 'other' column?

@Jeferex
Copy link
Author

Jeferex commented Mar 4, 2013

I have 'other' column but it always stores NULL values.

@tananaev
Copy link
Member

tananaev commented Mar 4, 2013

That's a bug then, I forgot to change config. Try to use following in config:

    <entry key='database.insertPosition'>
        INSERT INTO positions (device_id, time, valid, latitude, longitude, altitude, speed, course, power, other)
        VALUES (:device_id, :time, :valid, :latitude, :longitude, :altitude, :speed, :course, :power, :extended_info);
    </entry>

@Jeferex
Copy link
Author

Jeferex commented Mar 4, 2013

I added that to config but now, it stores: <protocol>gps103</protocol><alarm>tracker</alarm>. It should store "tracker" only.

:D

@tananaev
Copy link
Member

tananaev commented Mar 4, 2013

Why do you think so? Now you should see alarm in tracker status.

@Jeferex
Copy link
Author

Jeferex commented Mar 4, 2013

I think there is another bug related. I did what you said and I added 'other' in config file. Then, I saw "<protocol>gps103</protocol><alarm>tracker</alarm>" be stored in 'other' column, but after that, in traccar web when I click on a device in device panel, It only shows device status for those that have 'NULL' value in 'other' column.

@Tucsondirect
Copy link

i am having this problem as well

@Tucsondirect
Copy link

Reslvoved Will upload my modifications for you to change

The modified code below is from the gps103 protocol in the source

@Tucsondirect
Copy link

package org.traccar.protocol;

import java.util.Calendar;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
import org.traccar.ServerManager;
import org.traccar.helper.Log;
import org.traccar.model.Position;

/**

  • Gps 103 tracker protocol decoder
    */
    public class Gps103ProtocolDecoder extends BaseProtocolDecoder {

    /**

    • Initialize
      */
      public Gps103ProtocolDecoder(ServerManager serverManager) {
      super(serverManager);
      }

    /**

    • Regular expressions pattern
      /
      static private Pattern pattern = Pattern.compile(
      "imei:" +
      "(\d+)," + // IMEI
      "([^,]+)," + // Alarm
      "(\d{2})(\d{2})(\d{2})\d+," + // Date
      "[^,]
      ," +
      "[FL]," + // F - full / L - low
      "(\d{2})(\d{2})(\d{2}).(\d{3})," + // Time (HHMMSS.SSS)
      "([AV])," + // Validity
      "(\d{2})(\d{2}.\d{4})," + // Latitude (DDMM.MMMM)
      "([NS])," +
      "(\d{3})(\d{2}.\d{4})," + // Longitude (DDDMM.MMMM)
      "([EW])?," +
      "(\d+.?\d_)," + // Speed
      "(\d+.\d+)?" + // Course
      "._");

    /**

    • Decode message
      */
      @OverRide
      protected Object decode(
      ChannelHandlerContext ctx, Channel channel, Object msg)
      throws Exception {

      String sentence = (String) msg;

      // Send response Just hello #1
      if (sentence.contains("##")) {
      channel.write("LOAD");
      return null;
      }

      // Send response Add enfora support #2
      if (sentence.length() == 15 && Character.isDigit(sentence.charAt(0))) {
      channel.write("ON");
      return null;
      }

      // Parse message
      Matcher parser = pattern.matcher(sentence);
      if (!parser.matches()) {
      Log.info("Parsing error");
      return null;
      }

      // Create new position
      Position position = new Position();
      StringBuilder extendedInfo = new StringBuilder("");

      Integer index = 1;

      // Get device by IMEI
      String imei = parser.group(index++);
      try {
      position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
      } catch(Exception error) {
      Log.warning("Unknown device - " + imei);
      return null;
      }

      // Alarm message
      // extendedInfo.append("This is a Prefix ");
      extendedInfo.append(parser.group(index++));
      // The below code is the Suffix i.e. "tracker 0.0% +0.0 Mode|Fuel%|Temp"
      extendedInfo.append(" Mode|Fuel%|Temp");

      // Date
      Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
      time.clear();
      time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++)));
      time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1);
      time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++)));

      // Time
      time.set(Calendar.HOUR, Integer.valueOf(parser.group(index++)));
      time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++)));
      time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++)));
      time.set(Calendar.MILLISECOND, Integer.valueOf(parser.group(index++)));
      position.setTime(time.getTime());

      // Validity
      position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false);

      // Latitude
      Double latitude = Double.valueOf(parser.group(index++));
      latitude += Double.valueOf(parser.group(index++)) / 60;
      if (parser.group(index++).compareTo("S") == 0) latitude = -latitude;
      position.setLatitude(latitude);

      // Longitude
      Double lonlitude = Double.valueOf(parser.group(index++));
      lonlitude += Double.valueOf(parser.group(index++)) / 60;
      String hemisphere = parser.group(index++);
      if (hemisphere != null) {
      if (hemisphere.compareTo("W") == 0) lonlitude = -lonlitude;
      }
      position.setLongitude(lonlitude);

      // Altitude
      position.setAltitude(0.0);

      // Speed
      position.setSpeed(Double.valueOf(parser.group(index++)));

      // Course
      String course = parser.group(index++);
      if (course != null) {
      position.setCourse(Double.valueOf(course));
      } else {
      position.setCourse(0.0);
      }

      // Extended info
      position.setExtendedInfo(extendedInfo.toString());

      return position;
      }

}

@Jeferex
Copy link
Author

Jeferex commented Mar 19, 2013

extended_info is OK as XML, but traccar_web has a bug about it.

@Tucsondirect
Copy link

@Jeferex you can replace your protocol source with the above posted and edit as you wish.....this will remove the xml tags and replace them with either nothing or whatever you want....

@Jeferex
Copy link
Author

Jeferex commented Mar 19, 2013

@Tucsondirect I understand but the problem is with traccar web. When I add other column to the config file, device panel in traccar web stop working. The points in the map move and that's ok but when i clic on a device in the device panel, the point doesn't get the focus and status panel doesn't show anything. That's the issue.

@tananaev
Copy link
Member

Problem in web interface will be fixed under traccar/traccar-web#45.

@tananaev
Copy link
Member

Jeferex, I tried extended XML data and it works fine for me. Can you provide all data of one row with non-empty 'other' field?

@Jeferex
Copy link
Author

Jeferex commented Apr 16, 2013

Anton, I am going to tell you what I did.

1.- I added 'other' field to the query.
2.- Restarted traccar.
3.- The tracker is OK. This is what i get in the DB. I am using MySQL.

id | address | altitude | course | latitude | longitude | other | power | speed | time | valid | device_id |
1956259 | NULL | 0 | 192.93 | -8.109515 | -79.0275666666667 | <protocol>gps103</protocol><alarm>tracker</alarm> | NULL | 3.63 | 2013-04-16 09:59:37 | 1 | 221 |

  1. I log in to traccar web, when I click on a device (that has the 'other' field filled) in the devices panel, it doesn't show anything on status panel and doesn't turn the point to green in the map.

5.- The other devices that have the 'other' field empty are normal. They show info on status panel and turn the point to green in the map.

@Tucsondirect
Copy link

I belive your bug was fixed

@Jeferex
Copy link
Author

Jeferex commented Apr 16, 2013

@Tucsondirect It is not solved yet. Anton opened another issue for this bug but I answered here because he asked me. =)

@tananaev
Copy link
Member

Maybe I already fixed it, I don't remember, but build from latest source code works fine with above data.

@Jeferex
Copy link
Author

Jeferex commented Apr 17, 2013

I am gonna wait for new release so I can see if it is working!

Thanks

@Tucsondirect
Copy link

Just compile the new source...

@Jeferex
Copy link
Author

Jeferex commented Jun 3, 2013

This is OK with GPS103 tracker.

What is the problem?? You don't want tracker to appear?

@robertoalmeida
Copy link

"I'm GPS103 device problem:

If I turn the key appears in other: acc on
If I turn off the key appears in other: acc off and after a few minutes with the key off and the vehicle stopped another record appears "tracker"

@robertoalmeida
Copy link

This record "tracker" is correct even with the car stopped and ignition off?

@Jeferex
Copy link
Author

Jeferex commented Jun 3, 2013

Yes, that is correct behavior. If you don't want tracker feature, you have to send a sms with: notn123456

@tananaev
Copy link
Member

tananaev commented Jun 3, 2013

@robertoalmeida, please create a new issue next time you have a question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants