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

    PyGate - Recommended error handling techniques

    Scheduled Pinned Locked Moved Discussion
    6 Posts 6 Posters 122 Views 7 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.
    • kodarnK Offline
      kodarn
      last edited by kodarn

      Hi guys!

      I received my PyGate today and have started to read up on things.

      My scenario will be a GPY on the PyGate-board, with a WiFi (external) antenna proxying packets from/to The Things Network (TTN). That is, not using the PoE expansion board.

      When looking at the documentation (https://docs.pycom.io/tutorials/pygate/) there seems to a lack of error handling... Are there any examples of how to handle these kind of errors:

      • Reconnecting to WiFi of the local network glitches
      • Reconnecting to TTN if the WiFi goes down

      Or is this already taken care of "under the hood"?

      Regards

      D 1 Reply Last reply Reply Quote 2
      • D Offline
        d.alvrzx @kodarn
        last edited by d.alvrzx

        @kodarn Received my Pygate recently as well. I think there is still a big lack of documentation and tutorials for the Pygate. Too bad no one answered this thread. I'm hoping things get better as time passes :)

        1 Reply Last reply Reply Quote 1
        • J Offline
          jand
          last edited by jand

          @kodarn I think you question is still relevant, and nobody replied. Did you make any progress?

          1 Reply Last reply Reply Quote 1
          • F Offline
            firemonkey
            last edited by

            While configuring the PyGate I used the following code to make it re-connect to wifi network.

            import _thread
            from network import WLAN
            import time
            
            wlan = WLAN(mode=WLAN.STA)
            wlan.antenna(WLAN.EXT_ANT)
            
            def wifi_monitor(delay, id):
                while True:
                    if not wlan.isconnected():
                        wlan.connect(ssid='AP_NAME', auth=(WLAN.WPA2, "AP_PASSWORD"))
                        while not wlan.isconnected():
                            time.sleep(2)
                            print("Waiting for wifi to connect")
                        print("wifi connection complete!")
                    time.sleep(20)
            
            _thread.start_new_thread(wifi_monitor, (1, 2))
            time.sleep(20)
            

            The idea was to have a dedicated thread monitor if wifi is connected, and if not it would re-connect. The sleep timers selected are arbitrary.

            I wrote it due to the PyGate consistently losing wifi connection when running for longer than a day. Using this code it ran for months without any issues.

            Hope this helps.

            M 1 Reply Last reply Reply Quote 1
            • M Offline
              Matt Walter @firemonkey
              last edited by Matt Walter

              @firemonkey Did you have success with this? I'm having issues where the pygate drops off the network (usually when the router loses power) and it never reconnects.

              1 Reply Last reply Reply Quote 0
              • S Offline
                solega bardine Banned
                last edited by solega bardine

                This post is deleted!
                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