Simpified version of MQTT over UDP: Network is broker!
Note other repo: https://gitverse.ru/dzavalishin/mqtt_udp
See Russian version / Русская версия здесь
MQTT is a cute simple protocol well suited for IoT and similar things.
But it can be even simpler and still be very usable: MQTT/UDP is merely an MQTT Publish packets broadcast over an UDP.
Feel free to:
It is really easy.
This repository contains tools to support MQTT/UDP integration and test:
Send data:
import mqttudp.engine
if __name__ == "__main__":
mqttudp.engine.send_publish( "test_topic", "Hello, world!" )
Listen for data:
import mqttudp.engine
def recv_packet(ptype,topic,value,pflags,addr):
if ptype != "publish":
print( ptype + ", " + topic + "\t\t" + str(addr) )
return
print( topic+"="+value+ "\t\t" + str(addr) )
if __name__ == "__main__":
mqttudp.engine.listen(recv_packet)
Download pypi package
Send data:
PublishPacket pkt = new PublishPacket(topic, value);
pkt.send();
Listen for data:
PacketSourceServer ss = new PacketSourceServer();
ss.setSink( pkt -> { System.out.println("Got packet: "+pkt); });
Download JAR
Send data:
int rc = mqtt_udp_send_publish( topic, value );
Listen for data:
int main(int argc, char *argv[])
{
...
int rc = mqtt_udp_recv_loop( mqtt_udp_dump_any_pkt );
...
}
int mqtt_udp_dump_any_pkt( struct mqtt_udp_pkt *o )
{
printf( "pkt %x flags %x, id %d",
o->ptype, o->pflags, o->pkt_id
);
if( o->topic_len > 0 )
printf(" topic '%s'", o->topic );
if( o->value_len > 0 )
printf(" = '%s'", o->value );
printf( "\n");
}
Send data:
local mq = require "mqtt_udp_lib"
mq.publish( topic, val );
Listen for data:
local mq = require "mqtt_udp_lib"
local listener = function( ptype, topic, value, ip, port )
print("'"..topic.."' = '"..val.."'".." from: ", ip, port)
end
mq.listen( listener )
Download LuaRock
There is a Go language implementation, see lang/go for details