samples: net: echo_client: Add Kconfig option to run a number of times
Add Kconfig option NET_SAMPLE_SEND_ITERATIONS that sets the number of times the Zephyr echo client sample sends its data. By default the value is zero, which means indefinite, and demonstrates the same behavior as before. Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
This commit is contained in:
parent
814654af80
commit
dbd3439cf9
2 changed files with 20 additions and 2 deletions
|
@ -51,4 +51,11 @@ config NET_SAMPLE_PSK_HEADER_FILE
|
|||
Name of a header file containing a
|
||||
pre-shared key.
|
||||
|
||||
config NET_SAMPLE_SEND_ITERATIONS
|
||||
int "Send sample data this many times"
|
||||
default 0
|
||||
help
|
||||
Send sample data this many times before exiting. A value of
|
||||
zero means that the sample application is run forever.
|
||||
|
||||
source "Kconfig.zephyr"
|
||||
|
|
|
@ -257,7 +257,8 @@ static void init_app(void)
|
|||
|
||||
void main(void)
|
||||
{
|
||||
int ret;
|
||||
int ret = 0, i = 0;
|
||||
int iterations = CONFIG_NET_SAMPLE_SEND_ITERATIONS;
|
||||
|
||||
init_app();
|
||||
|
||||
|
@ -269,7 +270,7 @@ void main(void)
|
|||
k_sem_give(&run_app);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
while (iterations == 0 || i < iterations) {
|
||||
/* Wait for the connection. */
|
||||
k_sem_take(&run_app, K_FOREVER);
|
||||
|
||||
|
@ -277,8 +278,18 @@ void main(void)
|
|||
|
||||
while (connected && (ret == 0)) {
|
||||
ret = run_udp_and_tcp();
|
||||
|
||||
if (iterations > 0) {
|
||||
i++;
|
||||
if (i >= iterations) {
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stop_udp_and_tcp();
|
||||
}
|
||||
|
||||
exit(ret);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue