From bcb96cdde52b66eaca3ca976cd354466fa35033d Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 7 Mar 2013 19:00:09 +0200 Subject: [PATCH] emulator: Allow multiple vhci adapter creation with btvirt --- emulator/main.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/emulator/main.c b/emulator/main.c index a11fdd8a6..f185a9768 100644 --- a/emulator/main.c +++ b/emulator/main.c @@ -55,9 +55,9 @@ static void usage(void) } static const struct option main_options[] = { - { "local", no_argument, NULL, 'l' }, - { "version", no_argument, NULL, 'v' }, - { "help", no_argument, NULL, 'h' }, + { "local", optional_argument, NULL, 'l' }, + { "version", no_argument, NULL, 'v' }, + { "help", no_argument, NULL, 'h' }, { } }; @@ -69,22 +69,26 @@ int main(int argc, char *argv[]) struct server *server3; struct server *server4; struct server *server5; - bool enable_vhci = false; + int vhci_count = 0; enum vhci_type vhci_type = VHCI_TYPE_BREDRLE; sigset_t mask; + int i; mainloop_init(); for (;;) { int opt; - opt = getopt_long(argc, argv, "lLBvh", main_options, NULL); + opt = getopt_long(argc, argv, "l::LBvh", main_options, NULL); if (opt < 0) break; switch (opt) { case 'l': - enable_vhci = true; + if (optarg) + vhci_count = atoi(optarg); + else + vhci_count = 1; break; case 'L': vhci_type = VHCI_TYPE_LE; @@ -111,7 +115,7 @@ int main(int argc, char *argv[]) printf("Bluetooth emulator ver %s\n", VERSION); - if (enable_vhci) { + for (i = 0; i < vhci_count; i++) { vhci = vhci_open(vhci_type); if (!vhci) fprintf(stderr, "Failed to open Virtual HCI device\n"); -- 2.47.3