@@ -67,6 +67,7 @@ def check_tb_paho_mqtt_installed():
6767FW_CHECKSUM_ALG_ATTR = "fw_checksum_algorithm"
6868FW_SIZE_ATTR = "fw_size"
6969FW_STATE_ATTR = "fw_state"
70+ FW_ERROR_ATTR = "fw_error"
7071
7172REQUIRED_SHARED_KEYS = f"{ FW_CHECKSUM_ATTR } ,{ FW_CHECKSUM_ALG_ATTR } ,{ FW_SIZE_ATTR } ,{ FW_TITLE_ATTR } ,{ FW_VERSION_ATTR } "
7273
@@ -532,6 +533,7 @@ def __init__(self, host, port=1883, username=None, password=None, quality_of_ser
532533 "current_" + FW_TITLE_ATTR : "Initial" ,
533534 "current_" + FW_VERSION_ATTR : "v0" ,
534535 FW_STATE_ATTR : TBFirmwareState .IDLE .value ,
536+ FW_ERROR_ATTR : ""
535537 }
536538 self .__request_id = 0
537539 self .__firmware_request_id = 0
@@ -554,6 +556,10 @@ def update_firmware_info(self, title = None, version = None, state: TBFirmwareSt
554556
555557 if state is not None :
556558 self .current_firmware_info [FW_STATE_ATTR ] = state .value
559+ if state is TBFirmwareState .FAILED and error is not None :
560+ self .current_firmware_info [FW_ERROR_ATTR ] = error
561+ else :
562+ self .current_firmware_info [FW_ERROR_ATTR ] = ""
557563
558564 self .send_telemetry (self .current_firmware_info )
559565
@@ -796,7 +802,7 @@ def __process_firmware(self):
796802 sleep (1 )
797803 else :
798804 log .debug ('Checksum verification failed!' )
799- self .update_firmware_info (state = TBFirmwareState .FAILED )
805+ self .update_firmware_info (state = TBFirmwareState .FAILED , error = "Checksum verification failed!" )
800806 self .__request_firmware_info ()
801807 return
802808 self .firmware_received = True
0 commit comments