Skip to content
This repository has been archived by the owner on Oct 30, 2020. It is now read-only.

Consider changing bsd_init_get_ret usage #2

Open
sigvartmh opened this issue Jan 21, 2020 · 1 comment
Open

Consider changing bsd_init_get_ret usage #2

sigvartmh opened this issue Jan 21, 2020 · 1 comment

Comments

@sigvartmh
Copy link

sigvartmh commented Jan 21, 2020

int err = bsdlib_get_init_ret();

If the intention of this sample is to also display modem firmware upgrade functionality(DFU of modem firmware) I would suggest not using the auto initializing of bsdlib with regards to discussion found in the commit nrfconnect/sdk-nrf@5280b71

I do see that if you want to keep the sample code lines to a minimum it is the best option, but it would display "incorrect" usage which could result in unwanted behavior for the firmware running on the device.

@sigvartmh sigvartmh changed the title Consider changing bsdlib_get_init_ret Consider changing bsd_init_get_ret usage Jan 23, 2020
@sigvartmh sigvartmh changed the title Consider changing bsd_init_get_ret usage Consider changing bsd_init_get_ret usage Jan 23, 2020
@gordonklaus
Copy link

Thanks for the feedback. To be sure I understand correctly, there are two issues:

  1. The result of bsdlib_init is ignored during auto initialization, so subsequent uses of bsdlib can produce hard to understand errors (e.g. socket(...) == -ENOMEM) if a modem firmware upgrade is in progress.
  2. During a modem firmware upgrade, bsdlib_init may block for a whole minute, which may be undesirable for an application which can do other useful things at the same time (e.g. indicating that an upgrade is in progress, collecting sensor data, etc).

Is that correct?

In that case I think the first step is to fix auto initialization of bsdlib to complain loudly rather than ignore errors, so that users are not confused.

Then, I think it will be enough if this sample is modified in two ways:

  1. Split fota_init into two:
    1. fota_init, which does the bsd_init_get_ret check. This must be called first thing in main (if auto-initializing) or immediately after bsdlib_init (if manual).
    2. fota_run, which does the rest. This should be called after application initialization.
  2. Add a comment at the start of main and in the documentation for fota_init which makes it clear that an application should manually initialize bsdlib if they have other things to do while it blocks.

This will keep this FOTA sample code reusable while addressing the issues above.

In any case, this sample's support for modem firmware upgrade isn't yet complete (there is work yet to do in our gateway/backend), so we can put off doing the actual work until the other parts are sorted out. Please leave this issue open.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants