All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 01/15] device: Retrieve device technology from storage
@ 2012-12-13 20:39 Frédéric Danis
  2012-12-13 20:39 ` [PATCH v2 02/15] device: Add device_create_from_storage() function Frédéric Danis
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: Frédéric Danis @ 2012-12-13 20:39 UTC (permalink / raw)
  To: linux-bluetooth

---
 src/device.c |   68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/src/device.c b/src/device.c
index e7aa44d..515ee61 100644
--- a/src/device.c
+++ b/src/device.c
@@ -244,6 +244,35 @@ static gboolean store_device_info_cb(gpointer user_data)
 		g_key_file_remove_key(key_file, "General", "Class", NULL);
 	}
 
+	switch (device->bdaddr_type) {
+	case BDADDR_BREDR:
+		g_key_file_set_string(key_file, "General",
+					"SupportedTechnologies", "BR/EDR");
+		g_key_file_remove_key(key_file, "General",
+					"AddressType", NULL);
+		break;
+
+	case BDADDR_LE_PUBLIC:
+		g_key_file_set_string(key_file, "General",
+					"SupportedTechnologies", "LE");
+		g_key_file_set_string(key_file, "General",
+					"AddressType", "public");
+		break;
+
+	case BDADDR_LE_RANDOM:
+		g_key_file_set_string(key_file, "General",
+					"SupportedTechnologies", "LE");
+		g_key_file_set_string(key_file, "General",
+					"AddressType", "static");
+		break;
+
+	default:
+		g_key_file_remove_key(key_file, "General",
+					"SupportedTechnologies", NULL);
+		g_key_file_remove_key(key_file, "General",
+					"AddressType", NULL);
+	}
+
 	g_key_file_set_boolean(key_file, "General", "Trusted",
 							device->trusted);
 
@@ -1714,6 +1743,9 @@ static void load_info(struct btd_device *device, const gchar *local,
 	gboolean store_needed = FALSE;
 	gboolean blocked;
 	int source, vendor, product, version;
+	char **techno, **t;
+	gboolean bredr = FALSE;
+	gboolean le = FALSE;
 
 	snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/info", local, peer);
 	filename[PATH_MAX] = '\0';
@@ -1750,6 +1782,42 @@ static void load_info(struct btd_device *device, const gchar *local,
 		g_free(str);
 	}
 
+	/* Load device technology */
+	techno = g_key_file_get_string_list(key_file, "General",
+					"SupportedTechnologies", NULL, NULL);
+	if (!techno)
+		goto next;
+
+	for (t = techno; *t; t++) {
+		if (g_str_equal(*t, "BR/EDR"))
+			bredr = TRUE;
+		else if (g_str_equal(*t, "LE"))
+			le = TRUE;
+		else
+			error("Unknown device technology");
+	}
+
+	if (bredr && le) {
+		/* TODO: Add correct type for dual mode device */
+	} else if (bredr) {
+		device->bdaddr_type = BDADDR_BREDR;
+	} else if (le) {
+		str = g_key_file_get_string(key_file, "General",
+						"AddressType", NULL);
+
+		if (str && g_str_equal(str, "public"))
+			device->bdaddr_type = BDADDR_LE_PUBLIC;
+		else if (str && g_str_equal(str, "static"))
+			device->bdaddr_type = BDADDR_LE_RANDOM;
+		else
+			error("Unknown LE device technology");
+
+		g_free(str);
+	}
+
+	g_strfreev(techno);
+
+next:
 	/* Load trust */
 	device->trusted = g_key_file_get_boolean(key_file, "General",
 							"Trusted", NULL);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2012-12-14  8:31 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-13 20:39 [PATCH v2 01/15] device: Retrieve device technology from storage Frédéric Danis
2012-12-13 20:39 ` [PATCH v2 02/15] device: Add device_create_from_storage() function Frédéric Danis
2012-12-13 20:39 ` [PATCH v2 03/15] adapter: Convert device profiles list Frédéric Danis
2012-12-13 20:39 ` [PATCH v2 04/15] device: Load profiles from storage Frédéric Danis
2012-12-13 20:39 ` [PATCH v2 05/15] adapter: Probe profiles after device creation Frédéric Danis
2012-12-13 20:39 ` [PATCH v2 06/15] device: Delete storage device recursively Frédéric Danis
2012-12-13 20:39 ` [PATCH v2 07/15] doc: Update Settings-storage for SDP records Frédéric Danis
2012-12-13 20:39 ` [PATCH v2 08/15] adapter: Convert device sdp file Frédéric Danis
2012-12-13 20:39 ` [PATCH v2 09/15] device: Remove stored SDP records on device removal Frédéric Danis
2012-12-13 20:39 ` [PATCH v2 10/15] device: Load primary attributes from storage Frédéric Danis
2012-12-13 20:39 ` [PATCH v2 11/15] device: Store SDP records in new storage Frédéric Danis
2012-12-13 20:39 ` [PATCH v2 12/15] adapter: Convert device primaries list Frédéric Danis
2012-12-13 20:39 ` [PATCH v2 13/15] adapter: Remove create_stored_device_from_primaries Frédéric Danis
2012-12-13 20:39 ` [PATCH v2 14/15] device: Update btd_device_get_record to use new storage Frédéric Danis
2012-12-13 20:39 ` [PATCH v2 15/15] input: Use new storage architecture Frédéric Danis
2012-12-14  8:31 ` [PATCH v2 01/15] device: Retrieve device technology from storage Johan Hedberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.