where does Download_client save data?

Hi,

This seems like a silly question and feels like I am the only one who doesn't know since no one asked this before.

I want to use the download_client to download a large file (>120Kb) throught http/https. I tried with a sample URL and the file download worked as I see the status being printed when using the download_client sample. The problem is I cannot figure out where the downloaded file is saved and how to retreive the downloaded data.

Since it is a big file, it cannot be in the Ram so i am guessing it is being written somewhere in flash.

Secondly, one of our file download api on the server request a HTTP POST request. How can I modify the download_client code to send out http post request?

Regards

Noaman

  • Hello  Noaman, 

    Due to Christmas Holidays our team is lower staffed than normal and some delays in our answers must be expected. We apologize for the inconvenience.


    I will look into this issue. I hope to have an answer by tomorrow. 

    Kind regards,
    Øyvind

  • Thank you Oyvind!

    Happy Holidays and Happy New Year

  •  Hi Noaman, 

    My apologies for the late response. 

    Documentation for the download_client can be found in the Download Client library or in the SDK under nrf\include\net\download_client.h.

    The download_client will receive fragments via DOWNLOAD_CLIENT_EVT_FRAGMENT, once download is complete the application will receive a DOWNLOAD_CLIENT_EVT_DONE.

    Looking at the nRF9160: Download client sample (nrf\samples\nrf9160\download\src\main.c), you can see how this sample handles downloaded fragments under the "callback" function.

    case DOWNLOAD_CLIENT_EVT_FRAGMENT:
    		downloaded += event->fragment.len;
    		if (file_size) {
    			progress_print(downloaded, file_size);
    		} else {
    			printk("\r[ %d bytes ] ", downloaded);
    		}

    Here you can see that this is downloaded to static uint_t downloaded

    From here it is the user's responsibility to copy the received fragments to its final destination and in the correct order to reassemble the complete file. 

    Kind regards,
    Øyvind

  • Hi Oyvind,

    As I mentioned in the questions, this was quite simple. Not sure why I couldn't find it earlier.

    Following the definition of the struct, I found the buffer pointer defined in download_fragment in download_client.h

    struct download_fragment {
    	const void *buf;
    	size_t len;
    };
    
    /**
     * @brief Download client event.
     */
    struct download_client_evt {
    	/** Event ID. */
    	enum download_client_evt_id id;
    
    	union {
    		/** Error cause. */
    		int error;
    		/** Fragment data. */
    		struct download_fragment fragment;
    	};
    };

    Now, the real question. I need to modify the download_client to download the data from our cloud using the http POST method. The way cloud is implemented is that the device needs to specify a couple of properties for the cloud to deliver the right firmware type/version for the device and it requires a POST method. Can you please provide some assistance with that?

    Thank you again, you guys have always been great help!

Related