NordicSemiconductor / IOS-nRF-Connect-Device-Manager

A mobile management library for devices supporting nRF Connect Device Manager.
https://www.nordicsemi.com/Software-and-tools/Software/nRF-Connect-SDK
Apache License 2.0
91 stars 41 forks source link

How to calculate hash for FirmwareUpgradeManager? #195

Closed sjmerelglobus closed 6 months ago

sjmerelglobus commented 8 months ago

The FirmwareUpgradeManager.start() method now takes a hash parameter, but it's not explained in the README what kind of hash is expected or how best to calculate it.

philips77 commented 8 months ago

Use the following code to get the hash:

let hash = try McuMgrImage(data: image.data).hash

Before it was done under the hood, but as support for SUIT files was added, where hash is encoded as CBOR, hash is to be given explicitly. We may think of adding extension helper methods.

@dinesharjani What do you think?

philips77 commented 8 months ago

FYI: https://github.com/NordicSemiconductor/IOS-nRF-Connect-Device-Manager/pull/183

nysander commented 7 months ago

thanks but this should be somewhere documented

philips77 commented 7 months ago

Right.

@dinesharjani, why is the has given as a separate parameter? For the sake of SUIT files? They also have the hash inside.

dinesharjani commented 7 months ago

@nysander you are correct. I hope I can get to it today.

As for why, it's because since nRF Connect uses this API, I found that making the hash "magic" made everything more complicated. Also, you can see how the hash should be calculated in the Example app for now. But yes, I should fix the README.

nysander commented 7 months ago

thanks

issue here is that we are not using native envelope but download image data by ourselves and then upload it to the device, so the alternate method to getting hash was missing.

dinesharjani commented 6 months ago

Readme updated.