* [Bluez-devel] Possible Patch: list paired devices
@ 2006-02-21 8:36 Denis KENZIOR
2006-02-21 11:37 ` Marcel Holtmann
0 siblings, 1 reply; 2+ messages in thread
From: Denis KENZIOR @ 2006-02-21 8:36 UTC (permalink / raw)
To: bluez-devel
[-- Attachment #1: Type: text/plain, Size: 548 bytes --]
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
[-- Attachment #2: bluez-hcitool.patch --]
[-- Type: text/x-diff, Size: 1984 bytes --]
Index: tools/hcitool.c
===================================================================
RCS file: /cvsroot/bluez/utils/tools/hcitool.c,v
retrieving revision 1.85
diff -u -r1.85 hcitool.c
--- tools/hcitool.c 18 Jan 2006 17:45:51 -0000 1.85
+++ tools/hcitool.c 21 Feb 2006 08:25:45 -0000
@@ -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 }
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [Bluez-devel] Possible Patch: list paired devices
2006-02-21 8:36 [Bluez-devel] Possible Patch: list paired devices Denis KENZIOR
@ 2006-02-21 11:37 ` Marcel Holtmann
0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2006-02-21 11:37 UTC (permalink / raw)
To: bluez-devel
Hi Denis,
> 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.
> 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
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-02-21 11:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-21 8:36 [Bluez-devel] Possible Patch: list paired devices Denis KENZIOR
2006-02-21 11:37 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).