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: [PATCH 4/5] android/health: Implement MDL reconnection from remote device
Date: Mon, 30 Jun 2014 18:31:53 +0300 [thread overview]
Message-ID: <1404142314-20795-5-git-send-email-ravikumar.veeramally@linux.intel.com> (raw)
In-Reply-To: <1404142314-20795-1-git-send-email-ravikumar.veeramally@linux.intel.com>
---
android/health.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 52 insertions(+), 4 deletions(-)
diff --git a/android/health.c b/android/health.c
index 0327542..b77ab4e 100644
--- a/android/health.c
+++ b/android/health.c
@@ -235,6 +235,14 @@ static void free_health_app(void *data)
free(app);
}
+static bool match_channel_by_mdl(const void *data, const void *user_data)
+{
+ const struct health_channel *channel = data;
+ const struct mcap_mdl *mdl = user_data;
+
+ return channel->mdl == mdl;
+}
+
static bool match_channel_by_id(const void *data, const void *user_data)
{
const struct health_channel *channel = data;
@@ -298,6 +306,7 @@ static bool match_app_by_id(const void *data, const void *user_data)
*/
struct channel_search {
uint16_t channel_id;
+ struct mcap_mdl *mdl;
struct health_channel *channel;
};
@@ -309,8 +318,13 @@ static void device_search_channel(void *data, void *user_data)
if (search->channel)
return;
- search->channel = queue_find(dev->channels, match_channel_by_id,
+ if (search->channel_id)
+ search->channel = queue_find(dev->channels, match_channel_by_id,
INT_TO_PTR(search->channel_id));
+ else if (search->mdl)
+ search->channel = queue_find(dev->channels,
+ match_channel_by_mdl,
+ search->mdl);
}
static void app_search_channel(void *data, void *user_data)
@@ -331,6 +345,21 @@ static struct health_channel *search_channel_by_id(uint16_t id)
DBG("");
search.channel_id = id;
+ search.mdl = NULL;
+ search.channel = NULL;
+ queue_foreach(apps, app_search_channel, &search);
+
+ return search.channel;
+}
+
+static struct health_channel *search_channel_by_mdl(struct mcap_mdl *mdl)
+{
+ struct channel_search search;
+
+ DBG("");
+
+ search.channel_id = 0;
+ search.mdl = mdl;
search.channel = NULL;
queue_foreach(apps, app_search_channel, &search);
@@ -1176,11 +1205,14 @@ static void mcap_mdl_connected_cb(struct mcap_mdl *mdl, void *data)
struct health_channel *channel = data;
int fd;
+ DBG("Data channel connected: mdl %p channel %p", mdl, channel);
+
+ if (!channel)
+ channel = search_channel_by_mdl(mdl);
+
if (!channel->mdl)
channel->mdl = mcap_mdl_ref(mdl);
- DBG("Data channel connected: mdl %p channel %p", mdl, channel);
-
fd = mcap_mdl_get_fd(channel->mdl);
if (fd < 0) {
error("health: error retrieving fd");
@@ -1475,7 +1507,23 @@ static uint8_t mcap_mdl_conn_req_cb(struct mcap_mcl *mcl, uint8_t mdepid,
static uint8_t mcap_mdl_reconn_req_cb(struct mcap_mdl *mdl, void *data)
{
- DBG("Not Implemeneted");
+ struct health_channel *channel;
+ GError *err = NULL;
+
+ DBG("");
+
+ channel = search_channel_by_mdl(mdl);
+ if (!channel) {
+ error("health: channel data does not exist");
+ return MCAP_UNSPECIFIED_ERROR;
+ }
+
+ if (!mcap_set_data_chan_mode(mcap,
+ conf_to_l2cap(channel->type), &err)) {
+ error("health: %s", err->message);
+ g_error_free(err);
+ return MCAP_MDL_BUSY;
+ }
return MCAP_SUCCESS;
}
--
1.9.1
next prev parent reply other threads:[~2014-06-30 15:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-30 15:31 [PATCH 0/5] Implement disconenct and reconnect Ravi kumar Veeramally
2014-06-30 15:31 ` [PATCH 1/5] android/health: Implement mcl_disconnected cb Ravi kumar Veeramally
2014-06-30 15:31 ` [PATCH 2/5] android/health: Implement mcl_uncached callback Ravi kumar Veeramally
2014-06-30 15:31 ` [PATCH 3/5] android/health: Fix do not set mdl callbacks on mcl_reconneced call back Ravi kumar Veeramally
2014-06-30 15:31 ` Ravi kumar Veeramally [this message]
2014-06-30 16:36 ` [PATCH 4/5] android/health: Implement MDL reconnection from remote device Szymon Janc
2014-06-30 15:31 ` [PATCH 5/5] android/health: Update PTS result Ravi kumar Veeramally
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=1404142314-20795-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