aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2012-06-19 14:04:50 -0300
committerJoão Paulo Rechi Vita <jprvita@openbossa.org>2012-06-21 18:00:19 -0300
commita3715fb161e989f0d4bf96f73273072d1553da90 (patch)
treec585c5f213f464c2d648cc8cac46706fb391d8c8
parentd9fbf796a83f42ea35c1b005e2a3e89b11668b36 (diff)
downloadbluez-a3715fb161e989f0d4bf96f73273072d1553da90.tar.gz
bluez-a3715fb161e989f0d4bf96f73273072d1553da90.tar.xz
bluez-a3715fb161e989f0d4bf96f73273072d1553da90.zip
attio: Add fast connection parameters settings
This patch extends the attio callback registration function allowing the plugins to inform the wanted connection parameters. For multi profile scenario, the core will use the most restrictive settings.
-rw-r--r--attrib/client.c6
-rw-r--r--deviceinfo/deviceinfo.c3
-rw-r--r--proximity/immalert.c2
-rw-r--r--proximity/linkloss.c2
-rw-r--r--proximity/monitor.c3
-rw-r--r--src/attio.h6
-rw-r--r--src/device.c19
-rw-r--r--thermometer/thermometer.c3
8 files changed, 36 insertions, 8 deletions
diff --git a/attrib/client.c b/attrib/client.c
index a90f22b0..9f8fb3eb 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -399,7 +399,7 @@ static DBusMessage *register_watcher(DBusConnection *conn,
watcher, watcher_free);
if (gatt->attioid == 0)
- gatt->attioid = btd_device_add_attio_callback(gatt->dev,
+ gatt->attioid = btd_device_add_attio_callback(gatt->dev, NULL,
attio_connected,
attio_disconnected,
gatt);
@@ -457,7 +457,7 @@ static DBusMessage *set_value(DBusConnection *conn, DBusMessage *msg,
characteristic_set_value(chr, value, len);
if (gatt->attioid == 0)
- gatt->attioid = btd_device_add_attio_callback(gatt->dev,
+ gatt->attioid = btd_device_add_attio_callback(gatt->dev, NULL,
attio_connected,
attio_disconnected,
gatt);
@@ -977,7 +977,7 @@ static DBusMessage *discover_char(DBusConnection *conn, DBusMessage *msg,
query->msg = dbus_message_ref(msg);
if (gatt->attioid == 0) {
- gatt->attioid = btd_device_add_attio_callback(gatt->dev,
+ gatt->attioid = btd_device_add_attio_callback(gatt->dev, NULL,
attio_connected,
attio_disconnected,
gatt);
diff --git a/deviceinfo/deviceinfo.c b/deviceinfo/deviceinfo.c
index 4548553b..cef09599 100644
--- a/deviceinfo/deviceinfo.c
+++ b/deviceinfo/deviceinfo.c
@@ -174,7 +174,8 @@ int deviceinfo_register(struct btd_device *device, struct gatt_primary *prim)
servers = g_slist_prepend(servers, d);
- d->attioid = btd_device_add_attio_callback(device, attio_connected_cb,
+ d->attioid = btd_device_add_attio_callback(device, NULL,
+ attio_connected_cb,
attio_disconnected_cb, d);
return 0;
}
diff --git a/proximity/immalert.c b/proximity/immalert.c
index 1540b613..e85a27ee 100644
--- a/proximity/immalert.c
+++ b/proximity/immalert.c
@@ -205,7 +205,7 @@ static uint8_t imm_alert_alert_lvl_write(struct attribute *a,
condev->device = btd_device_ref(device);
condev->adapter = ia;
condev->callback_id = btd_device_add_attio_callback(device,
- NULL, imm_alert_disc_cb, condev);
+ NULL, NULL, imm_alert_disc_cb, condev);
ia->connected_devices = g_slist_append(ia->connected_devices,
condev);
DBG("added connected dev %p", device);
diff --git a/proximity/linkloss.c b/proximity/linkloss.c
index 14403cbc..da3e57d9 100644
--- a/proximity/linkloss.c
+++ b/proximity/linkloss.c
@@ -250,7 +250,7 @@ static uint8_t link_loss_alert_lvl_write(struct attribute *a,
condev->device = btd_device_ref(device);
condev->adapter = la;
condev->callback_id = btd_device_add_attio_callback(device,
- NULL, link_loss_disc_cb, condev);
+ NULL, NULL, link_loss_disc_cb, condev);
condev->local_disc_id = device_add_disconnect_watch(device,
link_loss_local_disc, condev, NULL);
diff --git a/proximity/monitor.c b/proximity/monitor.c
index f22d6f4e..7b606343 100644
--- a/proximity/monitor.c
+++ b/proximity/monitor.c
@@ -459,6 +459,7 @@ static DBusMessage *set_immediate_alert(DBusConnection *conn, DBusMessage *msg,
*/
if (monitor->attioid == 0)
monitor->attioid = btd_device_add_attio_callback(monitor->device,
+ NULL,
attio_connected_cb,
attio_disconnected_cb,
monitor);
@@ -653,7 +654,7 @@ int monitor_register(DBusConnection *conn, struct btd_device *device,
monitor->enabled.findme ? "TRUE" : "FALSE");
if (monitor->enabled.linkloss || monitor->enabled.pathloss)
- monitor->attioid = btd_device_add_attio_callback(device,
+ monitor->attioid = btd_device_add_attio_callback(device, NULL,
attio_connected_cb,
attio_disconnected_cb,
monitor);
diff --git a/src/attio.h b/src/attio.h
index 16e28732..c595a645 100644
--- a/src/attio.h
+++ b/src/attio.h
@@ -25,7 +25,13 @@
typedef void (*attio_connect_cb) (GAttrib *attrib, gpointer user_data);
typedef void (*attio_disconnect_cb) (gpointer user_data);
+struct scan_params {
+ uint16_t interval;
+ uint16_t window;
+};
+
guint btd_device_add_attio_callback(struct btd_device *device,
+ struct scan_params *fast,
attio_connect_cb cfunc,
attio_disconnect_cb dcfunc,
gpointer user_data);
diff --git a/src/device.c b/src/device.c
index 7ecccea2..7ec4f90a 100644
--- a/src/device.c
+++ b/src/device.c
@@ -73,6 +73,12 @@
#define APPEARANCE_CHR_UUID 0x2a01
+/* 60msec = 96 * 0.625 msec */
+#define DEFAULT_FAST_CONN_INTERVAL 96
+
+/* 30msec = 48 * 0.625 msec */
+#define DEFAULT_FAST_CONN_WINDOW 48
+
struct btd_disconnect_data {
guint id;
disconnect_watch watch;
@@ -112,6 +118,7 @@ struct browse_req {
struct attio_data {
guint id;
+ struct scan_params fast;
attio_connect_cb cfunc;
attio_disconnect_cb dcfunc;
gpointer user_data;
@@ -1847,6 +1854,7 @@ static gboolean attrib_disconnected_cb(GIOChannel *io, GIOCondition cond,
if (err != ETIMEDOUT && err != ECONNRESET)
goto done;
+ /* Use fast connection parameters */
device->auto_id = g_timeout_add_seconds_full(G_PRIORITY_DEFAULT_IDLE,
AUTO_CONNECTION_INTERVAL,
att_connect, device,
@@ -1997,6 +2005,7 @@ static void att_error_cb(const GError *gerr, gpointer user_data)
if (device->auto_connect == FALSE)
return;
+ /* Low power connection parameters */
device->auto_id = g_timeout_add_seconds_full(G_PRIORITY_DEFAULT_IDLE,
AUTO_CONNECTION_INTERVAL,
att_connect, device,
@@ -2331,6 +2340,7 @@ void device_set_auto_connect(struct btd_device *device, gboolean enable)
if (device->attios == NULL && device->attios_offline == NULL)
return;
+ /* Use fast connection parameters */
device->auto_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
att_connect, device,
att_connect_dispatched);
@@ -3110,6 +3120,7 @@ static gboolean notify_attios(gpointer user_data)
}
guint btd_device_add_attio_callback(struct btd_device *device,
+ struct scan_params *fast,
attio_connect_cb cfunc,
attio_disconnect_cb dcfunc,
gpointer user_data)
@@ -3125,6 +3136,13 @@ guint btd_device_add_attio_callback(struct btd_device *device,
attio->dcfunc = dcfunc;
attio->user_data = user_data;
+ if (fast)
+ memcpy(&attio->fast, fast, sizeof(attio->fast));
+ else {
+ attio->fast.interval = DEFAULT_FAST_CONN_INTERVAL;
+ attio->fast.window = DEFAULT_FAST_CONN_WINDOW;
+ }
+
if (device->attrib && cfunc) {
device->attios_offline = g_slist_append(device->attios_offline,
attio);
@@ -3134,6 +3152,7 @@ guint btd_device_add_attio_callback(struct btd_device *device,
device->attios = g_slist_append(device->attios, attio);
+ /* Use fast connection parameters */
if (device->auto_id == 0)
device->auto_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
att_connect, device,
diff --git a/thermometer/thermometer.c b/thermometer/thermometer.c
index 087662ef..329c3bce 100644
--- a/thermometer/thermometer.c
+++ b/thermometer/thermometer.c
@@ -1253,7 +1253,8 @@ int thermometer_register(DBusConnection *connection, struct btd_device *device,
thermometers = g_slist_prepend(thermometers, t);
- t->attioid = btd_device_add_attio_callback(device, attio_connected_cb,
+ t->attioid = btd_device_add_attio_callback(device, NULL,
+ attio_connected_cb,
attio_disconnected_cb, t);
return 0;
}