From 939da35000846943480e86e9c318641536e6fd30 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 31 Jan 2013 14:23:58 -0600 Subject: [PATCH] shared: Provide hciemu type in hciemu_new() --- src/shared/hciemu.c | 21 ++++++++++++++++++--- src/shared/hciemu.h | 8 +++++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/shared/hciemu.c b/src/shared/hciemu.c index e92174092..97ea84e13 100644 --- a/src/shared/hciemu.c +++ b/src/shared/hciemu.c @@ -41,6 +41,7 @@ struct hciemu { gint ref_count; + enum btdev_type btdev_type; struct bthost *host_stack; struct btdev *master_dev; struct btdev *client_dev; @@ -195,7 +196,7 @@ static bool create_vhci(struct hciemu *hciemu) const char *str; int fd, i; - btdev = btdev_create(BTDEV_TYPE_BREDRLE, 0x00); + btdev = btdev_create(hciemu->btdev_type, 0x00); if (!btdev) return false; @@ -226,7 +227,7 @@ static bool create_stack(struct hciemu *hciemu) struct bthost *bthost; int sv[2]; - btdev = btdev_create(BTDEV_TYPE_BREDRLE, 0x00); + btdev = btdev_create(hciemu->btdev_type, 0x00); if (!btdev) return false; @@ -263,7 +264,7 @@ static gboolean start_stack(gpointer user_data) return FALSE; } -struct hciemu *hciemu_new(void) +struct hciemu *hciemu_new(enum hciemu_type type) { struct hciemu *hciemu; @@ -271,6 +272,20 @@ struct hciemu *hciemu_new(void) if (!hciemu) return NULL; + switch (type) { + case HCIEMU_TYPE_BREDRLE: + hciemu->btdev_type = BTDEV_TYPE_BREDRLE; + break; + case HCIEMU_TYPE_BREDR: + hciemu->btdev_type = BTDEV_TYPE_BREDR; + break; + case HCIEMU_TYPE_LE: + hciemu->btdev_type = BTDEV_TYPE_LE; + break; + default: + return NULL; + } + if (!create_vhci(hciemu)) { g_free(hciemu); return NULL; diff --git a/src/shared/hciemu.h b/src/shared/hciemu.h index 4c2afcafa..0b2da359c 100644 --- a/src/shared/hciemu.h +++ b/src/shared/hciemu.h @@ -26,7 +26,13 @@ struct hciemu; -struct hciemu *hciemu_new(void); +enum hciemu_type { + HCIEMU_TYPE_BREDRLE, + HCIEMU_TYPE_BREDR, + HCIEMU_TYPE_LE, +}; + +struct hciemu *hciemu_new(enum hciemu_type type); struct hciemu *hciemu_ref(struct hciemu *hciemu); void hciemu_unref(struct hciemu *hciemu); -- 2.47.3