Catch value errors
This commit is contained in:
parent
435e1ace2c
commit
114c754900
1 changed files with 18 additions and 12 deletions
|
@ -21,14 +21,17 @@ import lorautil
|
||||||
# sodaq: lat=46.9699219 lon=9.0391764
|
# sodaq: lat=46.9699219 lon=9.0391764
|
||||||
# google: 46.969943, 9.038999
|
# google: 46.969943, 9.038999
|
||||||
|
|
||||||
known_devices = [ "0018B20000000C58", "0018B20000000C37", "0018B20000000C59", "0018B20000000CD0" ]
|
log = logging.getLogger("adeunis")
|
||||||
|
log.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
known_devices = [ "0018B20000000C58", "0018B20000000C37", "0018B20000000C59", "0018B20000000CD0" ]
|
||||||
|
|
||||||
def get_gps(deveui, payload):
|
def get_gps(deveui, payload):
|
||||||
res = []
|
res = []
|
||||||
if not int(payload[0:2], 16) & (2**7):
|
if not int(payload[0:2], 16) & (2**7):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
try:
|
||||||
lat_deg = float(payload[4:6])
|
lat_deg = float(payload[4:6])
|
||||||
lat_min = float(payload[6:8])
|
lat_min = float(payload[6:8])
|
||||||
lat_sec = float(payload[8:10])
|
lat_sec = float(payload[8:10])
|
||||||
|
@ -43,6 +46,9 @@ def get_gps(deveui, payload):
|
||||||
|
|
||||||
pos = ":lat={:.6f} long={:.6f}".format(lat, long)
|
pos = ":lat={:.6f} long={:.6f}".format(lat, long)
|
||||||
|
|
||||||
|
except ValueError as e:
|
||||||
|
log.info("GPS decode error: {}:{} {}".format(deveui, payload, e))
|
||||||
|
|
||||||
res = [ deveui + pos ]
|
res = [ deveui + pos ]
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
Loading…
Add table
Reference in a new issue