diff --git a/davis_decode.py b/davis_decode.py index cd09505..92ad2d2 100644 --- a/davis_decode.py +++ b/davis_decode.py @@ -34,10 +34,14 @@ def send_to_influx(host, port, db, user, password, davis_unit_id, wind, measurem try: return (True, urequests.post(post, data=data)) except Exception as e: + if e.args[0] == 103: + return (False, b"ERROR sending data to influx: {}".format(e.args)) machine.reset() else: - return (False, b"ERROR sending data to influx: {}".format(e)) + return (False, b"ERROR sending data to influx: {}".format(e.args)) + machine.reset() + return (False, b"ERROR - well fuck me, daisy") def raw_send_to_influx(host, port, db, user, password, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, rssi, lqi): post = "http://{}:{}/write?db={}".format(host, port, db) @@ -53,9 +57,12 @@ def raw_send_to_influx(host, port, db, user, password, b0, b1, b2, b3, b4, b5, b return (True, urequests.post(post, data=data)) except Exception as e: if e.args[0] == 103: + return (False, b"ERROR sending data to influx: {}".format(e)) machine.reset() else: return (False, b"ERROR sending RAW data to influx: {}".format(e)) + machine.reset() + return (False, b"ERROR - well fuck me, daisy") def reverseBits(data): data = "{:08b}".format(data) @@ -242,4 +249,3 @@ class davisDecoder(object): self.name = 'value' self.tags = {'type': 'rain_bucket_tips'} self.value = rain - diff --git a/main.py b/main.py index 6b867f8..05c4b44 100644 --- a/main.py +++ b/main.py @@ -35,7 +35,7 @@ while True: try: data_int = davis.rxPacket() except Exception as e: - raise e + #raise e print(b"Rx EXCEPTION: {}".format(e)) continue if data_int: @@ -82,8 +82,11 @@ while True: decoder.value, decoder.tags) except Exception as e: - raise e + #raise e print(b"ERROR: Data send 'urequest': {}".format(e)) + machine.reset() + #continue + gc.collect() try: (raw_sent_ok, raw_data_sent) = davis_decode.raw_send_to_influx( wifi_con._INFLUX_HOST, @@ -103,9 +106,12 @@ while True: data_int[9], davis.rssi, davis.lqi) + gc.collect() except Exception as e: - raise e + #raise e print(b"ERROR: Data send 'urequest': {}".format(e)) + machine.reset() + #continue if DEBUG: if sent_ok: