Diff between 946e51cdc39f44b8abcf4c149b36212e6f499511 and 939da35000846943480e86e9c318641536e6fd30

Changed Files

File Additions Deletions Status
src/shared/hciemu.c +18 -3 modified
src/shared/hciemu.h +7 -1 modified

Full Patch

diff --git a/src/shared/hciemu.c b/src/shared/hciemu.c
index e921740..97ea84e 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 4c2afca..0b2da35 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);