nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches

◆ suit_dfu_fetch_source_request_fn

typedef int(* suit_dfu_fetch_source_request_fn) (const uint8_t *uri, size_t uri_length, uint32_t session_id)

Fetch source callback function.

Fetch source callbacks are registered via suit_dfu_fetch_source_register. Multiple such callbacks can be registered. The callbacks are called from inside the SUIT processor and should be blocking until the download process finishes. If a fetch source succeeds - the fetch operation is assumed to be completed successfully, the iteration over fetch sources stops and the processor continues processing the manifest sequence. If a fetch source fails and it did not provide data using suit_dfu_fetch_source_write_fetched_data or suit_dfu_fetch_source_seek APIs, the iteration over fetch sources continues, and the next callback is called. If the fetch source fails after providing data, the iteration over fetch sources stops and the result code is passed to the SUIT processor to handle the error code.

The role of the callback is to fetch data from the provided URI and pass it to SUIT via suit_dfu_fetch_source_write_fetched_data - the data does not have to be passed all at once, suit_dfu_fetch_source_write_fetched_data can be called multiple times as new chunks of data arrive. If the data needs to be written at some offset (e.g. if the chunks arrive out of order) suit_dfu_fetch_source_seek can be used to move the write pointer to the given offset.

It is up to the implementer of this callback how the URI is resolved and how the data is fetched. If the function fails to fetch the data from the given URI it must return a negative error code.

Note
The local fetch context should be bound to the session ID. It is possible that the fetch source will perform multiple downloads simultaneously.
Parameters
[in]uriURI from which the data should be fetched. Fetch source interprets it. In case if fetch source is unable to retrieve requested resource, i.e. due to unsupported protocol, it shall just fail, without any prior call to suit_dfu_fetch_source_write_fetched_data or suit_dfu_fetch_source_seek.
[in]uri_lengthLength of the URI, in bytes.
[in]session_idSession ID used by the fetch source manager. It shall be passed without modification to calls to suit_dfu_fetch_source_write_fetched_data and suit_dfu_fetch_source_seek made by this function.
Returns
0 on success - if fetching from the URI is possible and writing the data succeeded Negative error code otherwise (URI not found or other error).