Function anj_coap_downloader_start

Function Documentation

int anj_coap_downloader_start(anj_coap_downloader_t *coap_downloader, const char *uri, const anj_net_config_t *net_config)

Starts a new download operation.

This function can only be called when no other download is ongoing or suspended in the same downloader instance.

Warning

The URI is not copied or stored internally by the CoAP downloader, so the pointer must remain valid throughout the entire download process.

Parameters:
  • coap_downloader – CoAP downloader state.

  • uri – URI of the resource to download. The string must be null-terminated.

  • net_config – Optional network configuration to use for the connection. Can be NULL for non-secure CoAP. Object pointed to by this pointer can be freed after this function returns, as it is copied internally.

Returns:

0 on success, ANJ_COAP_DOWNLOADER_ERR_INVALID_URI if the provided URI is invalid or unsupported. ANJ_COAP_DOWNLOADER_ERR_IN_PROGRESS if another download is ongoing or suspended. ANJ_COAP_DOWNLOADER_ERR_INVALID_CONFIGURATION if provided net_config is NULL while uri indicates secure CoAP.