From: Jakub Pawlowski <jpawlowski@google.com>
To: linux-bluetooth@vger.kernel.org
Cc: Jakub Pawlowski <jpawlowski@google.com>
Subject: [PATCH v6 2/8] core/adapter: Refactor of scan type
Date: Mon, 30 Mar 2015 16:32:14 -0700 [thread overview]
Message-ID: <1427758340-14949-2-git-send-email-jpawlowski@google.com> (raw)
In-Reply-To: <1427758340-14949-1-git-send-email-jpawlowski@google.com>
This patch replaces scan type with defined constants, and creates
new method that might be used to get currently avaliable scan type.
---
src/adapter.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index b806106..8f6583c 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -89,6 +89,9 @@
#define TEMP_DEV_TIMEOUT (3 * 60)
#define BONDING_TIMEOUT (2 * 60)
+#define SCAN_TYPE_BREDR (1 << BDADDR_BREDR)
+#define SCAN_TYPE_LE ((1 << BDADDR_LE_PUBLIC) | (1 << BDADDR_LE_RANDOM))
+
static DBusConnection *dbus_conn = NULL;
static bool kernel_conn_control = false;
@@ -1187,7 +1190,7 @@ static gboolean passive_scanning_timeout(gpointer user_data)
adapter->passive_scan_timeout = 0;
- cp.type = (1 << BDADDR_LE_PUBLIC) | (1 << BDADDR_LE_RANDOM);
+ cp.type = SCAN_TYPE_LE;
mgmt_send(adapter->mgmt, MGMT_OP_START_DISCOVERY,
adapter->dev_id, sizeof(cp), &cp,
@@ -1329,6 +1332,21 @@ static void cancel_passive_scanning(struct btd_adapter *adapter)
}
}
+static uint8_t get_scan_type(struct btd_adapter *adapter)
+{
+ uint8_t type;
+
+ if (adapter->current_settings & MGMT_SETTING_BREDR)
+ type = SCAN_TYPE_BREDR;
+ else
+ type = 0;
+
+ if (adapter->current_settings & MGMT_SETTING_LE)
+ type |= SCAN_TYPE_LE;
+
+ return type;
+}
+
static void trigger_start_discovery(struct btd_adapter *adapter, guint delay);
static void start_discovery_complete(uint8_t status, uint16_t length,
@@ -1374,13 +1392,7 @@ static gboolean start_discovery_timeout(gpointer user_data)
adapter->discovery_idle_timeout = 0;
- if (adapter->current_settings & MGMT_SETTING_BREDR)
- new_type = (1 << BDADDR_BREDR);
- else
- new_type = 0;
-
- if (adapter->current_settings & MGMT_SETTING_LE)
- new_type |= (1 << BDADDR_LE_PUBLIC) | (1 << BDADDR_LE_RANDOM);
+ new_type = get_scan_type(adapter);
if (adapter->discovery_enable == 0x01) {
/*
--
2.2.0.rc0.207.ga3a616c
next prev parent reply other threads:[~2015-03-30 23:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-30 23:32 [PATCH v6 1/8] core: device: add device_set_rssi_no_delta Jakub Pawlowski
2015-03-30 23:32 ` Jakub Pawlowski [this message]
2015-03-30 23:32 ` [PATCH v6 3/8] core: adapter: Add SetDiscoveryFilter method Jakub Pawlowski
2015-03-30 23:32 ` [PATCH v6 4/8] core: adapter: Add parameter parsing to SetDiscoveryFilter Jakub Pawlowski
2015-03-30 23:32 ` [PATCH v6 5/8] core: adapter: set the filter for each discovery client Jakub Pawlowski
2015-03-30 23:32 ` [PATCH v6 6/8] core: adapter: start proper discovery depending on filter type Jakub Pawlowski
2015-03-31 1:26 ` Arman Uguray
2015-03-31 7:33 ` Jakub Pawlowski
2015-03-30 23:32 ` [PATCH v6 7/8] core: adapter: filter discovery results when filered discovery is used Jakub Pawlowski
2015-03-31 1:18 ` Arman Uguray
2015-03-30 23:32 ` [PATCH v6 8/8] client: main: add support for SetDiscoveryFilter Jakub Pawlowski
2015-03-31 0:56 ` Arman Uguray
2015-03-31 5:11 ` [PATCH v6 1/8] core: device: add device_set_rssi_no_delta Johan Hedberg
-- strict thread matches above, loose matches on Subject: below --
2015-03-26 8:29 Jakub Pawlowski
2015-03-26 8:29 ` [PATCH v6 2/8] core/adapter: Refactor of scan type Jakub Pawlowski
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=1427758340-14949-2-git-send-email-jpawlowski@google.com \
--to=jpawlowski@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox