Return-Path: MIME-Version: 1.0 In-Reply-To: <1427183840-8089-2-git-send-email-jpawlowski@google.com> References: <1427183840-8089-1-git-send-email-jpawlowski@google.com> <1427183840-8089-2-git-send-email-jpawlowski@google.com> Date: Tue, 24 Mar 2015 11:18:08 +0200 Message-ID: Subject: Re: [PATCH v3 2/8] core/adapter: Refactor of scan type From: Luiz Augusto von Dentz To: Jakub Pawlowski Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-bluetooth-owner@vger.kernel.org List-ID: Hi Jakub, On Tue, Mar 24, 2015 at 9:57 AM, Jakub Pawlowski wrote: > 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 6eeb2f9..be8f5db 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -88,6 +88,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; > @@ -1185,7 +1188,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, > @@ -1327,6 +1330,21 @@ static void cancel_passive_scanning(struct btd_adapter *adapter) > } > } > > +static uint8_t get_current_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, > @@ -1372,13 +1390,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_current_type(adapter); I would rename this to get_scan_type. > if (adapter->discovery_enable == 0x01) { > /* > -- > 2.2.0.rc0.207.ga3a616c > > -- > To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Luiz Augusto von Dentz