public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [Bluez-devel] C program for capturing AnswerRequested signal
@ 2008-04-07 14:31 Pedro Vivancos
  2008-04-07 17:35 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 2+ messages in thread
From: Pedro Vivancos @ 2008-04-07 14:31 UTC (permalink / raw)
  To: bluez-devel


[-- Attachment #1.1: Type: text/plain, Size: 2024 bytes --]

Dear friends,

I wrote a C program to capture the "AnswerRequested" signal from a bluetooth
headset but it doesn't work. It is based on the DeviceDiscover Howto of the
wiki audio section but it doesn't do anything.

Can you help me to find the error?

Thanks in advance

/* Build with: */
/* glib-genmarshal --prefix=marshal marshal.list --header > marshal.h */
/* glib-genmarshal --prefix=marshal marshal.list --body > marshal.c */
/* gcc `pkg-config --libs --cflags glib-2.0 dbus-1 dbus-glib-1` bluetooth.c
marshal.c -o bluetooth */

#include <stdlib.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
#include <glib-object.h>

#include "marshal.h"

static GMainLoop *loop = NULL;

static void answer_requested(DBusGProxy *object, gpointer user_data)
{
        g_print("Signal: AnswerRequested()\n");
}


static void run_mainloop (void)
{
        GMainContext *ctx;

        ctx = g_main_loop_get_context (loop);

        while (g_main_context_pending (ctx))
                g_main_context_iteration (ctx, FALSE);
}

int main(int argc, char* argv[])
{
        GError *error = NULL;
        DBusGConnection * bus = NULL;
        DBusGProxy * obj = NULL;

        g_type_init();
        g_log_set_always_fatal (G_LOG_LEVEL_WARNING);
        loop = g_main_loop_new (NULL, FALSE);

        bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
        if (error != NULL)
        {
                g_printerr("Connecting to system bus failed: %s\n",
error->message);
                g_error_free(error);
                exit(EXIT_FAILURE);
        }

        // o probar con /org/bluez/audio
        obj = dbus_g_proxy_new_for_name(bus, "org.bluez",
"00:16:94:03:60:1B", "org.bluez.audio.Headset");

        dbus_g_proxy_add_signal(obj, "AnswerRequested", G_TYPE_INVALID);
        dbus_g_proxy_connect_signal(obj, "AnswerRequested",
G_CALLBACK(answer_requested), bus, NULL);

        run_mainloop ();
        dbus_g_connection_flush (bus);
        g_main_loop_run (loop);
        dbus_g_connection_unref(bus);

        return 0;
}

[-- Attachment #1.2: Type: text/html, Size: 3528 bytes --]

[-- Attachment #2: Type: text/plain, Size: 325 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Register now and save $200. Hurry, offer ends at 11:59 p.m., 
Monday, April 7! Use priority code J8TLD2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

[-- Attachment #3: Type: text/plain, Size: 164 bytes --]

_______________________________________________
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:[~2008-04-07 17:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-07 14:31 [Bluez-devel] C program for capturing AnswerRequested signal Pedro Vivancos
2008-04-07 17:35 ` Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox