Commit 218ac04c authored by Federico Sismondi's avatar Federico Sismondi

Fix for pushing locally collected fountain data when registers received from...

Fix for pushing locally collected fountain data when registers received from LoRa are corrupted or uses unexpected data format
parent 1126c3ca
...@@ -293,8 +293,10 @@ def get_values_from_raw_reading(message_data): ...@@ -293,8 +293,10 @@ def get_values_from_raw_reading(message_data):
else: else:
resp.append(None) resp.append(None)
app.logger.info("modbus / LoRa registers status : {}".format("{0:b}".format(int(status_registry, 16)))) app.logger.info("modbus registers bit status are {} and values are {}".format(
app.logger.info("modbus / LoRa registers values : {}".format(values_registry)) "{0:b}".format(int(status_registry, 16)),
values_registry)
)
# print("modbus / LoRa registers status : {}".format("{0:b}".format(int(status_registry, 16)))) # print("modbus / LoRa registers status : {}".format("{0:b}".format(int(status_registry, 16))))
# print("modbus / LoRa registers values : {}".format(values_registry)) # print("modbus / LoRa registers values : {}".format(values_registry))
...@@ -392,7 +394,12 @@ def _update_historical_db_from_local_raw_files(): ...@@ -392,7 +394,12 @@ def _update_historical_db_from_local_raw_files():
if not json_data['dataFrame'] or json_data['dataFrame'] == '': if not json_data['dataFrame'] or json_data['dataFrame'] == '':
print("(!) Warning found emtpy data frame from device {}".format(json_data['deveui'])) print("(!) Warning found emtpy data frame from device {}".format(json_data['deveui']))
try:
values = get_values_from_raw_reading(json_data['dataFrame']) values = get_values_from_raw_reading(json_data['dataFrame'])
except ValueError as e:
print("(!) Failed trying to parse file {}".format(json_file))
print("(!) Gotas frame data {}".format(json_data['dataFrame']))
continue # jump to next file
if len(values) == 1: # this is LoRa Device w/ the turbidity sensor if len(values) == 1: # this is LoRa Device w/ the turbidity sensor
entity = get_model_water_quality_observed( entity = get_model_water_quality_observed(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment