* [PATCH 1/3] Remove connectable checking when creating a device
@ 2011-05-04 14:13 Anderson Lizardo
2011-05-04 14:13 ` [PATCH 2/3] Remove advertise event type from adapter functions Anderson Lizardo
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Anderson Lizardo @ 2011-05-04 14:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
From: Claudio Takahasi <claudio.takahasi@openbossa.org>
Kernel advertising cache will be used to infer the LE address type
and if it is connectable. For kernels without cache patches, only
LE public address is supported and if the remote is non-connectable,
the connection will fail after the L2CAP timeout(~40s).
Note: currently, CreateDevice misbehaves when LE Create Connection
command times out for any reason (e.g. peer device left connectable
mode). This is being investigated and will be fixed in a separate patch.
---
src/adapter.c | 30 +++---------------------------
1 files changed, 3 insertions(+), 27 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 8dbd62c..82002e7 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -71,9 +71,6 @@
#define EIR_SIM_HOST 0x10 /* Simultaneous LE and BR/EDR to Same
Device Capable (Host) */
-#define ADV_TYPE_IND 0x00
-#define ADV_TYPE_DIRECT_IND 0x01
-
#define IO_CAPABILITY_DISPLAYONLY 0x00
#define IO_CAPABILITY_DISPLAYYESNO 0x01
#define IO_CAPABILITY_KEYBOARDONLY 0x02
@@ -1652,21 +1649,9 @@ static device_type_t flags2type(uint8_t flags)
return DEVICE_TYPE_DUALMODE;
}
-static gboolean event_is_connectable(uint8_t type)
-{
- switch (type) {
- case ADV_TYPE_IND:
- case ADV_TYPE_DIRECT_IND:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
static struct btd_device *create_device_internal(DBusConnection *conn,
struct btd_adapter *adapter,
- const gchar *address,
- gboolean force, int *err)
+ const gchar *address, int *err)
{
struct remote_dev_info *dev, match;
struct btd_device *device;
@@ -1682,14 +1667,6 @@ static struct btd_device *create_device_internal(DBusConnection *conn,
else
type = DEVICE_TYPE_BREDR;
- if (!force && type == DEVICE_TYPE_LE &&
- !event_is_connectable(dev->evt_type)) {
- if (err)
- *err = -ENOTCONN;
-
- return NULL;
- }
-
device = adapter_create_device(conn, adapter, address, type);
if (!device && err)
*err = -ENOMEM;
@@ -1721,7 +1698,7 @@ static DBusMessage *create_device(DBusConnection *conn,
DBG("%s", address);
- device = create_device_internal(conn, adapter, address, TRUE, &err);
+ device = create_device_internal(conn, adapter, address, &err);
if (!device)
goto failed;
@@ -1802,8 +1779,7 @@ static DBusMessage *create_paired_device(DBusConnection *conn,
device = adapter_find_device(adapter, address);
if (!device) {
- device = create_device_internal(conn, adapter, address,
- FALSE, &err);
+ device = create_device_internal(conn, adapter, address, &err);
if (!device)
return btd_error_failed(msg, strerror(-err));
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/3] Remove advertise event type from adapter functions
2011-05-04 14:13 [PATCH 1/3] Remove connectable checking when creating a device Anderson Lizardo
@ 2011-05-04 14:13 ` Anderson Lizardo
2011-05-04 14:13 ` [PATCH 3/3] Remove flags2type() function Anderson Lizardo
2011-05-05 9:16 ` [PATCH 1/3] Remove connectable checking when creating a device Johan Hedberg
2 siblings, 0 replies; 4+ messages in thread
From: Anderson Lizardo @ 2011-05-04 14:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
From: Claudio Takahasi <claudio.takahasi@openbossa.org>
---
src/adapter.c | 9 ++++-----
src/adapter.h | 5 ++---
src/event.c | 4 ++--
3 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 82002e7..aa8f5d4 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3059,18 +3059,17 @@ static void dev_prepend_uuid(gpointer data, gpointer user_data)
void adapter_update_device_from_info(struct btd_adapter *adapter,
bdaddr_t bdaddr, int8_t rssi,
- uint8_t evt_type, const char *name,
- GSList *services, int flags)
+ const char *name, GSList *services,
+ int flags)
{
struct remote_dev_info *dev;
gboolean new_dev;
dev = get_found_dev(adapter, &bdaddr, &new_dev);
- if (new_dev) {
+ if (new_dev)
dev->le = TRUE;
- dev->evt_type = evt_type;
- } else if (dev->rssi == rssi)
+ else if (dev->rssi == rssi)
return;
dev->rssi = rssi;
diff --git a/src/adapter.h b/src/adapter.h
index 7cc7c02..a305fa7 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -84,7 +84,6 @@ struct remote_dev_info {
char **uuids;
size_t uuid_count;
GSList *services;
- uint8_t evt_type;
uint8_t bdaddr_type;
uint8_t flags;
};
@@ -120,8 +119,8 @@ struct remote_dev_info *adapter_search_found_devices(struct btd_adapter *adapter
struct remote_dev_info *match);
void adapter_update_device_from_info(struct btd_adapter *adapter,
bdaddr_t bdaddr, int8_t rssi,
- uint8_t evt_type, const char *name,
- GSList *services, int flags);
+ const char *name, GSList *services,
+ int flags);
void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
int8_t rssi, uint32_t class, const char *name,
const char *alias, gboolean legacy,
diff --git a/src/event.c b/src/event.c
index 5373e33..c9d8d8c 100644
--- a/src/event.c
+++ b/src/event.c
@@ -399,8 +399,8 @@ void btd_event_advertising_report(bdaddr_t *local, le_advertising_info *info)
rssi = *(info->data + info->length);
adapter_update_device_from_info(adapter, info->bdaddr, rssi,
- info->evt_type, eir_data.name,
- eir_data.services, eir_data.flags);
+ eir_data.name, eir_data.services,
+ eir_data.flags);
free_eir_data(&eir_data);
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 3/3] Remove flags2type() function
2011-05-04 14:13 [PATCH 1/3] Remove connectable checking when creating a device Anderson Lizardo
2011-05-04 14:13 ` [PATCH 2/3] Remove advertise event type from adapter functions Anderson Lizardo
@ 2011-05-04 14:13 ` Anderson Lizardo
2011-05-05 9:16 ` [PATCH 1/3] Remove connectable checking when creating a device Johan Hedberg
2 siblings, 0 replies; 4+ messages in thread
From: Anderson Lizardo @ 2011-05-04 14:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
This function was only being used by create_device_internal(). It is
generating incorrect information when a single mode LE device has flags
0x02 (General Discoverable Mode), it was being "detected" as Dual Mode,
and thus the adapter was attempting to connect through BR/EDR.
This commit fixes CreateDevice() for these devices, but it is a partial
solution. In future, we should drop the "device type" enumeration, as
this information will come from kernel "device found" events.
Also note that the "DEVICE_TYPE_DUALMODE" enumeration is not really
being used, so it will probably disappear too.
---
src/adapter.c | 22 ++--------------------
1 files changed, 2 insertions(+), 20 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index aa8f5d4..609e3d5 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1631,24 +1631,6 @@ static DBusMessage *cancel_device_creation(DBusConnection *conn,
return dbus_message_new_method_return(msg);
}
-static device_type_t flags2type(uint8_t flags)
-{
- /* Inferring the remote type based on the EIR Flags field */
-
- /* For LE only and dual mode the following flags must be zero */
- if (flags & (EIR_SIM_CONTROLLER | EIR_SIM_HOST))
- return DEVICE_TYPE_UNKNOWN;
-
- /* Limited or General discoverable mode bit must be enabled */
- if (!(flags & (EIR_LIM_DISC | EIR_GEN_DISC)))
- return DEVICE_TYPE_UNKNOWN;
-
- if (flags & EIR_BREDR_UNSUP)
- return DEVICE_TYPE_LE;
- else
- return DEVICE_TYPE_DUALMODE;
-}
-
static struct btd_device *create_device_internal(DBusConnection *conn,
struct btd_adapter *adapter,
const gchar *address, int *err)
@@ -1662,8 +1644,8 @@ static struct btd_device *create_device_internal(DBusConnection *conn,
match.name_status = NAME_ANY;
dev = adapter_search_found_devices(adapter, &match);
- if (dev && dev->flags)
- type = flags2type(dev->flags);
+ if (dev && dev->le)
+ type = DEVICE_TYPE_LE;
else
type = DEVICE_TYPE_BREDR;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 1/3] Remove connectable checking when creating a device
2011-05-04 14:13 [PATCH 1/3] Remove connectable checking when creating a device Anderson Lizardo
2011-05-04 14:13 ` [PATCH 2/3] Remove advertise event type from adapter functions Anderson Lizardo
2011-05-04 14:13 ` [PATCH 3/3] Remove flags2type() function Anderson Lizardo
@ 2011-05-05 9:16 ` Johan Hedberg
2 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2011-05-05 9:16 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth, Claudio Takahasi
Hi,
On Wed, May 04, 2011, Anderson Lizardo wrote:
> Kernel advertising cache will be used to infer the LE address type
> and if it is connectable. For kernels without cache patches, only
> LE public address is supported and if the remote is non-connectable,
> the connection will fail after the L2CAP timeout(~40s).
>
> Note: currently, CreateDevice misbehaves when LE Create Connection
> command times out for any reason (e.g. peer device left connectable
> mode). This is being investigated and will be fixed in a separate patch.
> ---
> src/adapter.c | 30 +++---------------------------
> 1 files changed, 3 insertions(+), 27 deletions(-)
All three patches have been pushed upstream. Thanks.
Johan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-05-05 9:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-04 14:13 [PATCH 1/3] Remove connectable checking when creating a device Anderson Lizardo
2011-05-04 14:13 ` [PATCH 2/3] Remove advertise event type from adapter functions Anderson Lizardo
2011-05-04 14:13 ` [PATCH 3/3] Remove flags2type() function Anderson Lizardo
2011-05-05 9:16 ` [PATCH 1/3] Remove connectable checking when creating a device Johan Hedberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox