-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
samples: cellular: udp: cleanup and add way to shutdown modem #13066
Conversation
Test specificationCI/Jenkins/NRF
CI/Jenkins/integration
Detailed information of selected test modules Note: This message is automatically posted and updated by the CI |
samples/cellular/udp/src/main.c
Outdated
static bool is_nrf9160(void) | ||
{ | ||
char resp[32]; | ||
|
||
if (nrf_modem_at_cmd(resp, sizeof(resp), "AT+CGMM") == 0) { | ||
if (strstr(resp, "nRF9160") != NULL) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sample only works on nRF 9 series boards. It may have had support for qemu_cortex_m3
earlier, but that is no longer the case. I do not see why this function is necessary anymore, can we remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update the sample accordingly then. I was under the assumption that qemu target was still required.
samples/cellular/udp/Kconfig
Outdated
config UDP_DATA_UPLOAD_FOREVER | ||
bool "Enable that data is transmitted to the server forever" | ||
default y | ||
|
||
config UDP_DATA_UPLOAD_ITERATIONS | ||
int "NUmber of data transmissions to the server before shutdown" if !UDP_DATA_UPLOAD_FOREVER | ||
default 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't need two entries for this; one config for the number of iterations should be sufficient.
If set to -1
let the loop run forever.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about the -1 idea before, but I don't like the fact that a different value has a completely different behavior. While these two options make sense just by reading their name, in the -1 case the user will have to find such behavior in the documentation instead. I'll think more about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about UDP_DATA_UPLOAD_ITERATIONS_BEFORE_EXIT
, then -1 means that the application will not exit after n iterations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MechanicV1 made me aware that the download_client
uses -1
already in a similar way
range -1 600000 |
samples/cellular/udp/src/main.c
Outdated
@@ -239,5 +269,14 @@ int main(void) | |||
|
|||
k_work_schedule(&socket_transmission_work, K_NO_WAIT); | |||
|
|||
#if defined(CONFIG_NRF_MODEM_LIB) && !defined(CONFIG_UDP_DATA_UPLOAD_FOREVER) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove all the occurrences where we check for NRF_MODEM_LIB
. This sample runs only on nRF9 series boards, so this is always defined. Keep it a separate commit if you can.
samples/cellular/udp/src/main.c
Outdated
static int modem_shutdown(void) | ||
{ | ||
int err; | ||
|
||
err = nrf_modem_lib_shutdown(); | ||
if (err) { | ||
printk("Failed to shutdown modem library, error: %d\n", err); | ||
return err; | ||
} | ||
|
||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no point to define this function to call nrf_modem_lib_shutdown()
; just call nrf_modem_lib_shutdown()
directly.
You can find the documentation preview for this PR at this link. It will be updated about 10 minutes after the documentation build succeeds. Note: This comment is automatically posted by the Documentation Publishing GitHub Action. |
samples/cellular/udp/Kconfig
Outdated
config UDP_DATA_UPLOAD_FOREVER | ||
bool "Enable that data is transmitted to the server forever" | ||
default y | ||
|
||
config UDP_DATA_UPLOAD_ITERATIONS | ||
int "NUmber of data transmissions to the server before shutdown" if !UDP_DATA_UPLOAD_FOREVER | ||
default 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about UDP_DATA_UPLOAD_ITERATIONS_BEFORE_EXIT
, then -1 means that the application will not exit after n iterations.
samples/cellular/udp/src/main.c
Outdated
if (data_upload_iterations > 0) { | ||
data_upload_iterations--; | ||
goto transmit; | ||
} else if (data_upload_iterations == 0) { | ||
k_sem_give(&modem_shutdown_sem); | ||
return; | ||
} else if (data_upload_iterations < 0) { | ||
goto transmit; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last else if
is not strictly necessary. We could instead do:
if (data_upload_iterations > 0) { | |
data_upload_iterations--; | |
goto transmit; | |
} else if (data_upload_iterations == 0) { | |
k_sem_give(&modem_shutdown_sem); | |
return; | |
} else if (data_upload_iterations < 0) { | |
goto transmit; | |
} | |
if (data_upload_iterations == 0) { | |
k_sem_give(&modem_shutdown_sem); | |
return; | |
} | |
if (data_upload_iterations > 0) { | |
data_upload_iterations--; | |
} |
Not sure what is clearest.
samples/cellular/udp/src/main.c
Outdated
/* Transmit indefinitely. */ | ||
if (CONFIG_UDP_DATA_UPLOAD_ITERATIONS == -1) { | ||
goto transmit; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not necessary
config UDP_DATA_UPLOAD_ITERATIONS | ||
int "Number of data transmissions to the server before shutdown" | ||
range -1 2147483647 | ||
default -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the sample should terminate by default, so that we can run it in CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MechanicV1 From CI point of view should this sample terminate by default? Or can CI configure it locally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI can change the Kconfig value when building it. Though many other samples are terminating by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test automation will take care of setting the Kconfig ! @MirkoCovizzi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should implement the same behavior as other sample. It's easy enough to change that for users if needed.
CI might want to override the value anyway to shorten the time it takes to complete the test.
config UDP_DATA_UPLOAD_ITERATIONS | ||
int "Number of data transmissions to the server before shutdown" | ||
range -1 2147483647 | ||
default -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test automation will take care of setting the Kconfig ! @MirkoCovizzi
@@ -316,6 +316,10 @@ Cellular samples | |||
|
|||
* Added the configuration overlay file :file:`overlay-supl.conf` for building the sample with SUPL assistance support. | |||
|
|||
* :ref:`udp` sample: | |||
|
|||
* Added the :kconfig:option:`CONFIG_UDP_DATA_UPLOAD_ITERATIONS` Kconfig option for configuring the number of data transmissions to the server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Added the :kconfig:option:`CONFIG_UDP_DATA_UPLOAD_ITERATIONS` Kconfig option for configuring the number of data transmissions to the server. | |
* Added the :ref:`CONFIG_UDP_DATA_UPLOAD_ITERATIONS <CONFIG_UDP_DATA_UPLOAD_ITERATIONS>` Kconfig option for configuring the number of data transmissions to the server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@divipillai Is this the new standard syntax to use from now on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the way to represent the application-specific Kconfig options. For example, for UDP sample, the ones that are defined here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/cellular/udp/README.html#configuration. The Kconfig options defined in the Kconfig reference (library-specific) are provided with the ":kconfig:option:" syntax.
samples/cellular/udp/README.rst
Outdated
|
||
CONFIG_UDP_DATA_UPLOAD_ITERATIONS - UDP data upload iterations configuration | ||
This configuration option sets the number of times the sample transmits data to the server before shutting down. | ||
Set to -1 to transmit indefinitely. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set to -1 to transmit indefinitely. | |
Set to ``-1`` to transmit indefinitely. |
This commit adds a new Kconfig option for configuring the number of data transmissions to the server. Shutdown the modem library when there are no more transmissions to execute. Signed-off-by: Mirko Covizzi <[email protected]>
This commit aligns the semaphore naming convention. Signed-off-by: Mirko Covizzi <[email protected]>
This commit moves the cellular/udp sample from `CI-thingy91-test` to `CI-iot-samples-test`. This is because now the testing automation for `samples/cellular` is under the `CI-iot-samples-test` plan. Signed-off-by: Mirko Covizzi <[email protected]>
This commit adds a new Kconfig option for configuring
the number of data transmissions to the server.
Shutdown the modem library when there are no more
transmissions to execute.
Moved sample to
CI-iot-samples-test
plan.