Hello everyone,
I'm trying to find the fastest possible way to get RSSI values for
Bluetooth devices. So far, my code looks like this:
dev_id = hci_get_route(NULL);
hci_devinfo(dev_id,&di);
...
num_rsp = hci_inquiry(dev_id, len, max_rsp, NULL, &ii, flags);
...
for (i = 0; i < num_rsp; i++) {
uint16_t myhandle;
if (hci_create_connection(
sock,
&(ii+i)->bdaddr,
htobs(di.pkt_type & ACL_PTYPE_MASK),
(ii+i)->clock_offset,
0,
&myhandle,
0
) < 0) perror("hci_create_con");
if (hci_read_rssi(sock, myhandle, &rssi, 0) < 0)
rssi = -127;
hci_disconnect(sock, myhandle, HCI_OE_USER_ENDED_CONNECTION, 0);
...
}
Now, while this works, I feel it's really slow.
Can somebody please enlighten me to the meaning of parameters 3-5 of
hci_create_connection? I also would be grateful for some mid-level
description of the Bluetooth protocol..
What I believe to know is this:
- ptype: Packet types which are allowed for this connection.
Intersection of what the device supports and all ACL packet types.
- clock offset: difference in ticks between local device clock and
target device clock. My limited Bluetooth knowledge made me think that
when I specify the offset from hci_inquiry, the connection should be
created faster, as the clock offset doesn't have to be calculated
again. However, I don't really see a difference when I just set this
to 0.
- rswitch: Allow role switch. Not a difference either..
I know that somebody posted a while ago that L2CAP should be preferred
for such tasks, but IIRC, opening an L2CAP connection requires
authentication/pairing while this method doesn't.
Please correct my half-knowledge, where appropriate :-)
Thanks for your help,
Yours, Florian
--
0666 - Filemode of the Beast
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
> And no matter what you try, creating an ACL baseband connection is most
> expensive operation in Bluetooth. So it takes time and that it takes
> even more time if you have to wait for the page timeout if the device is
> not in range.
Hmm, ok.. I see that I'm probably still lacking some background
knowledge here. Can you suggest a document besides the official spec
that offers a detailed explanation of baseband and link manager?
Thanks, Yours, Florian
--
0666 - Filemode of the Beast
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Hi Florian,
> > > However, what I'm trying to do - repeating inquiries in one thread,
> > > checking RSSI in another one (even for devices that haven't been
> > > seen by
> > > the last inquiries) - doesn't seem possible in the D-Bus API, as there
> > > is no function to create a low-level ACL connection to a device
> > > address..?
> > what do you expect from the RSSI value that you get from an active ACL
> > link. It is different from the RSSI value you get via inquiry anyway.
> Well, that wouldn't matter, as I'm going to put all that into a wrapper
> class anyway.
>
> Maybe a word about what I'm trying to do - as you may have guessed
> already, it's about proximity sensing. I've put a minimal Dbus interface
> into my wrapper class and it's actually working quite nicely. However,
> some of the devices which I'm working with - e.g., Motorola mobile
> phones - have a hardcoded discoverable timeout of 3 minutes.
>
> This makes things a bit more difficult for me, as these phones suddenly
> vanish from the list which the Dbus interface is providing, even if they
> are still in range. With the hci_* interface, I can simply try to open
> an ACL connection and get the RSSI value to see if they are just
> invisible. How do I do this with Dbus?
and that RSSI value is totally different from the one you get via an
inquiry and thus you can't put them together. If you could, I would have
done this inside the kernel.
And no matter what you try, creating an ACL baseband connection is most
expensive operation in Bluetooth. So it takes time and that it takes
even more time if you have to wait for the page timeout if the device is
not in range.
Regards
Marcel
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
> > However, what I'm trying to do - repeating inquiries in one thread,
> > checking RSSI in another one (even for devices that haven't been
> > seen by
> > the last inquiries) - doesn't seem possible in the D-Bus API, as there
> > is no function to create a low-level ACL connection to a device
> > address..?
> what do you expect from the RSSI value that you get from an active ACL
> link. It is different from the RSSI value you get via inquiry anyway.
Well, that wouldn't matter, as I'm going to put all that into a wrapper
class anyway.
Maybe a word about what I'm trying to do - as you may have guessed
already, it's about proximity sensing. I've put a minimal Dbus interface
into my wrapper class and it's actually working quite nicely. However,
some of the devices which I'm working with - e.g., Motorola mobile
phones - have a hardcoded discoverable timeout of 3 minutes.
This makes things a bit more difficult for me, as these phones suddenly
vanish from the list which the Dbus interface is providing, even if they
are still in range. With the hci_* interface, I can simply try to open
an ACL connection and get the RSSI value to see if they are just
invisible. How do I do this with Dbus?
Thanks for your help,
Yours, Florian
--
0666 - Filemode of the Beast
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Hi Florian,
> A short followup to my own post: In the list archives, I've read
> multiple times that the hci_* API is more or less deprecated and D-Bus
> is the future.
>
> However, what I'm trying to do - repeating inquiries in one thread,
> checking RSSI in another one (even for devices that haven't been
> seen by
> the last inquiries) - doesn't seem possible in the D-Bus API, as there
> is no function to create a low-level ACL connection to a device
> address..?
what do you expect from the RSSI value that you get from an active ACL
link. It is different from the RSSI value you get via inquiry anyway.
Regards
Marcel
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
A short followup to my own post: In the list archives, I've read
multiple times that the hci_* API is more or less deprecated and D-Bus
is the future.
However, what I'm trying to do - repeating inquiries in one thread,
checking RSSI in another one (even for devices that haven't been seen by
the last inquiries) - doesn't seem possible in the D-Bus API, as there
is no function to create a low-level ACL connection to a device
address..?
Yours, Florian
--
0666 - Filemode of the Beast
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel