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

    Anyone have a reliable MQTT interface using PyCom?

    Scheduled Pinned Locked Moved MicroPython
    5 Posts 3 Posters 160 Views 4 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.
    • N Offline
      netskink
      last edited by

      I'm trying to use pycom for MQTT to GCP. I can't really make a reliable connection. In this screenshot, I show a long running exchange of messages with GCP, but once it fails bringing down the network interface and restarting still results in a crash. The umqtt.py and google_iot_core.py code which is from the pycom github is in play. I have filed issues with the files there and I have not gotten any response. I'm asking here again in hopes someone can advise if this is simply the expected behaviour.

      I have added a poll/select timeout on the mqtt socket read in umqtt.py. That is shown with the !!! in the debug log.

      Screenshot from 2020-07-12 09-43-56.png

      1 Reply Last reply Reply Quote 0
      • ahmadelmasriA Offline
        ahmadelmasri
        last edited by

        Hello @netskink,

        I recommend checking the new MQTT protocol which is more reliable.

        https://github.com/pycom/pycom-micropython-sigfox/tree/Dev/esp32/frozen/Pybytes

        files to check (work with):

        • mqtt.py
        • mqtt_core.py
        • msg_handl.py

        Best Regards,
        Ahmad EL Masri

        Ahmad EL Masri

        N 1 Reply Last reply Reply Quote 0
        • N Offline
          netskink @ahmadelmasri
          last edited by

          @ahmadelmasri Im using Google's IOT Core. Not pybytes.

          So only the umqtt.py file would apply to me. Just looking at the github, this code looks like it has tight coupling with pybytes and other unknown components.

          What is the deal with all these try exception blocks on imports? Is that so it can be run with regular python and micropython?

          try:
              from mqtt_core import MQTTCore as mqtt_core
          except:
              from _mqtt_core import MQTTCore as mqtt_core
          

          There is a subscribe method in _mqtt_core.py and a subscribe method in _mqtt.py How is this better?

          ahmadelmasriA 1 Reply Last reply Reply Quote 0
          • ahmadelmasriA Offline
            ahmadelmasri @netskink
            last edited by

            Hi @netskink,

            Yes this is part of Pybytes, but you can use the MQTT without integrating with pybytes, I mean you can use the library instead of umqtt.py

            In your case what you should use is only:

            • mqtt_core.py
            • msg_handl.py

            the try-catch is related to libraries under the "lib" folder and in the frozen zone. so if you are using your own firmware, you can just add the above files and ignore the try-catch or remove them. if you are using pybytes firmware, you can import mqtt.py or _mqtt.py and do subscribe, publish directly.

            Ahmad EL Masri

            B 1 Reply Last reply Reply Quote 0
            • B Offline
              BetterAuto Pybytes Beta @ahmadelmasri
              last edited by

              @ahmadelmasri said in Anyone have a reliable MQTT interface using PyCom?:

              Hi @netskink,

              Yes this is part of Pybytes, but you can use the MQTT without integrating with pybytes, I mean you can use the library instead of umqtt.py

              In your case what you should use is only:

              • mqtt_core.py
              • msg_handl.py

              the try-catch is related to libraries under the "lib" folder and in the frozen zone. so if you are using your own firmware, you can just add the above files and ignore the try-catch or remove them. if you are using pybytes firmware, you can import mqtt.py or _mqtt.py and do subscribe, publish directly.

              @ahmadelmasri I am trying this but it complains about missing arguments for MQTTClient, such as the mqtt_download_topic and pybytes_protocol. Do you have complete example code using the Pybytes MQTT library?

              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