[PATCH BlueZ 3/4] advertising: Add implementation of SecondaryChannel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>

This add the parsing for SecondaryChannel which indicates what secondary
PHY shall be used.
---
 src/advertising.c | 52 ++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 42 insertions(+), 10 deletions(-)

diff --git a/src/advertising.c b/src/advertising.c
index df7ebbf81..8cda6a372 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -874,6 +874,47 @@ static bool parse_discoverable_timeout(DBusMessageIter *iter,
 	return true;
 }
 
+static struct adv_secondary {
+	int flag;
+	const char *name;
+} secondary[] = {
+	{ MGMT_ADV_FLAG_SEC_1M, "1M" },
+	{ MGMT_ADV_FLAG_SEC_2M, "2M" },
+	{ MGMT_ADV_FLAG_SEC_CODED, "Codec" },
+	{ },
+};
+
+static bool parse_secondary(DBusMessageIter *iter,
+					struct btd_adv_client *client)
+{
+	const char *str;
+	struct adv_secondary *sec;
+
+	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
+		return false;
+
+	/* Reset secondary channels before parsing */
+	client->flags &= 0xfe00;
+
+	dbus_message_iter_get_basic(iter, &str);
+
+	for (sec = secondary; sec && sec->name; sec++) {
+		if (strcmp(str, sec->name))
+			continue;
+
+		if (!(client->manager->supported_flags & sec->flag))
+			return false;
+
+		DBG("Secondary Channel: %s", str);
+
+		client->flags |= sec->flag;
+
+		return true;
+	}
+
+	return false;
+}
+
 static struct adv_parser {
 	const char *name;
 	bool (*func)(DBusMessageIter *iter, struct btd_adv_client *client);
@@ -891,6 +932,7 @@ static struct adv_parser {
 	{ "Data", parse_data },
 	{ "Discoverable", parse_discoverable },
 	{ "DiscoverableTimeout", parse_discoverable_timeout },
+	{ "SecondaryChannel", parse_secondary },
 	{ },
 };
 
@@ -1234,16 +1276,6 @@ static gboolean get_supported_includes(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
-static struct adv_secondary {
-	int flag;
-	const char *name;
-} secondary[] = {
-	{ MGMT_ADV_FLAG_SEC_1M, "1M" },
-	{ MGMT_ADV_FLAG_SEC_2M, "2M" },
-	{ MGMT_ADV_FLAG_SEC_CODED, "Codec" },
-	{ },
-};
-
 static void append_secondary(struct btd_adv_manager *manager,
 						DBusMessageIter *iter)
 {
-- 
2.17.2




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux