public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: "Pedro Vivancos" <pedro.vivancos@vocali.net>
To: bluez-devel@lists.sourceforge.net
Subject: [Bluez-devel] C program for capturing AnswerRequested signal
Date: Mon, 7 Apr 2008 16:31:14 +0200	[thread overview]
Message-ID: <49f5aca0804070731j7d3a7349ta29461fad6808231@mail.gmail.com> (raw)


[-- 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

             reply	other threads:[~2008-04-07 14:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-07 14:31 Pedro Vivancos [this message]
2008-04-07 17:35 ` [Bluez-devel] C program for capturing AnswerRequested signal Luiz Augusto von Dentz

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=49f5aca0804070731j7d3a7349ta29461fad6808231@mail.gmail.com \
    --to=pedro.vivancos@vocali.net \
    --cc=bluez-devel@lists.sourceforge.net \
    /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