From: Jose Antonio Santos Cadenas <santoscadenas@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Jose Antonio Santos Cadenas <santoscadenas@gmail.com>
Subject: [PATCH 21/32] Manage mcap disconnections and reconnections
Date: Wed, 2 Jun 2010 15:19:17 +0200 [thread overview]
Message-ID: <1275484768-25838-22-git-send-email-santoscadenas@gmail.com> (raw)
In-Reply-To: <1275484768-25838-21-git-send-email-santoscadenas@gmail.com>
---
health/hdp.c | 58 ++++++++++++++++++++++++++++++++++++++++++---------
health/hdp_types.h | 5 ++++
health/hdp_util.c | 19 ++++++++++++----
3 files changed, 66 insertions(+), 16 deletions(-)
diff --git a/health/hdp.c b/health/hdp.c
index 19ff2f9..cb05324 100644
--- a/health/hdp.c
+++ b/health/hdp.c
@@ -37,10 +37,6 @@
#include "../src/dbus-common.h"
-#define HEALTH_MANAGER_INTERFACE "org.bluez.HealthAdapter"
-#define HEALTH_DEVICE "org.bluez.HealthDevice"
-#define HEALTH_LINK "org.bluez.HealthLink"
-
static GSList *adapters = NULL;
static GSList *devices = NULL;
@@ -102,6 +98,14 @@ static int hdp_instance_idcmp(gconstpointer instance, gconstpointer p)
return -1;
}
+static int hdp_link_mcl_cmp(gconstpointer link, gconstpointer mcl){
+ const struct hdp_link *hdpl = link;
+
+ if (hdpl->mcl == mcl)
+ return 0;
+ return -1;
+}
+
static void set_health_link_path(struct hdp_link *hdpl)
{
char path[MAX_PATH_LENGTH + 1];
@@ -617,7 +621,7 @@ static void mcl_connected(struct mcap_mcl *mcl, gpointer data)
struct hdp_link *hdpl;
GError *err = NULL;
- debug("TODO: implement mcl_connected");
+ debug("mcl_connected");
hdpl = create_health_link(hdpi, mcl, &err);
if (err)
return;
@@ -627,20 +631,52 @@ static void mcl_connected(struct mcap_mcl *mcl, gpointer data)
static void mcl_reconnected(struct mcap_mcl *mcl, gpointer data)
{
- /* struct hdp_instance *hdpi = data; */
- debug("TODO: implement mcl_reconnected");
+ struct hdp_instance *hdpi = data;
+ struct hdp_link *hdpl;
+ GSList *l;
+
+ debug("mcl_reconnected");
+ l = g_slist_find_custom(hdpi->hlink, mcl, hdp_link_mcl_cmp);
+ if (l) {
+ hdpl = l->data;
+ hdpl->closed = FALSE;
+ return;
+ }
+
+ mcl_connected(mcl, data);
}
static void mcl_disconnected(struct mcap_mcl *mcl, gpointer data)
{
- /* struct hdp_instance *hdpi = data; */
- debug("TODO: implement mcl_disconnected");
+ struct hdp_instance *hdpi = data;
+ struct hdp_link *hdpl;
+ GSList *l;
+
+ debug("mcl_disconnected");
+ l = g_slist_find_custom(hdpi->hlink, mcl, hdp_link_mcl_cmp);
+ if (!l)
+ return;
+
+ hdpl = l->data;
+ hdpl->closed = TRUE;
}
static void mcl_uncached(struct mcap_mcl *mcl, gpointer data)
{
- /* struct hdp_instance *hdpi = data; */
- debug("TODO: implement mcl_uncached");
+ struct hdp_instance *hdpi = data;
+ struct hdp_link *hdpl;
+ GSList *l;
+
+ debug("mcl_uncached");
+ l = g_slist_find_custom(hdpi->hlink, mcl, hdp_link_mcl_cmp);
+ if (!l)
+ return;
+
+ hdpl = l->data;
+
+ hdpi->hlink = g_slist_remove(hdpi->hlink, hdpl);
+ g_dbus_unregister_interface(hdpi->adapter->conn, hdpl->path,
+ HEALTH_LINK);
}
static DBusMessage *hdp_create_instance(DBusConnection *conn,
diff --git a/health/hdp_types.h b/health/hdp_types.h
index 79419a1..5db8e0d 100644
--- a/health/hdp_types.h
+++ b/health/hdp_types.h
@@ -42,6 +42,10 @@
#define HDP_ERROR g_quark_from_static_string("hdp-error-quark")
+#define HEALTH_MANAGER_INTERFACE "org.bluez.HealthAdapter"
+#define HEALTH_DEVICE "org.bluez.HealthDevice"
+#define HEALTH_LINK "org.bluez.HealthLink"
+
typedef enum {
HDP_DIC_PARSE_ERROR,
HDP_DIC_ENTRY_PARSE_ERROR,
@@ -105,6 +109,7 @@ struct hdp_instance {
struct hdp_link {
struct hdp_instance *hdpi; /* HDP session */
struct mcap_mcl *mcl; /* MCAP mcl */
+ gboolean closed; /* MCL is closed but cached */
GSList *channels; /* Data channels */
char *path; /* HDP link path */
uint32_t id; /* Health link id */
diff --git a/health/hdp_util.c b/health/hdp_util.c
index c54f55c..72d06df 100644
--- a/health/hdp_util.c
+++ b/health/hdp_util.c
@@ -109,15 +109,24 @@ static void free_config(struct hdp_config *config)
g_free(config);
}
+static void hdp_link_unregister(gpointer link, gpointer data)
+{
+ struct hdp_link *hdpl = link;
+ struct hdp_instance *hdpi = hdpl->hdpi;
+
+ hdpi->hlink = g_slist_remove(hdpi->hlink, hdpl);
+ g_dbus_unregister_interface(hdpi->adapter->conn, hdpl->path,
+ HEALTH_LINK);
+}
+
void hdp_instance_free(struct hdp_instance *hdpi)
{
debug("HDP instance %d is deleted", hdpi->id);
/* TODO: Complete this part */
- /*
- g_slist_foreach(hdpi->devices, hdp_device_unregister, NULL);
- g_slist_free(hdpi->devices);
- hdpi->devices = NULL;
- */
+
+ g_slist_foreach(hdpi->hlink, hdp_link_unregister, NULL);
+ g_slist_free(hdpi->hlink);
+ hdpi->hlink = NULL;
if (hdpi->dbus_watcher)
g_dbus_remove_watch(hdpi->adapter->conn, hdpi->dbus_watcher);
--
1.6.3.3
next prev parent reply other threads:[~2010-06-02 13:19 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-02 13:18 [PATCH 00/32] Health device profile (HDP) Jose Antonio Santos Cadenas
2010-06-02 13:18 ` [PATCH 01/32] Add Health api description Jose Antonio Santos Cadenas
2010-06-02 13:18 ` [PATCH 02/32] Initial support for HDP Jose Antonio Santos Cadenas
2010-06-02 13:18 ` [PATCH 03/32] Add functions to resiger health instances in SDP Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 04/32] Initial support for hdp_device_drivers Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 05/32] Register healt_driver interfaces in d-bus Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 06/32] Add delete instance petition Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 07/32] Add watcher to control client disconections to delete hdp instance Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 08/32] Work in getting remote SDP records Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 09/32] Adds functions to get remote suported features from its SDP record Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 10/32] Insert end_point in array returned by get_health_instances Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 11/32] Initial support for connecting instances Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 12/32] Complete the response dictionary in GetHealthInstances response Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 13/32] Implement connection of health instances Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 14/32] Manage mcap instances Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 15/32] Implement connect MCL callback in health instances connection Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 16/32] Register Health link int the bus when MCL is connected Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 17/32] Analize remote record looking for psm Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 18/32] Unify the creation of health links Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 19/32] Remove hdp_device pointer from health link struct Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 20/32] Release health link resources Jose Antonio Santos Cadenas
2010-06-02 13:19 ` Jose Antonio Santos Cadenas [this message]
2010-06-02 13:19 ` [PATCH 22/32] Initial work for disconnecting health links Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 23/32] Avoid multiple links with the same device Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 24/32] Disconnect health link petition Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 25/32] Create new structure to manage data channels in HDP Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 26/32] Implement connect data channel callback Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 27/32] Change function name when retreiving remote SDP records Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 28/32] Changed HEALTH_MANAGER_INTERFACE to HEALTH_MANAGER Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 29/32] Call the agent when a new Health Link is created Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 30/32] Add a test that creates a simple health agent Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 31/32] Send MCL disconnect callback to agents Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 32/32] Add support for mcl reconnections Jose Antonio Santos Cadenas
2010-06-02 13:51 ` [PATCH 00/32] Health device profile (HDP) Johan Hedberg
2010-06-02 14:44 ` José Antonio Santos Cadenas
2010-06-02 20:48 ` Gustavo F. Padovan
-- strict thread matches above, loose matches on Subject: below --
2010-06-04 8:29 [PATCH 00/32] Health Device Prifile (HDP) -- updated Jose Antonio Santos Cadenas
2010-06-04 8:29 ` [PATCH 01/32] Add Health api description Jose Antonio Santos Cadenas
2010-06-04 8:29 ` [PATCH 02/32] Initial support for HDP Jose Antonio Santos Cadenas
2010-06-04 8:29 ` [PATCH 03/32] Add functions to resiger health instances in SDP Jose Antonio Santos Cadenas
2010-06-04 8:29 ` [PATCH 04/32] Initial support for hdp_device_drivers Jose Antonio Santos Cadenas
2010-06-04 8:29 ` [PATCH 05/32] Register healt_driver interfaces in d-bus Jose Antonio Santos Cadenas
2010-06-04 8:29 ` [PATCH 06/32] Add delete instance petition Jose Antonio Santos Cadenas
2010-06-04 8:30 ` [PATCH 07/32] Add watcher to control client disconections to delete hdp instance Jose Antonio Santos Cadenas
2010-06-04 8:30 ` [PATCH 08/32] Work in getting remote SDP records Jose Antonio Santos Cadenas
2010-06-04 8:30 ` [PATCH 09/32] Adds functions to get remote suported features from its SDP record Jose Antonio Santos Cadenas
2010-06-04 8:30 ` [PATCH 10/32] Insert end_point in array returned by get_health_instances Jose Antonio Santos Cadenas
2010-06-04 8:30 ` [PATCH 11/32] Initial support for connecting instances Jose Antonio Santos Cadenas
2010-06-04 8:30 ` [PATCH 12/32] Complete the response dictionary in GetHealthInstances response Jose Antonio Santos Cadenas
2010-06-04 8:30 ` [PATCH 13/32] Implement connection of health instances Jose Antonio Santos Cadenas
2010-06-04 8:30 ` [PATCH 14/32] Manage mcap instances Jose Antonio Santos Cadenas
2010-06-04 8:30 ` [PATCH 15/32] Implement connect MCL callback in health instances connection Jose Antonio Santos Cadenas
2010-06-04 8:30 ` [PATCH 16/32] Register Health link int the bus when MCL is connected Jose Antonio Santos Cadenas
2010-06-04 8:30 ` [PATCH 17/32] Analize remote record looking for psm Jose Antonio Santos Cadenas
2010-06-04 8:30 ` [PATCH 18/32] Unify the creation of health links Jose Antonio Santos Cadenas
2010-06-04 8:30 ` [PATCH 19/32] Remove hdp_device pointer from health link struct Jose Antonio Santos Cadenas
2010-06-04 8:30 ` [PATCH 20/32] Release health link resources Jose Antonio Santos Cadenas
2010-06-04 8:30 ` [PATCH 21/32] Manage mcap disconnections and reconnections Jose Antonio Santos Cadenas
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=1275484768-25838-22-git-send-email-santoscadenas@gmail.com \
--to=santoscadenas@gmail.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).