Skip to main content
. 2024 Feb 23;24(5):1447. doi: 10.3390/s24051447
Algorithm 1 Firmware download and verification algorithm
  • 1:

    procedureDownloadAndVerifyFirmware(URL)

  • 2:

        expectedHashValueReceiveExpectedHashViaMQTT()

  • 3:

        firmwareDownloadFirmware(URL)

  • 4:

        allChunks[]

  • 5:

        while not EndOfFirmware(firmware) do

  • 6:

            chunkReadNextChunk(firmware, 4096)

  • 7:

            allChunks.append(chunk)

  • 8:

        end while

  • 9:

        completeFirmwareConcatenate(allChunks)

  • 10:

        hashValueCalculateHash(completeFirmware)

  • 11:

        if hashValue != expectedHashValue then

  • 12:

            throwVerificationError(“Hash MisMatch”)

  • 13:

        end if

  • 14:

        StoreInTemporaryDirectory(firmware)

  • 15:

    end procedure