All of lore.kernel.org
 help / color / mirror / Atom feed
From: Capaianca <fcornevilli@gmail.com>
To: bluez-devel@lists.sourceforge.net
Subject: Re: [Bluez-devel] hci connect and switch role modifications
Date: Tue, 21 Feb 2006 17:03:36 +0100	[thread overview]
Message-ID: <43FB39D8.3030908@gmail.com> (raw)
In-Reply-To: <1135882032.5426.0.camel@localhost.localdomain>

[-- Attachment #1: Type: text/plain, Size: 4763 bytes --]

Hi Marcel,

   as requested, we have attached the unified diff files of our 
modifications. Basically, we added a couple mechanisms that may use to 
prevent some errors from occurring (error masking mechanisms). The 
mechanisms are part of the results of our research on bluetooth 
networks. Perhaps the same strategies  can  be  generalized and applied  
on several parts of the code in order to improve the overall robustness 
of the BlueZ stack.

Specifically, in the hci.c file (and related hci_lib.h) we added two 
functions that may help to solve some problems which may arise when 
creating connections or when switching the role. These functions are 
called "hci_create_connection_timed" and "hci_switch_role_checked".

The hci_create_connection_timed function first creates a connection and 
then checks whether the handle is valid (>0) until a given timeout 
expires. The timeout is specified as an additional parameter, in 
milliseconds.
We created this function because, while working with bluetooth, we 
noticed that to get a valid handle over a connection may take some time, 
even after that the hci_create_connection function return, due to the 
asynchronous nature of the connection creation process. This could 
result in a error when subsequent calls are performed over the 
connection with a handle that is still not valid (e.g. a bnep create 
connection call over an already created l2cap connection, or a switch 
role command). This function avoids this problem because it returns with 
no errors only if the created connection has a valid handle.
It is worth noting that the function returns a "timer expired (ETIME)" 
error even when the connection is created. This happens when the timeout 
expires but the connection still has a not valid handle. However, the 
handle could become valid after the function exits.

The hci_switch_role_checked function performs a similar task. During our 
tests we noticed that sometimes the hci_switch_role function exits with 
a EIO error even if the role was actually switched. This problem may be 
due to a temporary bad state of the rp.status value during the switch 
role process attempt. To overcome this problem, after an invalid check 
of rp.status value, our function reads the linkmode of the connection to 
check the real status after a little amount of time (100ms in the 
current version). If the role is not switched, further attempts are made 
until a timeout expires. This timeout is provided as an input parameter 
to our function.
This function resulted particularly useful when using PDA and other 
limited resources devices where the time required to perform the switch 
role may be longer and may result in errors signaled by the original 
hci_switch_role function even if the role was actually switched.


We preferred to provide two new functions rather than modifying the 
original ones. This way the user can choose to use the function that 
better suites his requirements.

In order to test and use the new functionalities, we also slightly 
modified the hcitool.c program, so as to add an optional parameter 
"--timeout" to both the "cc" and "sr" commands. If the parameter is 
specified the new functions are called, otherwise the original functions 
are used.

Hope this can be of interest and help the BlueZ community.

Best regards,
Marcello Cinque
Fabio Cornevilli
Mobilab Research Group - www.mobilab.unina.it

> Hi Marcello,
>
>   
>> we are working with Bluetooth and BlueZ since two years, and during the
>> development of a field failure data analysis of Bluetooth networks, we
>> experienced some annoying and frequent runtime errors that could be avoided.
>> Those errors concern the creation of a L2CAP connection via HCI and the role
>> switch operation. However, we discovered how to prevent these errors from
>> occurring, by adding a little amount of code in the hci_create_connection and
>> hci_switch_role functions in hci.c.   
>>
>> We would like to contribute to the development and let the community know and
>> evaluate these modifications.
>>
>> If you are interested, let us know what is the procedure to contribute.
>>     
>
> simply sent a unified diff against the latest CVS to the mailing list.
>
> Regards
>
> Marcel
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> _______________________________________________
> Bluez-devel mailing list
> Bluez-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bluez-devel
>
>   


[-- Attachment #2: diffiles.tar.gz --]
[-- Type: application/gzip, Size: 2429 bytes --]

      reply	other threads:[~2006-02-21 16:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-29 15:53 [Bluez-devel] hci connect and switch role modifications Marcello e Fabio
2005-12-29 18:47 ` Marcel Holtmann
2006-02-21 16:03   ` Capaianca [this message]

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=43FB39D8.3030908@gmail.com \
    --to=fcornevilli@gmail.com \
    --cc=bluez-devel@lists.sourceforge.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.