Simultaneous scan and request
"Ryan Nevell" <[email protected]>
| Newsgroups | gmane.linux.bluez.user |
|---|---|
| Message-ID | <[email protected]> |
I'm trying to scan for all available devices, and query them for their name
as soon as possible, without waiting for the scan to complete.
However, if I read a EVT_INQUIRY_RESULT and then attempt to issue a
OCF_REMOTE_NAME_REQ on the same socket, it always returns with a 0x07 error
(out of memory?). The same thing happens if I use hci_read_remote_name. But
if I wait until EVT_INQUIRY_COMPLETE is received and then issue
hci_read_remote_name, everything works great.
I've also tried opening a 2nd socket with another call to hci_open_dev, but
it appears to be just a symbolic link to the same device. It has a different
fd number, but I receive the (same) data from both sockets, and it still
gives IO error.
So what is the trick to getting simultaneous commands like this working?
Thank you!
Some pseudo code:
/* this will be the socket accepting EVT_INQUIRY_RESULT */
scanner = hci_open_dev( 0 );
/* Set up a filter. If somebody could explain how this works? */
hci_filter_clear( &flt );
hci_filter_all_events( &flt );
hci_filter_set_ptype( HCI_EVENT_PKT, &flt );
setsockopt( sock, SOL_HCI, HCI_FILTER, &flt, sizeof(flt))
/* Send inquiry request - doesn't use ioctl like hid_inquiry does */
guint8 packet[5] = { 0x33, 0x8b, 0x9e, 0x08, 0xff }; (8 * 1.25 seconds
duration, 255 max response)
hci_send_cmd( sock, OGF_LINK_CTL, OCF_INQUIRY, sizeof(packet), packet)
while(1){
select( [scanner FD_SET] ); // Wait for some response
recv( scanner, resp, ..); // Read the response
if (resp[0] == EVT_INQUIRY_RESULT){
bacpy(bdaddr, resp + someoffset)
hci_read_remote_name( scanner, bdaddr, ..., 0) // Fails
"Input/output" error
// Note that this also fails:
dd = hci_open_dev( 0 )
hci_read_remote_name( dd, bdaddr, ..., 0) // Fails "Input/output"
error
hci_close_close( dd )
}
if (resp[0] == EVT_INQUIRY_COMPLETE){
hci_read_remote_name( scanner, bdaddr, ..., 0) // This one works!
break;
}
}
hci_close_dev( scanner );
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users