From: "rohit puri" <rohitpuri.rohit@gmail.com>
To: Bluez-users@lists.sourceforge.net
Subject: [Bluez-users] problem with two adapters in extracting the record of the discovered devices.
Date: Tue, 16 Oct 2007 12:12:27 +0530 [thread overview]
Message-ID: <d5d240eb0710152342i35564c90jaf62cd38db68d36@mail.gmail.com> (raw)
[-- 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
reply other threads:[~2007-10-16 6:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d5d240eb0710152342i35564c90jaf62cd38db68d36@mail.gmail.com \
--to=rohitpuri.rohit@gmail.com \
--cc=Bluez-users@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox