Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    publish/subscribe without MQTT

    Scheduled Pinned Locked Moved MicroPython
    pubsub
    3 Posts 2 Posters 951 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      antigraviton
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • T Offline
        thibault
        last edited by

        On your network maybe you can install mosquitto on a local device for host the MQTT broker?

        1 Reply Last reply Reply Quote 0
        • A Offline
          antigraviton
          last edited by

          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!

          1 Reply Last reply Reply Quote 0

          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
          • 1 / 1
          • First post
            Last post

          Pycom on Twitter

          Pycom