All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Frédéric Danis" <frederic.danis@linux.intel.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 01/14] device: Retrieve device technology from storage
Date: Wed, 12 Dec 2012 16:47:50 +0100	[thread overview]
Message-ID: <1355327283-1558-1-git-send-email-frederic.danis@linux.intel.com> (raw)

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

diff --git a/src/device.c b/src/device.c
index e6afe64..d6f8a9a 100644
--- a/src/device.c
+++ b/src/device.c
@@ -246,6 +246,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);
 
@@ -1902,6 +1931,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';
@@ -1938,6 +1970,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


             reply	other threads:[~2012-12-12 15:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-12 15:47 Frédéric Danis [this message]
2012-12-12 15:47 ` [PATCH 02/14] device: Add device_create_from_storage() function Frédéric Danis
2012-12-12 15:47 ` [PATCH 03/14] adapter: Convert device profiles list Frédéric Danis
2012-12-12 15:47 ` [PATCH 04/14] device: Load profiles from storage Frédéric Danis
2012-12-12 15:47 ` [PATCH 05/14] adapter: Probe profiles after device creation Frédéric Danis
2012-12-12 15:47 ` [PATCH 06/14] device: Delete storage device recursively Frédéric Danis
2012-12-12 15:47 ` [PATCH 07/14] adapter: Convert device sdp file Frédéric Danis
2012-12-12 15:47 ` [PATCH 08/14] device: Load services from storage Frédéric Danis
2012-12-12 15:47 ` [PATCH 09/14] device: Update services from SDP records Frédéric Danis
2012-12-12 15:47 ` [PATCH 10/14] adapter: Convert device primaries list Frédéric Danis
2012-12-12 15:48 ` [PATCH 11/14] adapter: Register services after device creation Frédéric Danis
2012-12-12 15:48 ` [PATCH 12/14] device: Add device_get_storage_path() Frédéric Danis
2012-12-12 15:48 ` [PATCH 13/14] device: Retrieve records from tmp_records only Frédéric Danis
2012-12-12 15:48 ` [PATCH 14/14] input: Use new storage architecture Frédéric Danis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1355327283-1558-1-git-send-email-frederic.danis@linux.intel.com \
    --to=frederic.danis@linux.intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.