react to add destinations and remove destinations

This commit is contained in:
Laura Klünder 2023-10-04 23:32:56 +02:00
parent d4c5fbefd9
commit a5d91394e0
2 changed files with 10 additions and 7 deletions

View file

@ -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)

View file

@ -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):