Dear all
I wrote a small c program to continuously inquire for nearby bluetooth devices and record their address, name and time of discovery. However, the program always seems to return a list of devices found earlier, even when the discovered device has been switched off.
Following is part of the code, which does 5 rounds of inquiry, largely derived from Bastian Ballmann's hciscan program. Is there anyway I can erase records of previously found devices and do a fresh inquiry everytime?
Thanks.
Teck Ping
for(j = 1; j <= 5; j++)
{
for(i = 0; i < num_rsp; i++)
{
memset(name, 0, sizeof(name));
if(hci_read_remote_name(dd, &(info+i)->bdaddr, sizeof(name), name, 100000) < 0)
{
strcpy(name, "na");
}
baswap(&bdaddr, &(info+i)->bdaddr);
time_t now;
time(&now);
printf("%d\t%s\t%s\t%s", j, batostr(&bdaddr), name, ctime(&now));
/*a+ will append text to the end of file*/
ptr = fopen("data.txt", "a+");
fprintf(ptr,"%d;%s;%s;%s", j, batostr(&bdaddr), name, ctime(&now));
fclose(ptr); /*close the opened file*/
}
}
Hi Teck,
> I wrote a small c program to continuously inquire for nearby bluetooth
> devices and record their address, name and time of discovery. However,
> the program always seems to return a list of devices found earlier,
> even when the discovered device has been switched off.
>
> Following is part of the code, which does 5 rounds of inquiry, largely
> derived from Bastian Ballmann's hciscan program. Is there anyway I can
> erase records of previously found devices and do a fresh inquiry
> everytime?
your code doesn't use hci_inquiry() at all. However you should take a
look a the IREQ_CACHE_FLUSH flag.
Regards
Marcel
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel