NRF_CLOUD_EVT_FOTA_START takes approx. 10 seconds to appear

Hey,

currently I am testing FOTA and it works. The only thing I don't like is the fact that

 

NRF_CLOUD_EVT_FOTA_START

takes > 10s to appear. Is there a way to make it faster? Because most of the time there is no FOTA pending when the device connects and then it has to wait a long timeout. If FOTA is pending it looks like this. Notice how it takes ~12 seconds until the event appears:

[00:14:41.616,210] <inf> application_states: Current state: APP_STATES_FIRMWARE_UPDATE_STATE
[00:14:41.616,271] <inf> cloud_connection: Enabling connectivity...
[00:14:41.616,394] <inf> application_states: Waiting for cloud disconnection for 120000 ms
[00:14:41.619,934] <inf> cloud_connection: Setting up nRF Cloud library...
[00:14:41.619,964] <wrn> cloud_connection: nRF Cloud library already initialized.
[00:14:41.753,326] <inf> nrf_cloud_credentials: Sec Tag: 16842753; CA: Yes, Client Cert: Yes, Private Key: Yes
[00:14:41.753,387] <inf> nrf_cloud_credentials: CA Size: 1208, AWS: Likely, CoAP: Unlikely
[00:14:41.754,119] <inf> cloud_connection: Network is ready
[00:14:41.754,119] <inf> cloud_connection: Connecting to nRF Cloud
[00:14:41.754,180] <inf> cloud_connection: Device ID: nrf-359404233472084
[00:14:44.469,482] <inf> cloud_connection: Connected to nRF Cloud
[00:14:44.469,543] <inf> cloud_connection: Waiting up to 5s for NRF_CLOUD_EVT_READY...
[00:14:46.069,976] <inf> cloud_connection: Waiting up to 15s for NRF_CLOUD_EVT_FOTA_START...
[00:14:46.070,068] <inf> nrf_cloud_info: Team ID:   6b45992a-f6be-432c-8081-ae8bba455ea9
[00:14:57.699,737] <wrn> downloader: Protocol not specified for bundles.nrfcloud.com/a8376b5e-9840-4166-9503-3db0ff52806d/Poseidon.signed.bin, attempting https://
[00:14:57.699,798] <inf> nrf_cloud_fota: Downloading update
[00:14:57.699,859] <inf> cloud_connection: NRF_CLOUD_EVT_FOTA_START received within 15s.
[00:14:57.699,859] <inf> cloud_connection: FOTA started, staying connected for FOTA process...
[00:14:57.931,274] <inf> downloader: Setting up TLS credentials, sec tag count 1
[00:14:57.931,365] <inf> downloader: Connecting to 2600:9000:275b:7400:7:76af:9a40:93a1
[00:14:57.931,793] <inf> downloader: Failed to connect on IPv6 (err -118), attempting IPv4
[00:14:58.032,958] <inf> downloader: Setting up TLS credentials, sec tag count 1
[00:14:58.033,081] <inf> downloader: Connecting to 3.160.150.85
[00:15:01.561,828] <inf> downloader: Downloaded 1700/397771 bytes (0%)
[00:15:03.077,789] <inf> downloader: Downloaded 3206/397771 bytes (0%)
[00:15:03.095,794] <inf> downloader: Downloaded 3400/397771 bytes (0%)
[00:15:04.045,928] <inf> downloader: Downloaded 4906/397771 bytes (1%)
[00:15:04.150,360] <inf> downloader: Downloaded 5100/397771 bytes (1%)
[00:15:04.830,780] <inf> downloader: Downloaded 6606/397771 bytes (1%)
[00:15:04.848,754] <inf> downloader: Downloaded 6800/397771 bytes (1%)
[00:15:05.450,378] <inf> downloader: Downloaded 8306/397771 bytes (2%)

Is there a way to speed it up?

And second question:
Is there a way to track the FOTA progress? The information is there as you can see in the snippet above (in %) from

ncs/v3.2.1/nrf/subsys/net/lib/downloader/src/downloader.c

but how do I get this information to the application? 

ncs/v3.2.1/nrf/include/net/downloader.h

offers

int downloader_downloaded_size_get(struct downloader *dl, size_t *size);

but I lack *dl.

Also via 

ncs/v3.2.1/nrf/subsys/net/lib/fota_download/src/fota_download.c:

...

static void send_progress(int progress)
{
#ifdef CONFIG_FOTA_DOWNLOAD_PROGRESS_EVT
	const struct fota_download_evt evt = { .id = FOTA_DOWNLOAD_EVT_PROGRESS,
					       .progress = progress };
	callback(&evt);
#endif
}

...

I cant get get the info.


Is there something in place or do I have to do it on my own?

Best

  • Hi,

    Thanks for the detailed log. Regarding your delay question, I would like to say that unfortunately this is not something you can speed up on the device side. What happens is once the device connects and is ready, it asks the cloud like do I have a FOTA job? over MQTT, and then waits for cloud to respond. That round trip just takes time depending on the cloud. Even when there is no FOTA pending you still have to wait the full timeout before knowing that. If this wait is unacceptable, you could be switching to REST-based FOTA polling, where the check returns immediately when no job is found.

    Secondly regarding tracking of download progress, I spent some time on it and it looks that in the NCS library it is made in a way that it never comes out to your application. The progress does flow internally all the way through fota_download.c to nrf_cloud_fota.c, but the bridge function nrf_cloud_fota_cb_handler() in nrf_cloud_transport.c discards the NRF_CLOUD_FOTA_EVT_DL_PROGRESS event instead of forwarding it to your application. So it is something you would need to do it yourself. One of the way could be inside the nRF Cloud library itself, specifically in nrf_cloud_transport.c, where the progress event is currently dropped, and a new public event type would need to be exposed in nrf_cloud.h. 

    Best Regards,
    Syed Maysum

Related