From: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Subject: [RFC 4/5] android/health: Implement mdl reconnect
Date: Fri, 27 Jun 2014 00:30:45 +0300 [thread overview]
Message-ID: <1403818246-20205-5-git-send-email-ravikumar.veeramally@linux.intel.com> (raw)
In-Reply-To: <1403818246-20205-1-git-send-email-ravikumar.veeramally@linux.intel.com>
MDL reconnection can be called only when it is already created, connected
and closed not deleted.
---
android/health.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/android/health.c b/android/health.c
index 717e9a6..db3ae9c 100644
--- a/android/health.c
+++ b/android/health.c
@@ -1147,6 +1147,59 @@ fail:
destroy_channel(channel);
}
+static void reconnect_mdl_cb(struct mcap_mdl *mdl, GError *gerr, gpointer data)
+{
+ struct health_channel *channel = data;
+ uint8_t mode;
+ GError *err = NULL;
+
+ DBG("");
+
+ if (gerr) {
+ error("health: error reconnecting to MDL %s", gerr->message);
+ goto fail;
+ }
+
+ channel->mdl_id = mcap_mdl_get_mdlid(mdl);
+
+ if (channel->type == CHANNEL_TYPE_RELIABLE)
+ mode = L2CAP_MODE_ERTM;
+ else
+ mode = L2CAP_MODE_STREAMING;
+
+ if (!mcap_connect_mdl(channel->mdl, mode, channel->dev->dcpsm,
+ connect_mdl_cb, channel,
+ NULL, &err)) {
+ error("health: error connecting to mdl");
+ g_error_free(err);
+ goto fail;
+ }
+
+ return;
+
+fail:
+ /* TODO: mcap_mdl_abort */
+ destroy_channel(channel);
+}
+
+static int reconnect_mdl(struct health_channel *channel)
+{
+ GError *gerr = NULL;
+
+ DBG("");
+
+ if (!channel)
+ return -1;
+
+ if (!mcap_reconnect_mdl(channel->mdl, reconnect_mdl_cb, channel,
+ NULL, &gerr)){
+ error("health: reconnect failed %s", gerr->message);
+ destroy_channel(channel);
+ }
+
+ return 0;
+}
+
static void create_mdl_cb(struct mcap_mdl *mdl, uint8_t type, GError *gerr,
gpointer data)
{
@@ -1563,6 +1616,13 @@ static void bt_health_connect_channel(const void *buf, uint16_t len)
/* create mdl if it does not exists */
if (!channel->mdl && get_mdep(channel) < 0)
goto fail;
+
+ /* reconnect mdl if it exists */
+ if (channel->mdl && !channel->mdl_conn) {
+ if (reconnect_mdl(channel) < 0)
+ goto fail;
+ }
+
}
rsp.channel_id = channel->id;
--
1.9.1
next prev parent reply other threads:[~2014-06-26 21:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-26 21:30 [RFC 0/5] Implement MDL disconnect and reconnect Ravi kumar Veeramally
2014-06-26 21:30 ` [RFC 1/5] android/client/health: Introduce close_channel API Ravi kumar Veeramally
2014-06-26 21:30 ` [RFC 2/5] android/health: Implement mdl_closed_cb callback Ravi kumar Veeramally
2014-06-26 21:30 ` [RFC 3/5] android/health: Fix deleting channels queue Ravi kumar Veeramally
2014-06-26 21:30 ` Ravi kumar Veeramally [this message]
2014-06-26 21:30 ` [RFC 5/5] android/health: Implement destroy_channel call Ravi kumar Veeramally
2014-06-27 14:13 ` Andrei Emeltchenko
2014-06-27 13:32 ` [RFC 0/5] Implement MDL disconnect and reconnect Szymon Janc
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=1403818246-20205-5-git-send-email-ravikumar.veeramally@linux.intel.com \
--to=ravikumar.veeramally@linux.intel.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;
as well as URLs for NNTP newsgroup(s).