traccar-client-android icon indicating copy to clipboard operation
traccar-client-android copied to clipboard

Option message MQTT

Open willguitaradmfar opened this issue 8 years ago • 9 comments

It would be very good to have a communication option via MQTT, as OwnTracks available in store. OwnTracks lets you configure the broker MQTT easy way, so we can generate actions with several other cloudIOT.

willguitaradmfar avatar Oct 17 '16 14:10 willguitaradmfar

You have to provide more details about what MQTT is, how it works, and what exactly you want to be implemented in Traccar Client.

tananaev avatar Oct 17 '16 20:10 tananaev

Here is a brief explanation of MQTT protocol. wiki

MQTT is a topic-based protocol of publications and subscriptions. IOT focused on architecture, is being very adopted in design with low network capacity.

MQTT provides reconnection when missed by a network problem, ideal for GSM / GPRS / 3G.

Basically, you implement a client that connects to a broker that will be set by the User in the same way that today we put the host and port of the server traccar.

When a MQTT client sends a packet to the broker, it is necessary to choose a topic for publication, this setting could be the user to configure.

When sending packets, you can set the flag to retain the broker keep the last package as information for a next customer to sign up and instantly know the current location of the device.

QoS is a means of informing the quality of the shipping package, 0, 1 or 2. In my opnion, can be configured by the user.

MQTT is designed to be very lightweight protocol intended for M2M communication (Machine to Machine), intended for low bandwidth and resources.

The Eclipse has a Paho library for android allows to use all the protocol benefits for android.

MQTT API - PAHO

This link contains example of easy use in android applications.

Eclipse also provides a public broker for testing:

iot.eclipse.org

The default port for MQTT 1883.

Proposal:

MQTT is present in almost all programming languages ​​enabling endless possibilities.

Imagine integration with IOT world where my automatic garage gate, which is controlled via MQTT by a device connected to the Internet, receive my phone location package to authorize the opening.

Or

Through the app (IoT MQTT Dashboard) available in Google Play, I know if my child arrived in school or location.

MQTT increases our chances of integration with the IOT world.

If possible this implementation combined with the hidden APK and running as a service in the mobile boot ... :) :)

willguitaradmfar avatar Oct 18 '16 13:10 willguitaradmfar

OK, so it's basically another communication protocol. I don't really want to complicate the app by including another protocol, but we can keep this feature request here in case more people request it and we decide to implement it.

tananaev avatar Oct 18 '16 20:10 tananaev

I also would love to have MQTT option.

albertusgeyser avatar Sep 07 '17 19:09 albertusgeyser

MQTT is very good, please be sure to support it!

langxj avatar Jun 07 '18 13:06 langxj

It could probably be done serverside by hooking up a "converter" to the events/api.

leifnel avatar Jul 19 '18 06:07 leifnel

I've made a small api to bridge any incoming OsmAnd HTTP post

http://myserver:5297/?id=123456789&timestamp=1702232117&lat=YY.YYYY&lon=Z.ZZZ066&speed=0.0&bearing=0.0&altitude=48.87311760736797&accuracy=100.0&batt=17.0

and just publish that to an MQTT topic that contains the ID and the payload for all data after the ID

topic: OsmAnd/{id} => OsmAnd/123456789 payload: timestamp=1702232117&lat=YY.YYYY&lon=Z.ZZZ066&speed=0.0&bearing=0.0&altitude=48.87311760736797&accuracy=100.0&batt=17.0

Which returns HTTP 202.

Ow, it also strips 0 values so that the payload is as small as possible.

I then have a consumer that splits the payload into other subtopics. Taking the above as an example:

topics

  • OsmAnd/{id}/timestamp
  • OsmAnd/{id}/lat
  • OsmAnd/{id}/lon
  • OsmAnd/{id}/speed
  • OsmAnd/{id}/bearing
  • OsmAnd/{id}/altitude
  • OsmAnd/{id}/accuracy
  • OsmAnd/{id}/batt

It's not ideal but works. I think this likely would be a better task for the Traccar server software to have this functionality. It would make real-time push based integrating with it:

I do found https://github.com/ivanfmartinez/ivanfm-traccar-mqtt which seems to do something similar and there also seems to be already some form of MQTT support in Traccar:

https://github.com/search?q=repo%3Atraccar%2Ftraccar+mqtt&type=pullrequests

ramonsmits avatar Dec 10 '23 19:12 ramonsmits

I think it would be more useful to have the client publish the data over mqtt, and then have a serverside "plugin" that subcribed to that topic and forwarded it to traccar.

Then other applications, for instance Home Assistant could also subscribe to the location.

leifnel avatar May 10 '24 00:05 leifnel

Traccar server can already publish data to MQTT.

tananaev avatar May 10 '24 00:05 tananaev