Re: [Bluez-devel] how to do asynchronous device inquiry?

Marcel Holtmann
2004-06-29T21:37:35Z

Hi James,

> 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.

very bad idea :(

> You could use threads. Erk.

Possible, but not needed.

> 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 ...

You don't looked into the details. The inquiry ioctl() is one way. The
other one is the HCI raw socket. Open and bind a device and then set an
event filter on it. Send an inquiry command according to the spec. and
listen for the incoming inquiry result events.

> 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.

It is impossible to run two inquiries at the same time. The Bluetooth
chip won't allow and even the HCI core don't accepts it. There is the
INQUIRY flag that will set if an inquiry is in progress.