From: James Cameron <james.cameron@hp.com>
To: Albert Huang <ashuang@gmail.com>
Cc: BlueZ Mailing List <bluez-devel@lists.sourceforge.net>
Subject: Re: [Bluez-devel] how to do asynchronous device inquiry?
Date: Tue, 29 Jun 2004 14:33:56 +1000 [thread overview]
Message-ID: <20040629043356.GK20139@hp.com> (raw)
In-Reply-To: <ef9938ec040628194321db5d9c@mail.gmail.com>
G'day Albert,
You could certainly fork() a process to exec() hcitool, and when it
finishes it could send the information to your program, through a pipe
that your program is select()ing on, or something similar.
If you knew your application environment well, you could configure the
inquiry to take far less time. e.g. "hcitool inq --length=1" is
supposed to work for 1.28 seconds only, assuming no cache. If you can
change the inquiry parameters of the other device, you can help this to
go even faster.
I've tried running "hcitool inq --length=1" repeatedly until another
device is found. It doesn't seem as reliable as doing a full inquiry.
You could use threads. Erk.
But how to implement it asynchronously all in one process using an event
model ... doesn't seem to be a way to do it. Maybe I just can't find
it. Here's how I looked ...
Looking at tools/hcitool.c, an inquiry uses hci_inquiry() function, part
of libbluetooth1 on my system. I'm looking at 2.7.
In libbluetooth1, hci_inquiry() calls ioctl() to do the work. It passes
an hci_inquiry_req struct. I'm not sure what possible flag bits are
valid. IREQ_CACHE_FLUSH is the only one I can see defined.
The ioctl() is handled by kernel function hci_sock_ioctl() in
net/bluetooth/hci_sock.c which dispatches it to hci_inquiry() in
net/bluetooth/hci_core.c and there doesn't seem to be any clear support
for doing the inquiry asynchronously. I'm looking at 2.6.6.
Warning though; in hci_request() in the hci_core.c file, all requests to
the device are serialised. Multiple attempts to do hci_inquiry() will
be queued.
--
James Cameron
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
next prev parent reply other threads:[~2004-06-29 4:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-29 2:43 [Bluez-devel] how to do asynchronous device inquiry? Albert Huang
2004-06-29 4:33 ` James Cameron [this message]
2004-06-29 21:37 ` Marcel Holtmann
2004-06-30 1:48 ` James Cameron
2004-06-30 9:09 ` Marcel Holtmann
2004-06-29 9:21 ` Marcel Holtmann
2004-06-29 18:30 ` Albert Huang
2004-06-29 21:50 ` Marcel Holtmann
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=20040629043356.GK20139@hp.com \
--to=james.cameron@hp.com \
--cc=ashuang@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox