PyGate - Recommended error handling techniques
-
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
-
@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 :)
-
@kodarn I think you question is still relevant, and nobody replied. Did you make any progress?
-
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.
-
@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.
-
This post is deleted!
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