From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Message-ID: <49f5aca0804070731j7d3a7349ta29461fad6808231@mail.gmail.com> Date: Mon, 7 Apr 2008 16:31:14 +0200 From: "Pedro Vivancos" To: bluez-devel@lists.sourceforge.net MIME-Version: 1.0 Subject: [Bluez-devel] C program for capturing AnswerRequested signal Reply-To: BlueZ development List-Id: BlueZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============1804525839==" Sender: bluez-devel-bounces@lists.sourceforge.net Errors-To: bluez-devel-bounces@lists.sourceforge.net --===============1804525839== Content-Type: multipart/alternative; boundary="----=_Part_1615_3372406.1207578674928" ------=_Part_1615_3372406.1207578674928 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 #include #include #include #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; } ------=_Part_1615_3372406.1207578674928 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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;
}

------=_Part_1615_3372406.1207578674928-- --===============1804525839== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- 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 --===============1804525839== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel --===============1804525839==--