diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2006-03-23 22:15:09 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2006-03-23 22:15:09 +0000 |
commit | b357f1d3900bca5575e88fcfc160945c6088608c (patch) | |
tree | 9c13d9c72daa6dab919e7ef140a6f6d98f3f5b62 /test/rctest.c | |
parent | 6ba87383b2047862686d04db85a4b7e0d1f243ae (diff) |
Add options for count and delay
Diffstat (limited to 'test/rctest.c')
-rw-r--r-- | test/rctest.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/test/rctest.c b/test/rctest.c index 39ec51b7..ebcc4c07 100644 --- a/test/rctest.c +++ b/test/rctest.c @@ -60,6 +60,12 @@ static unsigned char *buf; static long data_size = 127; static long num_frames = -1; +/* Default number of consecutive frames before the delay */ +static int count = 1; + +/* Default delay after sending count number of frames */ +static unsigned long delay = 0; + /* Default addr and channel */ static bdaddr_t bdaddr; static uint8_t channel = 10; @@ -344,6 +350,9 @@ static void send_mode(int sk) strerror(errno), errno); exit(1); } + + if (num_frames && delay && !(seq % count)) + usleep(delay); } syslog(LOG_INFO, "Closing channel ..."); @@ -399,6 +408,8 @@ static void usage(void) "\t[-b bytes] [-i device] [-P channel]\n" "\t[-L seconds] enabled SO_LINGER option\n" "\t[-N num] number of frames to send\n" + "\t[-C num] send num frames before delay (default = 1)\n" + "\t[-D seconds] delay after sending num frames (default = 0)\n" "\t[-A] request authentication\n" "\t[-E] request encryption\n" "\t[-S] secure connection\n" @@ -412,7 +423,7 @@ int main(int argc ,char *argv[]) bacpy(&bdaddr, BDADDR_ANY); - while ((opt=getopt(argc,argv,"rdscuwmnb:i:P:N:MAESL:")) != EOF) { + while ((opt=getopt(argc,argv,"rdscuwmnb:i:P:N:MAESL:C:D:")) != EOF) { switch (opt) { case 'r': mode = RECV; @@ -490,6 +501,14 @@ int main(int argc ,char *argv[]) num_frames = atoi(optarg); break; + case 'C': + count = atoi(optarg); + break; + + case 'D': + delay = atoi(optarg) * 1000000; + break; + default: usage(); exit(1); |