publish/subscribe without MQTT
-
Given one thread listening to a data feed and a (variable) number of threads listening to incoming TCP connection, how should I send the data feed to the TCP threads, and publish incoming data to all TCP listeners?
Ideally, I'd use a pub/sub pattern with 0MQ but that's not an option on Pycom devices.
MQTT is not an option unless I could run a broker on the device itself.
The device is networked but isolated from the internet, disqualifying the MQTT option.
Any ideas?
Background: a GPS receiver and an AIS receiver publish NMEA sentences (through I2C and UART), the NMEA sentences should be read by multiple instruments over WiFI on a boat.
-
On your network maybe you can install mosquitto on a local device for host the MQTT broker?
-
Good idea as such, however, I want to keep cost and complexity down.
Ended up reading from i2c and uart, accepting new tcp connection, adding new connection to a list (socket, address-port tuple)), looping through every tcp connection and sending the message. If sending fails, remove that particular (socket, addr) from list and close socket.
It works well, and all without threads.
It looks that the speed is good enough, and I'm not losing any packets.
Thanks!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login