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