Using Traccar client with my own server

calast7 years ago

I am interested in using Traccar Client in a somewhat different way from what most people probably do, and would like some feedback on feasibility.

At present, we are using a system that is based on a client that is unfortunately no longer supported and thus has some compatibility problems with recent versions of Android. In simple terms, the system consists of two parts – a producer (that produces time and position info and stores it in a pseudo-database on our web server) and a consumer, that periodically reads that database and does something useful based on built-in rules. The consumer app is not of interest here, but we need to collect and store data.

The way we acquire data is to use a controller (in the model-view-controller sense) that runs on our server. The phone app we were using simply uses HTTP POST to send information to the controller. Our old app would let you specify any URL and sent data like this:

http://my.url?time=12:34.56&latitude=43.567&longitude=123.456

That is a bit of an oversimplification, since it really sent several data points at once (latitude1, latitude2, ...) and had an argument for the number of data points it was sending. But you get the idea, I am sure. It is a very minimal protocol, if that term even fits - which is what we like about it.

The controller acts as an event handler for such requests, converting them to our format and storing them according to a set of built-in rules. Since the phone app knows the URL, it just sends one or more data points – which triggers the handler.

Ideally, I could modify the controller to accept data in whatever form Traccar Client likes to send them. But I have no real interest in Traccar Server, since we already have a server that does what our system needs it to do. So, a number of questions:

  1. Does Traccar Client just post data points, like our present phone app? In other words, can it use HTTP POST to send points to a customer-provided URL?
  2. In what format does it send the data?
  3. Would it be confused by not talking to its own server, because it expects some response that we might forget to provide? Is there documentation on all the messages that go back and forth between the client and server so we could at least try?
  4. What else am I forgetting to ask?

So, has anyone tried this sort of thing (writing your own server)? If so, how well did it work?

Disclaimer: my expertise is in writing database-driven web apps (and other things even less applicable) and I know very little about how GPS really works.

Thanks in Advance,
Ken Greenberg

Anton Tananaev7 years ago
  1. Currently it uses GET request, but it's easy to change it to POST. It sends to the root path of the server, but it's also easy to change as well.

  2. Similar to your one:

https://www.traccar.org/osmand/

  1. It's a standard HTTP protocol, so standard OK response is expected by the app.
calast7 years ago

Thanks, that is very helpful. GET is fine, and it would be easy to change the software at my end to do this. I can just switch over to OsmAnd quite easily.

My question is: Is changing protocols something that is done at run time (via settings or some other configuration method), or do I have to rebuild the app to use a different protocol? I do have an Android IDE around here somewhere, but I would have to retrain myself on how to use it.

Thanks,
Ken

Anton Tananaev7 years ago

Traccar Client only supports one protocol. If you want to change it, you would have to modify the source code.

calast7 years ago

Sorry. I guess I am getting slightly confused by the term protocol in the documentation. As I said, my expertise is in writing database-driven web apps, and I have no idea how GPS works other than that it sends time and position info.

In the documentation here:
https://www.traccar.org/devices/
There is a list of devices and protocols. In the OsmAnd web page referenced in your first answer, it states:
New versions of Traccar Client use this protocol to report GPS data to the server side.

So, is this a different use of the term "protocol?" Really, if OsmAnd is the default way that the app running on a phone sends position data, then I am happy to use it and it would not seem that I have to change anything. Of course, I have to tell it the URL of where I want the data sent. Am I correct in assuming that this is something you simply set on the phone? E.g., change http://demo.traccar.org:5055 to http://www.calast.com/wsm/controllers/postPositions.php or something like it.

Thanks,
Ken (who does not own a smartphone and so cannot test this)

Anton Tananaev7 years ago

Older versions of Traccar Client use different protocol. Newer versions use OsmAnd.

The app always uses root path. So, if you want to specify path, you would have to modify the source code.

calast7 years ago

Thanks. The company owner noted that when he tried to specify a path:

it always reverts to the default of demo.traccar.org. No error message no explanation.

I like what your product does, but we will pursue another solution. May I suggest that you allow people to specify paths as part of run-time configuration going forward? Everyone cannot deal with the "root only" restriction, especially if you are not running the server on your own machine. Also, other apps allow this.

Best,
Ken

Anton Tananaev7 years ago

It reverts if you try to enter invalid host address.

For any feature suggestions, please use GitHub.