From 070b61ff489127ed821f34c62c0db0f274c79714 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Tue, 3 Aug 2021 11:54:25 +0200 Subject: [PATCH] examples/nimble_scanner: use nimble_scanner_ser_scan_duration Replace xtimer by ztimer Co-authored-by: Roudy Dagher --- examples/nimble_scanner/Makefile | 1 - examples/nimble_scanner/main.c | 15 ++++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/nimble_scanner/Makefile b/examples/nimble_scanner/Makefile index b43bcb7569..3bda95e19b 100644 --- a/examples/nimble_scanner/Makefile +++ b/examples/nimble_scanner/Makefile @@ -8,7 +8,6 @@ BOARD ?= nrf52dk RIOTBASE ?= $(CURDIR)/../.. # We use the xtimer and the shell in this example -USEMODULE += xtimer USEMODULE += shell # configure and use Nimble diff --git a/examples/nimble_scanner/main.c b/examples/nimble_scanner/main.c index 82c2314db9..f7ca6db35c 100644 --- a/examples/nimble_scanner/main.c +++ b/examples/nimble_scanner/main.c @@ -22,7 +22,8 @@ #include #include -#include "xtimer.h" +#include "timex.h" +#include "ztimer.h" #include "shell.h" #include "shell_commands.h" @@ -30,25 +31,25 @@ #include "nimble_scanlist.h" /* default scan duration (1s) */ -#define DEFAULT_DURATION (1000000U) +#define DEFAULT_DURATION_MS (1 * MS_PER_SEC) int _cmd_scan(int argc, char **argv) { - uint32_t timeout = DEFAULT_DURATION; + uint32_t timeout = DEFAULT_DURATION_MS; if ((argc == 2) && (memcmp(argv[1], "help", 4) == 0)) { printf("usage: %s [timeout in ms]\n", argv[0]); return 0; } if (argc >= 2) { - timeout = (uint32_t)(atoi(argv[1]) * 1000); + timeout = atoi(argv[1]); } nimble_scanlist_clear(); - printf("Scanning for %ums now ...", (unsigned)(timeout / 1000)); + printf("Scanning for %"PRIu32" ms now ...", timeout); + nimble_scanner_set_scan_duration(timeout); nimble_scanner_start(); - xtimer_usleep(timeout); - nimble_scanner_stop(); + ztimer_sleep(ZTIMER_MSEC, timeout); puts(" done\n\nResults:"); nimble_scanlist_print(); puts("");