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

How to integrate GPS tracker to SiteWhere? #49

Closed
anhdenday opened this issue Aug 3, 2016 · 4 comments
Closed

How to integrate GPS tracker to SiteWhere? #49

anhdenday opened this issue Aug 3, 2016 · 4 comments

Comments

@anhdenday
Copy link

Hi @derekadams,

As I see in Web Admin, SiteWhere support to connect to GPS tracker something like MeiTrack GPS device!!!
Could you please tell me how to connect it to SiteWhere? So that I can get lat, long from it!
Because As I see it's doesn't have the OS. So I could not use the provided Agent! Please give me an advice!
Thanks you so much

@derekadams
Copy link
Member

Hi @anhdenday,

We have done testing with MeiTrack GPS devices in the past, but there are no examples in the current code base. The general idea is to use a socket event receiver to handle receiving and parsing payloads sent directly to SiteWhere from the device. An example of the general technique is shown in this GitHub repository:

https://github.com/sitewhere/sitewhere-examples/tree/master/socket-event-source/groovy-socket-decoder

Note that the device must be configured to report to the SiteWhere host/port you have set up in the event source. The device will connect via TCP/IP and send a command payload. SiteWhere can parse the command via Groovy script and optionally carry on a conversation with the device before terminating the connection.

Let me know if you have any questions.

Regards,
Derek

@anhdenday
Copy link
Author

anhdenday commented Aug 4, 2016

Thanks you for your reply @derekadams ,
I understood the general idea , In fact I don't have MeiTrack GPS device yet therefore I could not test with It.
Actually I want to buy this one for car tracker: TK207 OBD gps gsm gprs car tracker Quad Band Anti-theft GSM/GPRS Mini GPS Tracker Tracking OBD II Quad Band Anti-theft
The parameter I want to parse it is not only the location (lat, long), it's include speed, gasoline, temporary, battery status...
So that if I want to get these parameters I will implement it as following. Please correct me if something is wrong?

Map<String, Double> measurementsPart = new HashMap<String, Double>();
measurementsPart.put("speed", part[4] );
measurementsPart.put("gasoline", part[5] );
......
def measurements = new DeviceMeasurementsCreateRequest()
measurements.setMeasurements(measurementsPart);
......

Assuming that part[4], part[5]... is parameter that I parse from the payload

def message = new String(payload);
def parts = message.split(","); 

Of course, following your recommendation, it's just only the idea that I will do, Actually I dont have the device yet.

Thanks you so much

@derekadams
Copy link
Member

You will need to download the operation manual for the device and confirm how it connects and what the message payloads look like. Most of these types of devices use similar payloads, but each has its own nuances. Once you have the device and point it to SiteWhere, you should be able to see what it sends and update the script accordingly.

@anhdenday
Copy link
Author

Yes, my example code is assuming that the format of message payloads is look like the message payloads in GitHub repository like that you already mentioned above.
I will order one device and check the manual how it connects then try to point to sitewhere and will update the script to match the real message payload format.

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

2 participants