From a5d91394e047e3fc469b220e2bb731859957be3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Kl=C3=BCnder?= Date: Wed, 4 Oct 2023 23:32:56 +0200 Subject: [PATCH] react to add destinations and remove destinations --- src/c3nav/mesh/consumers.py | 15 ++++++++++----- src/c3nav/mesh/messages.py | 2 -- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/c3nav/mesh/consumers.py b/src/c3nav/mesh/consumers.py index 1d3b9fe0..29f90f6d 100644 --- a/src/c3nav/mesh/consumers.py +++ b/src/c3nav/mesh/consumers.py @@ -83,6 +83,12 @@ class MeshConsumer(WebsocketConsumer): self.log_received_message(src_node, msg) + if isinstance(msg, messages.MeshAddDestinationsMessage): + self.add_dst_nodes(src_node.mac_addresses) + + if isinstance(msg, messages.MeshRemoveDestinationsMessage): + self.remove_dst_nodes(src_node.mac_addresses) + def mesh_uplink_consumer(self, data): # message handler: if we are not the given uplink, leave this group if data["name"] != self.channel_name: @@ -148,11 +154,10 @@ class MeshConsumer(WebsocketConsumer): self.dst_nodes.discard(address) # add the stuff to the db as well - # todo: can't do this because of race condition - # MeshNode.objects.filter(address__in=addresses, uplink_id=self.uplink_node.address).update( - # uplink_id=self.uplink_node.address, - # last_signin=timezone.now(), - # ) + # todo: shouldn't do this because of race condition? + MeshNode.objects.filter(address__in=addresses, uplink_id=self.uplink_node.address).update( + uplink_id=None, + ) def remove_route(self, route_address): MeshNode.objects.filter(route_id=route_address).update(route_id=None) diff --git a/src/c3nav/mesh/messages.py b/src/c3nav/mesh/messages.py index 401d1478..da238a1a 100644 --- a/src/c3nav/mesh/messages.py +++ b/src/c3nav/mesh/messages.py @@ -265,10 +265,8 @@ class ConfigFirmwareMessage(MeshMessage, msg_id=MeshMessageType.CONFIG_FIRMWARE) @classmethod def upgrade_json(cls, data): data = data.copy() # todo: deepcopy? - print(data) if 'revision' in data: data['revision_major'], data['revision_minor'] = data.pop('revision') - print(data) return data def get_chip_display(self):