LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-15-2009, 05:50 AM   #1
thilaga
LQ Newbie
 
Registered: Apr 2009
Posts: 9

Rep: Reputation: 0
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;
}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
dbus "rm /var/run/dbus/Desktop can't remove..." longus Slackware 6 12-15-2008 03:33 AM
Fedora Core 9 update dbus.exception & dbus.proxies & DBus.Error.AccessDenied errors trien27 Fedora 1 12-08-2008 11:23 PM
Regd Xen nolinuxnollife Linux - Software 2 03-17-2008 04:38 AM
dbus and bluez chopp Slackware 3 02-20-2006 12:49 AM
how to determine cpu usage, memory usage, I/O usage by a particular user logged on li rags2k Programming 4 08-21-2004 04:45 AM


All times are GMT -5. The time now is 02:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration