From: Jose Antonio Santos Cadenas <santoscadenas@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Jose Antonio Santos Cadenas <santoscadenas@gmail.com>
Subject: [PATCH 26/32] Implement connect data channel callback
Date: Wed, 2 Jun 2010 15:19:22 +0200 [thread overview]
Message-ID: <1275484768-25838-27-git-send-email-santoscadenas@gmail.com> (raw)
In-Reply-To: <1275484768-25838-26-git-send-email-santoscadenas@gmail.com>
---
health/hdp.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++----
health/hdp_types.h | 5 ++++
2 files changed, 67 insertions(+), 6 deletions(-)
diff --git a/health/hdp.c b/health/hdp.c
index a38cbe0..1d626d7 100644
--- a/health/hdp.c
+++ b/health/hdp.c
@@ -107,6 +107,13 @@ static struct hdp_link *find_health_link(struct hdp_adapter *adapter,
return NULL;
}
+static int hdp_supp_fts_mdepcmp(gconstpointer ft, gconstpointer mdepid)
+{
+ const struct hdp_supp_fts *fts = ft;
+
+ return bcmp(&fts->mdepid, mdepid, sizeof(uint8_t));
+}
+
static int hdp_instance_idcmp(gconstpointer instance, gconstpointer p)
{
const struct hdp_instance *hdpi = instance;
@@ -379,19 +386,65 @@ static void hdp_mcap_mdl_closed_cb(struct mcap_mdl *mdl, void *data)
debug("TODO: Incomplete callback, mdl closed");
}
-static uint8_t hdp_mcap_mdl_conn_req_cb(struct mcap_mdl *mdl, void *data)
+static uint8_t hdp_mcap_mdl_reconn_req_cb(struct mcap_mdl *mdl, void *data)
{
/* struct hdp_link *hdpl = data; */
debug("TODO: Incomplete callback, mdl connection request");
return MCAP_REQUEST_NOT_SUPPORTED;
}
-static uint8_t hdp_mcap_mdl_reconn_req_cb(struct mcap_mcl *mcl,
- uint8_t mdepid, uint16_t mdlid,
- uint8_t *conf, void *data)
+static uint8_t hdp_mcap_mdl_conn_req_cb(struct mcap_mcl *mcl, uint8_t mdepid,
+ uint16_t mdlid, uint8_t *conf, void *data)
{
- debug("TODO: Incomplete callback, mdl reconnection request");
- return MCAP_REQUEST_NOT_SUPPORTED;
+ struct hdp_link *hdpl = data;
+ struct hdp_supp_fts *f;
+ struct hdp_dc *dc;
+ uint8_t new_conf;
+ GSList *l;
+
+ l = g_slist_find_custom(hdpl->hdpi->config->supp_fts, &mdepid,
+ hdp_supp_fts_mdepcmp);
+ if (!l)
+ return MCAP_INVALID_MDEP;
+ f = l->data;
+
+ /* Check if is the first dc if so,
+ * only reliable configuration is allowed */
+ switch(*conf) {
+ case HDP_NO_PREFERENCE_DC:
+ if (f->role == HDP_SINK)
+ return MCAP_CONFIGURATION_REJECTED;
+ else
+ new_conf = HDP_RELIABLE_DC;
+ break;
+ case HDP_STREAMING_DC:
+ if (g_slist_length(hdpl->channels) == 0)
+ return MCAP_CONFIGURATION_REJECTED;
+ case HDP_RELIABLE_DC:
+ if (f->role == HDP_SOURCE)
+ return MCAP_CONFIGURATION_REJECTED;
+ new_conf = *conf;
+ break;
+ default:
+ /* Special case defined in HDP spec 3.4. When an invalid
+ * configuration is received we need close the MCL when
+ * we are still processing the callback. When MCL is
+ * closed in a callback the returned value won't be
+ * proccesed in MCAP */
+ /* TODO: Send MCL disconnection to agent */
+ g_dbus_unregister_interface(hdpl->hdpi->adapter->conn,
+ hdpl->path, HEALTH_LINK);
+ return MCAP_CONFIGURATION_REJECTED; /* not processed */
+ }
+ *conf = new_conf;
+
+ dc = g_new0(struct hdp_dc, 1);
+ dc->hdpl = hdpl;
+ dc->conf = *conf;
+ dc->mdlid = mdlid;
+
+ hdpl->ndc = dc;
+ return MCAP_SUCCESS;
}
static void health_link_free(struct hdp_link *hdpl)
@@ -406,6 +459,9 @@ static void health_link_free(struct hdp_link *hdpl)
if (hdpl->path)
g_free(hdpl->path);
+ if (hdpl->ndc)
+ g_free(hdpl->ndc);
+
hdpl->hdpi->hlink = g_slist_remove(hdpl->hdpi->hlink, hdpl);
g_free(hdpl);
}
diff --git a/health/hdp_types.h b/health/hdp_types.h
index 6d41e2b..abbfbf3 100644
--- a/health/hdp_types.h
+++ b/health/hdp_types.h
@@ -46,6 +46,10 @@
#define HEALTH_DEVICE "org.bluez.HealthDevice"
#define HEALTH_LINK "org.bluez.HealthLink"
+#define HDP_NO_PREFERENCE_DC 0x00
+#define HDP_RELIABLE_DC 0x01
+#define HDP_STREAMING_DC 0x02
+
typedef enum {
HDP_DIC_PARSE_ERROR,
HDP_DIC_ENTRY_PARSE_ERROR,
@@ -113,6 +117,7 @@ struct hdp_link {
GSList *channels; /* Data channels */
char *path; /* HDP link path */
uint32_t id; /* Health link id */
+ struct hdp_dc *ndc; /* Data channel negotiated */
};
struct hdp_dc {
--
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 ` [PATCH 21/32] Manage mcap disconnections and reconnections Jose Antonio Santos Cadenas
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 ` Jose Antonio Santos Cadenas [this message]
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
2010-06-04 8:30 ` [PATCH 22/32] Initial work for disconnecting health links Jose Antonio Santos Cadenas
2010-06-04 8:30 ` [PATCH 23/32] Avoid multiple links with the same device Jose Antonio Santos Cadenas
2010-06-04 8:30 ` [PATCH 24/32] Disconnect health link petition Jose Antonio Santos Cadenas
2010-06-04 8:30 ` [PATCH 25/32] Create new structure to manage data channels in HDP Jose Antonio Santos Cadenas
2010-06-04 8:30 ` [PATCH 26/32] Implement connect data channel callback 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-27-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).