blubb bloobb

This commit is contained in:
Laura Klünder 2023-12-01 15:19:51 +01:00
parent e295c62757
commit bef3db6841
2 changed files with 18 additions and 3 deletions

View file

@ -242,10 +242,19 @@ class MeshConsumer(AsyncWebsocketConsumer):
update_id = node_status.ota_recipient.update_id if node_status.ota_recipient else 0
if update_id == msg.update_id:
print('start/cancel confirmed!')
node_status.waiting_for = NodeWaitingFor.NOTHING # todo: probably good to continue from here
node_status.waiting_for = NodeWaitingFor.NOTHING
if update_id:
print('queue chunk sending')
await self.ota_set_chunks(node_status.ota_recipient.update, min_chunk=msg.highest_chunk+1)
if msg.status.is_failed:
print('ota failed')
node_status.ota_recipient.status = OTARecipientStatus.FAILED
await node_status.ota_recipient.send_status()
await OTAUpdateRecipient.objects.filter(pk=node_status.ota_recipient.pk).aupdate(
status=OTARecipientStatus.SUCCESS
)
node_status.ota_recipient = None
else:
print('queue chunk sending')
await self.ota_set_chunks(node_status.ota_recipient.update, min_chunk=msg.highest_chunk+1)
if isinstance(msg, messages.OTARequestFragmentsMessage):
print('got OTA fragment request', msg)
@ -374,6 +383,8 @@ 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')
recipient.status = OTARecipientStatus.SUCCESS
await recipient.send_status()
await OTAUpdateRecipient.objects.filter(pk=recipient.pk).aupdate(
status=OTARecipientStatus.SUCCESS
)

View file

@ -286,6 +286,10 @@ class OTADeviceStatus(EnumSchemaByNameMixin, IntEnum):
def pretty_name(self):
return self.name.replace('_', ' ').lower()
@property
def is_failed(self):
return self >= self.START_FAILED
@dataclass
class OTAStatusMessage(MeshMessage, msg_type=MeshMessageType.OTA_STATUS):