From: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
To: Szymon Janc <szymon.janc@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH_v2 5/7] android/health: Create and connect MDL
Date: Sun, 22 Jun 2014 14:08:07 +0300 [thread overview]
Message-ID: <53A6B917.4000209@linux.intel.com> (raw)
In-Reply-To: <1684458.fN4lC0bvSy@leonov>
Hi Szymon,
On 06/21/2014 11:19 PM, Szymon Janc wrote:
> Hi Ravi,
>
> On Friday 20 of June 2014 15:23:34 Ravi kumar Veeramally wrote:
>> Request for md_create_mdl and on successful response
>> connect mdl and pass fd. First data channel should be reliable
>> data channel.
>> ---
>> android/health.c | 122
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 120
>> insertions(+), 2 deletions(-)
>>
>> diff --git a/android/health.c b/android/health.c
>> index fff999d..ec5a413 100644
>> --- a/android/health.c
>> +++ b/android/health.c
>> @@ -87,6 +87,7 @@ struct health_device {
>>
>> uint16_t ccpsm;
>> uint16_t dcpsm;
>> + bool fr; /* first reliable channel */
> Is this really needed? Couldn't this be decided based on eg. dev->channels
> queue length?
Yes, make sense.
>> };
>>
>> struct health_channel {
>> @@ -146,6 +147,16 @@ static void send_channel_state_notify(struct
>> health_channel *channel, sizeof(ev), &ev, fd);
>> }
>>
>> +static void unref_mdl(struct health_channel *channel)
>> +{
>> + if (!channel || !channel->mdl)
>> + return;
>> +
>> + mcap_mdl_unref(channel->mdl);
>> + channel->mdl = NULL;
>> + channel->mdl_conn = false;
>> +}
>> +
>> static void free_health_channel(void *data)
>> {
>> struct health_channel *channel = data;
>> @@ -153,6 +164,7 @@ static void free_health_channel(void *data)
>> if (!channel)
>> return;
>>
>> + unref_mdl(channel);
>> free(channel);
>> }
>>
>> @@ -1016,6 +1028,93 @@ static void mcap_mdl_reconn_req_cb(struct mcap_mdl
>> *mdl, void *data) DBG("Not Implemeneted");
>> }
>>
>> +static void connect_mdl_cb(struct mcap_mdl *mdl, GError *gerr, gpointer
>> data) +{
>> + struct health_channel *channel = data;
>> + int fd;
>> +
>> + DBG("");
>> +
>> + if (gerr) {
>> + error("error connecting to MDL %s", gerr->message);
>> + goto fail;
>> + }
>> +
>> + fd = mcap_mdl_get_fd(channel->mdl);
>> + if (fd < 0) {
>> + error("error retrieving fd");
>> + goto fail;
>> + }
>> +
>> + DBG("MDL connected");
>> + channel->mdl_conn = true;
>> +
>> + /* first data channel should be reliable data channel */
>> + if (!channel->dev->fr)
>> + if (channel->type == CHANNEL_TYPE_RELIABLE)
>> + channel->dev->fr = true;
> If first isn't reliable shouldn't this be an error?
yes, I will add it.
>> +
>> + send_channel_state_notify(channel, HAL_HEALTH_CHANNEL_CONNECTED, fd);
>> +
>> + return;
>> +
>> +fail:
>> + /* TODO: mcap_mdl_abort */
>> + destroy_channel(channel);
>> +}
>> +
>> +static void create_mdl_cb(struct mcap_mdl *mdl, uint8_t type, GError *gerr,
>> + gpointer data)
>> +{
>> + struct health_channel *channel = data;
>> + uint8_t mode;
>> + GError *err = NULL;
>> +
>> + DBG("");
>> + if (gerr) {
>> + error("error creating MDL %s", gerr->message);
>> + goto fail;
>> + }
>> +
>> + if (channel->type == CHANNEL_TYPE_ANY && type != CHANNEL_TYPE_ANY)
>> + channel->type = type;
>> +
>> + /*
>> + * if requested channel type is not same as preferred
>> + * channel type from remote device, then abort the connection.
>> + */
>> + if (channel->type != type) {
>> + /* TODO: abort mdl */
>> + error("abort, channel-type requested %d, preferred %d not same",
>> + channel->type, type);
>> + goto fail;
>> + }
>> +
>> + if (!channel->mdl)
>> + channel->mdl = mcap_mdl_ref(mdl);
>> +
>> + channel->type = type;
>> + 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("error connecting to mdl");
>> + g_error_free(err);
>> + goto fail;
>> + }
>> +
>> + return;
>> +
>> +fail:
>> + destroy_channel(channel);
>> +}
>> +
>> static bool check_role(uint8_t rec_role, uint8_t app_role)
>> {
>> if ((rec_role == HAL_HEALTH_MDEP_ROLE_SINK &&
>> @@ -1078,7 +1177,8 @@ static void get_mdep_cb(sdp_list_t *recs, int err,
>> gpointer user_data) struct health_channel *channel = user_data;
>> struct health_app *app;
>> struct mdep_cfg *mdep;
>> - uint8_t mdep_id;
>> + uint8_t mdep_id, type;
>> + GError *gerr = NULL;
>>
>> if (err < 0 || !recs) {
>> error("error getting remote SDP records");
>> @@ -1102,7 +1202,18 @@ static void get_mdep_cb(sdp_list_t *recs, int err,
>> gpointer user_data)
>>
>> channel->remote_mdep = mdep_id;
>>
>> - /* TODO : create mdl */
>> + if (mdep->role == HAL_HEALTH_MDEP_ROLE_SOURCE)
>> + type = channel->type;
>> + else
>> + type = CHANNEL_TYPE_ANY;
>> +
>> + if (!mcap_create_mdl(channel->dev->mcl, channel->remote_mdep,
>> + type, create_mdl_cb, channel, NULL, &gerr)) {
>> + error("error creating mdl %s", gerr->message);
>> + g_error_free(gerr);
>> + goto fail;
>> + }
>> +
>> return;
>>
>> fail:
>> @@ -1321,6 +1432,13 @@ static void bt_health_connect_channel(const void
>> *buf, uint16_t len) if (!channel)
>> goto fail;
>>
>> + if (!dev->fr) {
>> + if (channel->type != CHANNEL_TYPE_RELIABLE) {
>> + error("error, first data shannel should be reliable");
>> + goto fail;
>> + }
>> + }
>> +
>> if (!dev->mcl) {
>> if (connect_mcl(channel) < 0) {
>> error("error retrieving HDP SDP record");
Thanks,
Ravi.
next prev parent reply other threads:[~2014-06-22 11:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-20 12:23 [PATCH_v2 0/7] Initial implementation for MCAP data channel Ravi kumar Veeramally
2014-06-20 12:23 ` [PATCH_v2 1/7] android/health: Fix queue creation for mdeps and devices Ravi kumar Veeramally
2014-06-21 13:32 ` Szymon Janc
2014-06-20 12:23 ` [PATCH_v2 2/7] android/health: Check if device and channel already exists or not Ravi kumar Veeramally
2014-06-21 13:49 ` Szymon Janc
2014-06-22 11:06 ` Ravi kumar Veeramally
2014-06-20 12:23 ` [PATCH_v2 3/7] android/health: Cache remote mdep id on channel connect request Ravi kumar Veeramally
2014-06-20 12:23 ` [PATCH_v2 4/7] android/health: Notify channel status on channel destroy call Ravi kumar Veeramally
2014-06-20 12:23 ` [PATCH_v2 5/7] android/health: Create and connect MDL Ravi kumar Veeramally
2014-06-21 20:19 ` Szymon Janc
2014-06-22 11:08 ` Ravi kumar Veeramally [this message]
2014-06-20 12:23 ` [PATCH_v2 6/7] android/health: Implement mcap_mdl_deleted_cb Ravi kumar Veeramally
2014-06-20 12:23 ` [PATCH_v2 7/7] anrdroid/client/health: Cache fd and close on channel disconnection Ravi kumar Veeramally
2014-06-21 8:40 ` Sebastian Chlad
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=53A6B917.4000209@linux.intel.com \
--to=ravikumar.veeramally@linux.intel.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=szymon.janc@tieto.com \
/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).