LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   regd usage of bluez-dbus (https://www.linuxquestions.org/questions/linux-newbie-8/regd-usage-of-bluez-dbus-733008/)

thilaga 06-15-2009 05:50 AM

regd usage of bluez-dbus
 
Hi,

I am trying to execute the following program. It is compiling properly, but while executing it gives the following error.

Method "StartDiscovery" with signature "" on interface "org.bluez.Adapter" doesn't exist

I am suspecting on the bluez version which I have.
In that case

1. how to check what are all the methods supported by bluez stack available in the system.
2. How to configure the latest bluez stack and what are its dependent libraries.

Thanks for your help.

#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 device_found(const char *address, int values)
{
g_print(" In DeviceFound SIgnal\n Device address: %s \n",address);
}

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, *mgr = 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);
}

obj = dbus_g_proxy_new_for_name(bus, "org.bluez", "/org/bluez/hci0", "org.bluez.Adapter");
if (obj == NULL)
{
g_print("OBJ failed\n");
g_printe//rr("Obj failed: %s\n", error->message);
g_error_free(error);
exit(EXIT_FAILURE);
}

mgr = dbus_g_proxy_new_for_name(bus, "org.bluez", "/", "org.bluez.Manager");
if (obj == NULL)
{
g_print("OBJ failed\n");
g_printerr("Obj failed: %s\n", error->message);
g_error_free(error);
exit(EXIT_FAILURE);
}

dbus_g_object_register_marshaller(marshal_VOID__STRING_INT, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INVALID);
dbus_g_proxy_add_signal(obj, "DeviceFound", G_TYPE_STRING, G_TYPE_INT, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(obj, "DeviceFound", G_CALLBACK(device_found), bus, NULL);

g_print(" Call start discovery\n");
dbus_g_proxy_call(obj, "StartDiscovery", &error, G_TYPE_INVALID, G_TYPE_INVALID);
g_print(" Call List Adapters\n");
//dbus_g_proxy_call(mgr, "ListAdapters", &error, G_TYPE_INVALID, G_TYPE_INVALID);
if (error != NULL)
{
g_printerr("Failed to list adpaters: %s\n", error->message);
g_error_free(error);
exit(EXIT_FAILURE);
}
else
{
g_printf("Call is success\n");
}
run_mainloop ();
dbus_g_connection_flush (bus);
g_main_loop_run (loop);
dbus_g_connection_unref(bus);

return 0;
}


All times are GMT -5. The time now is 07:36 AM.