summaryrefslogtreecommitdiff
path: root/android/health.c
diff options
context:
space:
mode:
authorRavi kumar Veeramally <ravikumar.veeramally@linux.intel.com>2014-06-27 00:30:45 +0300
committerSzymon Janc <szymon.janc@tieto.com>2014-06-27 15:30:24 +0200
commit8efc2021a22b07a06fe1737b2c273226b55e0183 (patch)
treeb2679dad68649707570edda0e8801212cff0baa3 /android/health.c
parentd411e3e01239a84b1706656503647f5362493b5d (diff)
downloadbluez-8efc2021a22b07a06fe1737b2c273226b55e0183.tar.gz
android/health: Implement mdl reconnect
MDL reconnection can be called only when it is already created, connected and closed not deleted.
Diffstat (limited to 'android/health.c')
-rw-r--r--android/health.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/android/health.c b/android/health.c
index 717e9a67b..db3ae9c8e 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;