Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 May 2009 09:42:52 -0700
From:      Maksim Yevmenkin <maksim.yevmenkin@gmail.com>
To:        Iain Hibbert <plunky@rya-online.net>
Cc:        freebsd-bluetooth@freebsd.org
Subject:   Re: libhci update
Message-ID:  <bb4a86c70905140942u67ed1203ke245029a740be3ca@mail.gmail.com>
In-Reply-To: <bb4a86c70905140926n488cb2b5x5f5530e01d70bd66@mail.gmail.com>
References:  <E1Lv5La-00058x-HH@smtpbarns01> <bb4a86c70904201053y1a04d76el336432d3e1a23576@mail.gmail.com> <1240311202.361300.1366.nullmailer@galant.ukfsn.org> <bb4a86c70904210959w6de5e808h9f85ee2bb1995dbf@mail.gmail.com> <1240352254.082638.416.nullmailer@galant.ukfsn.org> <bb4a86c70904211651m6127745ao9d4f26c91e428994@mail.gmail.com> <1240386569.369073.696.nullmailer@galant.ukfsn.org> <bb4a86c70904220909j5d047ce6x6260bd2e87b5b7bd@mail.gmail.com> <1242294653.314348.1748.nullmailer@galant.ukfsn.org> <bb4a86c70905140926n488cb2b5x5f5530e01d70bd66@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, May 14, 2009 at 9:26 AM, Maksim Yevmenkin
<maksim.yevmenkin@gmail.com> wrote:

>>        /* Calculate inquire length in 1.28 second units */
>>        to = (time_t) ((double) length / 1.28);
>>
>>        if (to <= 0)
>>                cp->inquiry_length = 4;         /* 5.12 seconds */
>>        else if (to > 254)
>>                cp->inquiry_length = 255;       /* 326.40 seconds */
>>        else
>>                cp->inquiry_length = to + 1;
>>
>> 2.1 spec says 1.28 -> 61.44 seconds range is acceptable (0x01->0x30)

ok, do you like something like

Index: hci.c
===================================================================
--- hci.c       (revision 191499)
+++ hci.c       (working copy)
@@ -410,7 +410,6 @@
        ng_hci_inquiry_response         *ir;
        struct bt_devinquiry            *i;
        int                             s, n;
-       time_t                          to;

        if (ii == NULL) {
                errno = EINVAL;
@@ -452,17 +451,21 @@
        cp->lap[1] = 0x8b;
        cp->lap[2] = 0x9e;

-       /* Calculate inquire length in 1.28 second units */
-       to = (time_t) ((double) length / 1.28);
-       if (to <= 0)
-               cp->inquiry_length = 4;         /* 5.12 seconds */
-       else if (to > 254)
-               cp->inquiry_length = 255;       /* 326.40 seconds */
-       else
-               cp->inquiry_length = to + 1;
+       /*
+        * Calculate inquire length in 1.28 second units
+        * v2.x specification says that 1.28 -> 61.44 seconds
+        * range is acceptable
+        */

-       to = (time_t)((double) cp->inquiry_length * 1.28) + 1;
+       if (length <= 0)
+               length = 5;
+       else if (length == 1)
+               length = 2;
+       else if (length > 61)
+               length = 61;

+       cp->inquiry_length = (uint8_t)((length * 100) / 128);
+
        if (num_rsp <= 0 || num_rsp > 255)
                num_rsp = 8;
        cp->num_responses = (uint8_t) num_rsp;
@@ -484,7 +487,7 @@

 wait_for_more:

-       n = bt_devrecv(s, buf, sizeof(buf), to);
+       n = bt_devrecv(s, buf, sizeof(buf), length);
        if (n < 0) {
                free(i);
                bt_devclose(s);

==

thanks,
max



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bb4a86c70905140942u67ed1203ke245029a740be3ca>