Diff between 06159d7ab3202104b6345dac7f94ed714d74fcbc and e17038b6d682aef84ad6e66f0d8c85d11ef871ce

Changed Files

File Additions Deletions Status
src/shared/gap.c +16 -0 modified
src/shared/gap.h +3 -0 modified

Full Patch

diff --git a/src/shared/gap.c b/src/shared/gap.c
index 64ed827..f440cdd 100644
--- a/src/shared/gap.c
+++ b/src/shared/gap.c
@@ -39,6 +39,7 @@
 
 struct bt_gap {
 	int ref_count;
+	uint16_t index;
 	struct mgmt *mgmt;
 
 	uint8_t mgmt_version;
@@ -132,12 +133,27 @@ static void read_version_complete(uint8_t status, uint16_t length,
 
 struct bt_gap *bt_gap_new(void)
 {
+	return bt_gap_new_index(0x0000);
+}
+
+struct bt_gap *bt_gap_new_default(void)
+{
+	return bt_gap_new_index(0x0000);
+}
+
+struct bt_gap *bt_gap_new_index(uint16_t index)
+{
 	struct bt_gap *gap;
 
+	if (index == MGMT_INDEX_NONE)
+		return NULL;
+
 	gap = new0(struct bt_gap, 1);
 	if (!gap)
 		return NULL;
 
+	gap->index = index;
+
 	gap->mgmt = mgmt_new_default();
 	if (!gap->mgmt) {
 		free(gap);
diff --git a/src/shared/gap.h b/src/shared/gap.h
index 4e19da0..a12ec4a 100644
--- a/src/shared/gap.h
+++ b/src/shared/gap.h
@@ -22,10 +22,13 @@
  */
 
 #include <stdbool.h>
+#include <stdint.h>
 
 struct bt_gap;
 
 struct bt_gap *bt_gap_new(void);
+struct bt_gap *bt_gap_new_default(void);
+struct bt_gap *bt_gap_new_index(uint16_t index);
 
 struct bt_gap *bt_gap_ref(struct bt_gap *gap);
 void bt_gap_unref(struct bt_gap *gap);