* [PATCH] test/agent.c: Wait for reply from CreatePairedDevice before exiting
@ 2011-06-20 4:11 Steven Luo
2011-06-28 7:43 ` Johan Hedberg
0 siblings, 1 reply; 2+ messages in thread
From: Steven Luo @ 2011-06-20 4:11 UTC (permalink / raw)
To: linux-bluetooth
This matches the behavior of the Python sample agent, and is needed to
get my Bluetooth keyboard to pair.
Signed-off-by: Steven Luo <steven@steven676.net>
---
diff -urpN a/test/agent.c b/test/agent.c
--- a/test/agent.c 2011-03-28 11:10:44.000000000 -0700
+++ b/test/agent.c 2011-06-19 03:19:12.000000000 -0700
@@ -41,6 +41,7 @@ static int do_reject = 0;
static volatile sig_atomic_t __io_canceled = 0;
static volatile sig_atomic_t __io_terminated = 0;
+static volatile sig_atomic_t exit_on_release = 1;
static void sig_term(int sig)
{
@@ -286,7 +287,8 @@ static DBusHandlerResult release_message
if (!__io_canceled)
fprintf(stderr, "Agent has been released\n");
- __io_terminated = 1;
+ if (exit_on_release)
+ __io_terminated = 1;
reply = dbus_message_new_method_return(msg);
if (!reply) {
@@ -414,6 +416,13 @@ static int unregister_agent(DBusConnecti
return 0;
}
+static void create_paired_device_reply(DBusPendingCall *pending,
+ void *user_data)
+{
+ __io_terminated = 1;
+ return;
+}
+
static int create_paired_device(DBusConnection *conn, const char *adapter_path,
const char *agent_path,
const char *capabilities,
@@ -421,6 +430,7 @@ static int create_paired_device(DBusConn
{
dbus_bool_t success;
DBusMessage *msg;
+ DBusPendingCall *pending;
msg = dbus_message_new_method_call("org.bluez", adapter_path,
"org.bluez.Adapter",
@@ -435,7 +445,12 @@ static int create_paired_device(DBusConn
DBUS_TYPE_STRING, &capabilities,
DBUS_TYPE_INVALID);
- success = dbus_connection_send(conn, msg, NULL);
+ exit_on_release = 0;
+ success = dbus_connection_send_with_reply(conn, msg, &pending, -1);
+ if (pending)
+ dbus_pending_call_set_notify(pending,
+ create_paired_device_reply,
+ NULL, NULL);
dbus_message_unref(msg);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] test/agent.c: Wait for reply from CreatePairedDevice before exiting
2011-06-20 4:11 [PATCH] test/agent.c: Wait for reply from CreatePairedDevice before exiting Steven Luo
@ 2011-06-28 7:43 ` Johan Hedberg
0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2011-06-28 7:43 UTC (permalink / raw)
To: Steven Luo; +Cc: linux-bluetooth
Hi Steven,
On Sun, Jun 19, 2011, Steven Luo wrote:
> This matches the behavior of the Python sample agent, and is needed to
> get my Bluetooth keyboard to pair.
>
> Signed-off-by: Steven Luo <steven@steven676.net>
> ---
Applied (with the signed-off-by line removed). Thanks.
Johan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-06-28 7:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-20 4:11 [PATCH] test/agent.c: Wait for reply from CreatePairedDevice before exiting Steven Luo
2011-06-28 7:43 ` Johan Hedberg
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).