board boots with target firmware? OTA success!

This commit is contained in:
Laura Klünder 2023-11-30 22:45:53 +01:00
parent 7401c00216
commit faad19f5a5
2 changed files with 6 additions and 4 deletions

View file

@ -17,7 +17,7 @@ from django.utils import timezone
from c3nav.mesh import messages
from c3nav.mesh.messages import (MESH_BROADCAST_ADDRESS, MESH_NONE_ADDRESS, MESH_ROOT_ADDRESS, OTA_CHUNK_SIZE,
MeshMessage, MeshMessageType)
from c3nav.mesh.models import MeshNode, MeshUplink, NodeMessage, OTAUpdate, OTAUpdateRecipient
from c3nav.mesh.models import MeshNode, MeshUplink, NodeMessage, OTAUpdate, OTAUpdateRecipient, OTARecipientStatus
from c3nav.mesh.utils import MESH_ALL_UPLINKS_GROUP, UPLINK_PING, get_mesh_uplink_group
from c3nav.routing.rangelocator import RangeLocator
@ -374,8 +374,10 @@ class MeshConsumer(AsyncWebsocketConsumer):
print('current app desc:', current_app_desc)
if target_app_desc == current_app_desc:
print('the node already has this firmware, awesome')
# todo: do something with this information
recipient = False
await OTAUpdateRecipient.objects.filter(pk=recipient.pk).aupdate(
status=OTARecipientStatus.SUCCESS
)
recipient = None
else:
print('app desc does not match')

View file

@ -79,7 +79,7 @@ class MeshNodeQuerySet(models.QuerySet):
)
return clone
def prefetch_firmwares(self, *types: MeshMessageType):
def prefetch_firmwares(self):
clone = self.prefetch_last_messages(MeshMessageType.CONFIG_FIRMWARE,
MeshMessageType.CONFIG_HARDWARE)
clone._prefetch_firmwares = True