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.
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.
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.
On your network maybe you can install mosquitto on a local device for host the MQTT broker?