Possible Patch: list paired devices
Marcel,
I noticed that there is no way to list paired devices from hcitool/hciconfig,
at least I couldn't find a way to do so. Here is a proposed patch to
hcitool which will show a list of paired devices.
I'm not sure if this is the right solution, since it requires hcitool to be run with effective permissions to access the linkkeys file (e.g. root on my system). If there is a better way let me know.
Also, will the patch for 128 bit UUID searching in sdptool get merged into CVS, or did I mess something up again?
Regards,
-Denis
Index: tools/hcitool.c
===================================================================
RCS file: /cvsroot/bluez/utils/tools/hcitool.c,v
retrieving revision 1.85
hcitool.c +65 -0
@@ -1865,6 +1865,70 @@free (cr); } +static int dev_paired (int dd,int dev_id,long arg) +{ +void print_key (char *key,char *value,void *data) + { +printf ("%s\n" , key); + } + +struct hci_dev_info di = { dev_id: dev_id }; +char filename[PATH_MAX +1 ]; +char addr[18 ]; + +if (ioctl (dd,HCIGETDEVINFO , (void *) &di)) +return 0 ; + +ba2str (&di.bdaddr, addr); + +snprintf (filename,PATH_MAX ,"%s/%s/linkkeys" ,STORAGEDIR , addr); + +printf ("Devices paired to %s:\n" , addr); +textfile_foreach (filename, print_key,NULL ); +printf ("\n" ); + +return 0 ; +} + +/* List pairings */ + +static struct option paired_options[] = { + {"help" ,0 ,0 ,'h' }, + {0 ,0 ,0 ,0 } +}; + +static char *paired_help = +"Usage:\n" +"\tpaired\n" ; + +static void cmd_paired (int dev_id,int argc,char **argv) +{ +int dd, opt; + +for_each_opt (opt, cc_options,NULL ) { +switch (opt) { +default : +printf (paired_help); +return ; + } + } + +if (dev_id <0 ) { +hci_for_each_dev (HCI_UP , dev_paired,0 ); +return ; + } + + dd =hci_open_dev (dev_id); +if (dd <0 ) { +perror ("HCI device open failed" ); +exit (1 ); + } + +dev_paired (dd, dev_id,0 ); + +hci_close_dev (dd); +} +/* Read clock offset */ static struct option clkoff_options[] = {
@@ -2051,6 +2115,7 @@ { "auth", cmd_auth, "Request authentication" }, { "enc", cmd_enc, "Set connection encryption" }, { "key", cmd_key, "Change connection link key" }, + { "paired", cmd_paired, "Show paired devices" }, { "clkoff", cmd_clkoff, "Read clock offset" }, { "clock", cmd_clock, "Read local or remote clock" }, { NULL, NULL, 0 }
Marcel Holtmann
maintainerHi Denis,
Quoted 7 lines
I noticed that there is no way to list paired devices from hcitool/hciconfig,
at least I couldn't find a way to do so. Here is a proposed patch to
hcitool which will show a list of paired devices.I'm not sure if this is the right solution, since it requires hcitool to be run with effective permissions to access the linkkeys file (e.g. root on my system). If there is a better way let me know.
you can use standard tools like grep and awk to get this information and since we have the limitation with the root access, I am not going to add this. Use the new D-Bus interface to retrieve this information.
Quoted 2 lines
Also, will the patch for 128 bit UUID searching in sdptool get merged into CVS, or did I mess something up again?
The patch is in my todo stack, but I haven't looked at it.
Regards
Marcel
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel