Using Android-Tablet as an MQTT-Server

别来无恙 提交于 2019-12-19 11:23:06

问题


I have read something about "messaging system" using the MQTT protocol. But i was always reading about the constellation: using Android as a MQTT-Client and a MQTT-Server which is not installed on a Android smartphone oder tablet (but as a standalone server).

Is it possible to use one Android-Tablet as a MQTT-Server and some other Android-Tablets (for example 5 Tablets) as MQTT-Clients??

And if this is possible, is it possible to use the one Android-Tablet which is a MQTT-Server, also as a MQTT-Client?

The communication between the Android-MQTT-Server-Tablet and the other tablets as MQTT-Client, should work over an WIFI-Router / WIFI-Access-Point.

Thank you in advance for helping.


回答1:


It is possible to use tablets as mqtt brokers (server) and mqtt clients. You'll have to use a client library on all tablets and a broker on one of them.

Here is pure java broker I have adapted to work on Android: https://github.com/interaktionsbyran/moquette Feel free to try it out!




回答2:


It's perfectly possible.

The hard bit would be working out which tablet would become the broker. One approach would be to use avahi (mDNS) to try and discover a broker, if none are found then set one up and advertise it via avahi.

As for actually finding a broker that will run on Android that would be anther challenge. I'm not aware of a public pure Java broker available, but you may be able to get mosquitto to compile as a native (arm) Android app, but you would need to write a service wrapper for it.



来源:https://stackoverflow.com/questions/19114730/using-android-tablet-as-an-mqtt-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!