Skip to content

Commit

Permalink
Add test to handle wrong topic format
Browse files Browse the repository at this point in the history
An associated test should be done on the gateway to not generate such topic
  • Loading branch information
GwendalRaoul committed Apr 24, 2023
1 parent 204346b commit 911162f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions wirepas_mqtt_library/wirepas_network_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,14 @@ def _on_data_received(self, client, userdata, message):
data = wmm.ReceivedDataEvent.from_payload(message.payload)
if data.network_address is None:
# Network id is from topic
_, _, network_address, _, _ = TopicParser.parse_received_data_topic(message.topic)
data.network_address = network_address
try:
_, _, network_address, _, _ = TopicParser.parse_received_data_topic(message.topic)
data.network_address = network_address
except ValueError:
logging.error("Cannot determine network address from topic: %s",message.topic)
# Address is unknown but still dispatch data
data.network_address = None

self._task_queue.add_task(self._dispatch_uplink_data, data)
except wmm.GatewayAPIParsingException as e:
logging.error(str(e))
Expand Down

0 comments on commit 911162f

Please sign in to comment.