* [Bluez-users] problem with two adapters in extracting the record of the discovered devices.
@ 2007-10-16 6:42 rohit puri
0 siblings, 0 replies; only message in thread
From: rohit puri @ 2007-10-16 6:42 UTC (permalink / raw)
To: Bluez-users
[-- Attachment #1.1: Type: text/plain, Size: 2722 bytes --]
Hi all
I want to accomplish the following tasks using the Dbus interface.
1.
I am using the two bluetooth adapters
the first adapter is searching for the near by devices.
2.
The second adapter is used to find out the SDP records of the
discoverd devices.
Here In my code I am using theDBusGProxy HCI0 object to search for the near
by bluetooth devices, secondly HCI1 object is used to extract the channel
number of the discoverd devices.
In summary
first adapter (HCI0) is continuously searching for the near by devices.
And second adapter (HCI1)is used to find out the Records of the discovered
devices.
In my code it discovers the near by devices ,gives there channel number but
crashes.
Here I am attaching the relevant and minimal code.
I want to know whether is this the right way to proceed or there exists any
other alternative.
/*function for device discovery attached with signal*/
static void remote_device_found(DBusGProxy *object, const char
*address, const unsigned int class, const int rssi, gpointer user_data)
{
GError *error = NULL;
/*function to extract the channel*/
int channel = get_remote_service_channel ( object,address,"OPP" );
g_print ("Channel returned is %d\n",channel);
}
static void discovery_started(DBusGProxy *object, gpointer user_data)
{
g_print("Signal: DiscoveryStarted()\n");
}
/* Function Defination for extracting the channel */
gint
get_remote_service_channel (DBusGProxy *obj, const gchar *address, const
gchar *uuid)
{
GError *error = NULL;
GArray *handle_array = NULL;
GArray *record_array = NULL;
sdp_record_t *sdp_record = NULL;
gint scanned;
sdp_list_t *protos = NULL;
gint channel = -1;
g_print ("hi i am here\n");
/* find services that match our UUID */
DBusGConnection * bus = NULL;
bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
/*another HCI1 adapter used to extract the SDP Records*/
DBusGProxy* obj1 = dbus_g_proxy_new_for_name(bus, "org.bluez",
"/org/bluez/hci1", "org.bluez.Adapter");
if (!dbus_g_proxy_call (obj1,
"GetRemoteServiceHandles", &error,
G_TYPE_STRING, address,
G_TYPE_STRING, uuid,
G_TYPE_INVALID,
DBUS_TYPE_G_UINT_ARRAY, &handle_array,
G_TYPE_INVALID)) {
g_warning (error->message);
g_error_free (error);
goto out;
}
if (!handle_array) {
goto out;
}
/* get service record for the first service handle */
if (!handle_array->data)
goto out;
if (!dbus_g_proxy_call (obj1,
"GetRemoteServiceRecord", &error, G_TYPE_STRING, address,
G_TYPE_UINT, *((guint32 *)handle_array->data), G_TYPE_INVALID,
DBUS_TYPE_G_UINT_ARRAY, &record_array, G_TYPE_INVALID)) {
g_warning (error->message);
g_error_free (error);
goto out;
}
Any help is appreciated.
Regards,
Rohit
[-- Attachment #1.2: Type: text/html, Size: 6437 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-16 6:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-16 6:42 [Bluez-users] problem with two adapters in extracting the record of the discovered devices rohit puri
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox