Skip to content

Commit

Permalink
Bugfix: formatting fix, replaced envelope test
Browse files Browse the repository at this point in the history
  • Loading branch information
John Gorkos committed Nov 1, 2024
1 parent b71a1c2 commit cd0c19b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/mesh_persist/db_functions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Database Functions.
This module contains the database functions that store various types of
This module contains the database functions that store various types of
Meshtastic packets to the PostgreSQL database.
"""

Expand Down
10 changes: 7 additions & 3 deletions src/mesh_persist/mesh_persist.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def __init__(self) -> None:

def load_mqtt_config(self, filename: str = "mesh_persist.ini", section: str = "mqtt") -> dict:
"""Reads configfile configuration for mqtt server."""
self.logger.info("Reading config file...")
parser = ConfigParser()
parser.read(filename)

Expand All @@ -49,7 +48,6 @@ def load_mqtt_config(self, filename: str = "mesh_persist.ini", section: str = "m
self.logger.fatal(err)
sys.exit(1)

self.logger.info("Read config file.")
return config

def on_message( # noqa: C901
Expand All @@ -61,7 +59,13 @@ def on_message( # noqa: C901
) -> None:
"""Callback function when message received from MQTT server."""
service_envelope = mqtt_pb2.ServiceEnvelope()
if service_envelope is None:
if service_envelope is not None:
try:
se = service_envelope.ParseFromString(message.payload)
except (DecodeError, Exception):
self.logger.exception("Exception in initial Service Envelope decode")
return
else:
return

msg_pkt = service_envelope.packet
Expand Down

0 comments on commit cd0c19b

Please sign in to comment.