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

Marcel Holtmann
2004-06-30T09:09:34Z

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 :(
>
> Aww, it's just another way to do it, that doesn't require as much
> dependency or learning. ;-)

It is not fork() that is bad. It the combination of exec() and hcitool
you propose to use. If you fork or use a thread then use hci_inquiry().

> > 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.
>
> I stand corrected.
>
> Albert, there is a good example of this in src/btctl-discovery-source.c
> in the libbtctl-0.4.1 package.
> http://usefulinc.com/software/gnome-bluetooth/
>
> btctl_discovery_source_new()
> The hci device is opened, then set O_NONBLOCK, and the event filters are
> set. There's no sign of binding.

If you use hci_open_dev() the binding is done by that call.