gps emulation

Dale Wheeler4 years ago

I have written a c++ program that simulates gps 'motion'. It outputs gps coordinates in decimal format (New York City would be 40.74194444,-73.59888888 for instance) but could be modified to output in any of the standard gps formats. When the program runs, it increments the gps location at a rate and direction that is set by controls in the program. I can set the program up to talk to a computer port via local host. My question is, can I input this data into Traccar in order to see a moving map of the 'track' of the emulator? Is there already a method for doing this?

Anton Tananaev4 years ago
Dale Wheeler4 years ago

Thanks! I'm not fluent in python, but might be able to decipher enough to get my program set up. Do you know if there is a video showing this program working? I really don't want to load java on my computer and would like to see it working before doing so.

Anton Tananaev4 years ago

You can use any of the demo servers.

Dale Wheeler4 years ago

Thanks again.

Dale Wheeler4 years ago

Using the python script you referred me to, I have made changes to my emulator in an attempt to use it with Traccar, and have not been successful. I am using an ID of 123456, and have also tried the ID referred to in the sctipt of 123456789012345. It is connecting to localhost port 5055 and sends the following data:

40.74194760,-73.59888454,45,25,Normal,True,Low,2100,90,123456

Traccar logs show the following:

2020-01-15 13:51:12  INFO: [68ca188f] connected
2020-01-15 13:51:13  INFO: [68ca188f: osmand < 0:0:0:0:0:0:0:1] HEX: 34302e37343139343934302c2d37332e35393838383238332c34352c32352c4e6f726d616c2c547275652c4c6f772c323130302c39302c313233340d0a
2020-01-15 13:51:13  INFO: [68ca188f: osmand > 0:0:0:0:0:0:0:1] HEX: 485454502f312e31203430302042616420526571756573740d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
2020-01-15 13:51:13  INFO: [68ca188f] disconnected

I also listen for a response from Traccar and receive the following:

HTTP/1.1 400 Bad Request
content-length: 0

Is this enough information to help me find why it is not working?

Anton Tananaev4 years ago

OsmAnd is an HTTP based protocol.

Dale Wheeler4 years ago

What should I be using instead?

Dale Wheeler4 years ago

What protocol should I be using?

Dale Wheeler4 years ago

I misunderstood your previous reply and now know what protocol to use. However, I have been unable to write a c++ program that inputs sequential osmand packets into tracar. I can write a one time packet by using localhost:5055. Tracar reads the packet and plots a map location. BUT this also opens an additional page in my browser. When I write another packet to localhost, it opens another browser page and plots the new location on traccar. I can not write the packets directly to the traccar host without opening a new browser page.

Are you aware of how to do this with c++?

Anton Tananaev4 years ago

None of what you said makes any sense to me. What browser page does it open? Are you calling browser from C++ code?

Dale Wheeler4 years ago

I only know of 2 ways to open localhost from c++ (I'm using qt c++). One is by opening a browser page. This is the only way I have been able to get traccar to correctly read a packet. The other way to connect to localhost is by using a socket. When sending data using socket, it uses 3 types of encoding; local8bit, utl8, or latin1. QT will not send a string through the socket unless it is encoded with one of these. When I use any of these encoding methods, traccar will not decode the string. The log above shows what it reports.

Anton Tananaev4 years ago

Opening a page is definitely the wrong way to go. You should be using something like QNetworkRequest to send a proper HTTP request.