[PATCH 32/32] Add support for mcl reconnections

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

 



---
 health/hdp.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/health/hdp.c b/health/hdp.c
index 9678baa..7a726e0 100644
--- a/health/hdp.c
+++ b/health/hdp.c
@@ -56,6 +56,7 @@ struct hdp_connection_cb {
 	struct hdp_instance	*hdpi;
 	uint32_t		rem_id;
 	DBusMessage		*msg;
+	struct hdp_link		*hdpl;
 };
 
 static struct hdp_adapter *find_adapter(GSList *list,
@@ -554,11 +555,15 @@ static void hdp_mcl_connect_cb(struct mcap_mcl *mcl, GError *err, void *data)
 	if (err)
 		goto fail;
 
-	hdpl = create_health_link(hdpi, mcl, &gerr);
-	if (gerr)
-		goto fail;
+	if (cb_data->hdpl)
+		hdpl = cb_data->hdpl;
+	else {
+		hdpl = create_health_link(hdpi, mcl, &gerr);
+		if (gerr)
+			goto fail;
+		hdpi->hlink = g_slist_prepend(hdpi->hlink, hdpl);
+	}
 
-	hdpi->hlink = g_slist_prepend(hdpi->hlink, hdpl);
 	reply = g_dbus_create_reply(msg, DBUS_TYPE_OBJECT_PATH, &hdpl->path,
 							DBUS_TYPE_INVALID);
 	g_dbus_send_message(device->conn, reply);
@@ -664,10 +669,7 @@ static DBusMessage *hdp_connect(DBusConnection *conn,
 	hdpi = l->data;
 	hdpl = get_health_link(hdpi, device);
 	if (hdpl) {
-		if (hdpl->closed) {
-			debug("Need a reconection");
-			/* TODO: Reconnect */;
-		} else
+		if (!hdpl->closed)
 			return g_dbus_create_reply(msg, DBUS_TYPE_OBJECT_PATH,
 						&hdpl->path, DBUS_TYPE_INVALID);
 	}
@@ -677,6 +679,8 @@ static DBusMessage *hdp_connect(DBusConnection *conn,
 	cb_data->hdpi = hdpi;
 	cb_data->rem_id = rid;
 	cb_data->msg = dbus_message_ref(msg);
+	/* Used for reconnections */
+	cb_data->hdpl = hdpl;
 
 	adapter = device->hdp_adapter->btd_adapter;
 	adapter_get_address(adapter, &src);
-- 
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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