public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [Bluez-users] problem in discovering device using dbus APIs
@ 2007-10-09 12:07 rohit puri
  0 siblings, 0 replies; only message in thread
From: rohit puri @ 2007-10-09 12:07 UTC (permalink / raw)
  To: Bluez-users


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

hi all,

I have trimmed the program comes with gnome. The program compiles  but
doesnt give any output.There may be some problem.here I am attaching the
code.

#include<stdlib.h>
#include<stdio.h>
#include<dbus-1.0/dbus/dbus.h>
#include <dbus/dbus-glib.h>
#include <string.h>
#include<glib-object.h>
#include "marshal.h"

extern void marshal_VOID__STRING_UINT_INT (GClosure     *closure,
                GValue       *return_value,
                guint         n_param_values,
                const GValue *param_values,
                gpointer      invocation_hint,
                gpointer      marshal_data);



extern void marshal_VOID__STRING_STRING (GClosure     *closure,
                GValue       *return_value,
                guint         n_param_values,
                const GValue *param_values,
                gpointer      invocation_hint,
                gpointer      marshal_data);

static void remote_device_found(DBusGProxy *object, const char *address,
                const unsigned int class, const int rssi, gpointer
user_data)
{
        //DBusGConnection *conn = user_data;

        /* bluetooth_device_store_add_device(BLUETOOTH_DEVICE_STORE(store),
address, class, rssi);*/


        printf("(%s )\n :Remote device address  found",address);
#if 0
        object = dbus_g_proxy_new_for_name(conn, "org.bluez",
                        "/org/bluez/hci0", "org.bluez.Test");

        dbus_g_proxy_call(object, "AuditRemoteDevice", NULL, G_TYPE_STRING,
address, G_TYPE_INVALID);
#endif
}

static void discovery_started(DBusGProxy *object, gpointer user_data)
{
        printf("devices discovered: DiscoveryStarted()\n");
}


static void setup_dbus(DBusGConnection *conn)
{
        /*creating the proxy object*/
        DBusGProxy *object;
        /*creating a message and sending a message to the remote object
blocking call*/
        object = dbus_g_proxy_new_for_name(conn, "org.bluez",
"/org/bluez/hci0", "org.bluez.Adapter");
        /*registering a marshal */
        dbus_g_object_register_marshaller(marshal_VOID__STRING_UINT_INT,
G_TYPE_NONE, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INT, G_TYPE_INVALID);

        dbus_g_proxy_add_signal(object, "RemoteDeviceFound", G_TYPE_STRING,
G_TYPE_UINT, G_TYPE_INT, G_TYPE_INVALID);

        dbus_g_proxy_connect_signal(object, "RemoteDeviceFound",
G_CALLBACK(remote_device_found), conn, NULL);

        dbus_g_proxy_add_signal(object, "DiscoveryStarted", G_TYPE_INVALID);

        dbus_g_proxy_connect_signal(object, "DiscoveryStarted",
G_CALLBACK(discovery_started), NULL, NULL);
}

int main(int argc, char *argv[])
{
        DBusGConnection *conn;
        GError *error = NULL;
        g_type_init();

        /*getting the system bus connection*/

 conn = 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);
        }
        setup_dbus(conn);
        DBusGProxy *object;
        object = dbus_g_proxy_new_for_name(conn, "org.bluez",
                        "/org/bluez/hci0", "org.bluez.Adapter");

        dbus_g_proxy_call(object, "DiscoverDevices", &error,
                                G_TYPE_INVALID, G_TYPE_INVALID);

        if (error != NULL) {
                printf ("\n Error ... message is %s",error->message);
        }
        dbus_g_connection_unref(conn);
        return 0;
can some one figure out the problem.


Thanks
Rohit

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

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

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

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

_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-10-09 12:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-09 12:07 [Bluez-users] problem in discovering device using dbus APIs rohit puri

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