From: Filippo Giunchedi <filippo@esaurito.net>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 4/4] test/agent.c: pairing via CreatePairedDevice
Date: Sun, 28 Jun 2009 20:27:39 +0200 [thread overview]
Message-ID: <1246213659-24559-4-git-send-email-filippo@esaurito.net> (raw)
In-Reply-To: <1246213659-24559-1-git-send-email-filippo@esaurito.net>
Introduce mandatory target argument for remote address
---
test/agent.c | 46 +++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/test/agent.c b/test/agent.c
index 30af926..7f7bfe4 100644
--- a/test/agent.c
+++ b/test/agent.c
@@ -276,6 +276,39 @@ static const DBusObjectPathVTable agent_table = {
.message_function = agent_message,
};
+static int create_paired_device(DBusConnection *conn, const char *device_path,
+ const char *agent_path,
+ const char *capabilities, const char *target)
+{
+ dbus_bool_t success;
+ DBusMessage *msg;
+
+ msg = dbus_message_new_method_call("org.bluez", device_path,
+ "org.bluez.Adapter", "CreatePairedDevice");
+ if (!msg) {
+ fprintf(stderr, "Can't allocate new method call\n");
+ return -1;
+ }
+
+ dbus_message_append_args(msg, DBUS_TYPE_STRING, &target,
+ DBUS_TYPE_OBJECT_PATH, &agent_path,
+ DBUS_TYPE_STRING, &capabilities,
+ DBUS_TYPE_INVALID);
+
+ success = dbus_connection_send(conn, msg, NULL);
+
+ dbus_message_unref(msg);
+
+ if (!success) {
+ fprintf(stderr, "Not enough memory for message send\n");
+ return -1;
+ }
+
+ dbus_connection_flush(conn);
+
+ return 0;
+}
+
static char *get_device(const char *device)
{
char *path;
@@ -290,7 +323,7 @@ static void usage(void)
printf("Bluetooth agent ver %s\n\n", VERSION);
printf("Usage:\n"
- "\tagent [--device interface] [--path agent-path] <passkey>\n"
+ "\tagent [--device interface] [--path agent-path] <passkey> <target_device>\n"
"\n");
}
@@ -309,7 +342,7 @@ int main(int argc, char *argv[])
struct sigaction sa;
DBusConnection *conn;
char match_string[128], default_path[128], *device_id = NULL;
- char *device_path = NULL, *agent_path = NULL;
+ char *device_path = NULL, *agent_path = NULL, *target = NULL;
int opt;
snprintf(default_path, sizeof(default_path),
@@ -345,13 +378,15 @@ int main(int argc, char *argv[])
argv += optind;
optind = 0;
- if (argc < 1) {
+ if (argc < 2) {
usage();
exit(1);
}
passkey = strdup(argv[0]);
+ target = strdup(argv[1]);
+
if (!agent_path)
agent_path = strdup(default_path);
@@ -370,6 +405,11 @@ int main(int argc, char *argv[])
return -1;
}
+ if (create_paired_device(conn, device_path, agent_path, capabilities, target) < 0) {
+ dbus_connection_unref(conn);
+ exit(1);
+ }
+
if (!dbus_connection_add_filter(conn, agent_filter, NULL, NULL))
fprintf(stderr, "Can't add signal filter");
--
1.6.3.1
prev parent reply other threads:[~2009-06-28 18:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-28 18:27 [PATCH 1/4] test/agent.c: honour commandline --device Filippo Giunchedi
2009-06-28 18:27 ` [PATCH 2/4] test/agent.c: update dbus API usage Filippo Giunchedi
2009-06-28 18:27 ` [PATCH 3/4] test/agent.c: register object path only Filippo Giunchedi
2009-06-30 13:34 ` Johan Hedberg
2009-06-30 15:16 ` [PATCH 1/3] test/agent.c: honour commandline --device Filippo Giunchedi
2009-06-30 15:16 ` [PATCH 2/3] test/agent.c: update dbus API usage Filippo Giunchedi
2009-06-30 15:16 ` [PATCH 3/3] test/agent.c: pairing via CreatePairedDevice Filippo Giunchedi
2009-06-30 15:39 ` Johan Hedberg
2009-06-30 15:48 ` Filippo Giunchedi
2009-06-28 18:27 ` Filippo Giunchedi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1246213659-24559-4-git-send-email-filippo@esaurito.net \
--to=filippo@esaurito.net \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox