mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-06 20:45:54 +01:00
use malloc to allocate storate for hci_inquiry instead of the
stack. That *seems* to fix it always returning 0, something that changed with newer version of linux or libbluetooth or who knows what. BT still doesn't work from linux, but this is a necessary start.
This commit is contained in:
parent
a0ae117e35
commit
f288fe2860
1 changed files with 15 additions and 13 deletions
|
@ -519,25 +519,27 @@ typedef gboolean (*bt_proc)( const bdaddr_t* bdaddr, int socket, void* closure )
|
||||||
static void
|
static void
|
||||||
btDevsIterate( bt_proc proc, void* closure )
|
btDevsIterate( bt_proc proc, void* closure )
|
||||||
{
|
{
|
||||||
int id, socket;
|
|
||||||
LOG_FUNC();
|
LOG_FUNC();
|
||||||
|
int id = hci_get_route( NULL );
|
||||||
id = hci_get_route( NULL );
|
int socket = hci_open_dev( id );
|
||||||
socket = hci_open_dev( id );
|
|
||||||
if ( id >= 0 && socket >= 0 ) {
|
if ( id >= 0 && socket >= 0 ) {
|
||||||
long flags = IREQ_CACHE_FLUSH;
|
int flags = IREQ_CACHE_FLUSH;
|
||||||
inquiry_info inqInfo[RESPMAX];
|
inquiry_info* iinfo = (inquiry_info*)
|
||||||
inquiry_info* inqInfoP = inqInfo;
|
malloc( RESPMAX * sizeof(inquiry_info) );
|
||||||
int count = hci_inquiry( id, 8/*wait seconds*/,
|
int count = hci_inquiry( id, 8/*wait seconds*/,
|
||||||
RESPMAX, NULL, &inqInfoP, flags );
|
RESPMAX, NULL, &iinfo, flags );
|
||||||
|
XP_LOGF( "%s: hci_inquiry=>%d", __func__, count );
|
||||||
int ii;
|
int ii;
|
||||||
|
if ( 0 < count ) {
|
||||||
for ( ii = 0; ii < count; ++ii ) {
|
for ( ii = 0; ii < count; ++ii ) {
|
||||||
const bdaddr_t* bdaddr = &inqInfo[ii].bdaddr;
|
const bdaddr_t* bdaddr = &iinfo[ii].bdaddr;
|
||||||
if ( !(*proc)( bdaddr, socket, closure ) ) {
|
if ( !(*proc)( bdaddr, socket, closure ) ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
close( socket );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue