Skip to contentSkip to conversation

RemoteNameRequested signal during discovery patch

Bluez-devel Frederic Danis 3 participants 8 messages Mar 9, 2007 – Apr 24, 2007 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Hello,

I wrote a little patch to add a DBus signal when a remote name is asked by the service daemon during discovery, so discovery applications can display this information to user.

Regards

Fred

Signature · 7 lines
-----------------------------------------------
It is not by improving the oil lamp that one invents the electric bulb!
-----------------------------------------------
Danis Frederic                   Access Company
Software engineer
Mail : mailto:[email protected]
-----------------------------------------------

? hcid/.deps
? hcid/.libs
? hcid/Makefile
? hcid/Makefile.in
? hcid/hcid
? hcid/lexer.c
? hcid/parser.c
? hcid/parser.h
Index: hcid/dbus-api.txt
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-api.txt,v retrieving revision 1.108

dbus-api.txt +5 -0
diff -u -r1.108 dbus-api.txt
@@ -1021,6 +1021,11 @@
 			This signal will be sent every time the service daemon
 			tries to resolve a remote and this fails.
 
+		void RemoteNameRequested(string address)
+
+			This signal will be sent every time the service daemon
+			tries to resolve a remote name during discovery.
+
 		void RemoteAliasChanged(string address, string alias)
 
 			After changing an alias with SetRemoteAlias this

Index: hcid/dbus-hci.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-hci.c,v
retrieving revision 1.16

dbus-hci.c +18 -9
diff -u -r1.16 dbus-hci.c
@@ -1005,7 +1005,7 @@
 
 	/* send at least one request or return failed if the list is empty */
 	do {
-		DBusMessage *failed_signal = NULL;
+		DBusMessage *signal = NULL;
 		struct remote_dev_info *dev = l->data;
 		char *peer_addr;
 		bdaddr_t tmp;
@@ -1023,7 +1023,7 @@
 		if (hci_send_req(dd, &rq, 500) < 0) {
 			error("Unable to send the HCI remote name request: %s (%d)",
 						strerror(errno), errno);
-			failed_signal = dev_signal_factory(adapter->dev_id,
+			signal = dev_signal_factory(adapter->dev_id,
 						"RemoteNameFailed",
 						DBUS_TYPE_STRING, &peer_addr,
 						DBUS_TYPE_INVALID);
@@ -1032,21 +1032,30 @@
 		if (rp.status) {
 			error("Remote name request failed with status 0x%02x",
 					rp.status);
-			failed_signal = dev_signal_factory(adapter->dev_id,
+			signal = dev_signal_factory(adapter->dev_id,
 						"RemoteNameFailed",
 						DBUS_TYPE_STRING, &peer_addr,
 						DBUS_TYPE_INVALID);
 		}
 
-		free(peer_addr);
-
-		if (!failed_signal) {
+		if (!signal) {
 			req_sent = 1;
-			break;
+			/* if we are in discovery, inform application of getting name */
+			if (adapter->discov_type & (STD_INQUIRY | PERIODIC_INQUIRY)) {
+				signal = dev_signal_factory(adapter->dev_id,
+							"RemoteNameRequested",
+							DBUS_TYPE_STRING, &peer_addr,
+							DBUS_TYPE_INVALID);
+			} else {
+				free(peer_addr);
+				break;
+			}
 		}
 
-		send_message_and_unref(connection, failed_signal);
-		failed_signal = NULL;
+		free(peer_addr);
+
+		send_message_and_unref(connection, signal);
+		signal = NULL;
 
 		/* if failed, request the next element */
 		/* remove the element from the list */

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#1 lore raw

Hello,

A new version of the patch.
Are you okay with it ?

Thanks

Fred

Quoted 7 lines · Frederic Danis

Hello,

I wrote a little patch to add a DBus signal when a remote name is asked by the service daemon during discovery, so discovery applications can display this information to user.

Regards

Fred

? .deps
? .libs
? Makefile
? Makefile.in
? hcid
? lexer.c
? parser.c
? parser.h
Index: dbus-api.txt
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-api.txt,v retrieving revision 1.110

dbus-api.txt +5 -0
diff -a -u -r1.110 dbus-api.txt
@@ -1030,6 +1030,11 @@
 			This signal will be sent every time the service daemon
 			tries to resolve a remote and this fails.
 
+		void RemoteNameRequested(string address)
+
+			This signal will be sent every time the service daemon
+			tries to resolve a remote name during discovery.
+
 		void RemoteAliasChanged(string address, string alias)
 
 			After changing an alias with SetRemoteAlias this

Index: dbus-hci.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-hci.c,v
retrieving revision 1.16

dbus-hci.c +19 -8
diff -a -u -r1.16 dbus-hci.c
@@ -1005,7 +1005,7 @@
 
 	/* send at least one request or return failed if the list is empty */
 	do {
-		DBusMessage *failed_signal = NULL;
+		DBusMessage *signal = NULL;
 		struct remote_dev_info *dev = l->data;
 		char *peer_addr;
 		bdaddr_t tmp;
@@ -1023,7 +1023,7 @@
 		if (hci_send_req(dd, &rq, 500) < 0) {
 			error("Unable to send the HCI remote name request: %s (%d)",
 						strerror(errno), errno);
-			failed_signal = dev_signal_factory(adapter->dev_id,
+			signal = dev_signal_factory(adapter->dev_id,
 						"RemoteNameFailed",
 						DBUS_TYPE_STRING, &peer_addr,
 						DBUS_TYPE_INVALID);
@@ -1032,21 +1032,32 @@
 		if (rp.status) {
 			error("Remote name request failed with status 0x%02x",
 					rp.status);
-			failed_signal = dev_signal_factory(adapter->dev_id,
+			signal = dev_signal_factory(adapter->dev_id,
 						"RemoteNameFailed",
 						DBUS_TYPE_STRING, &peer_addr,
 						DBUS_TYPE_INVALID);
 		}
 
+		if (!signal) {
+			req_sent = 1;
+			/* if we are in discovery, inform application of getting name */
+			if (adapter->discov_type & (STD_INQUIRY | PERIODIC_INQUIRY)) {
+				signal = dev_signal_factory(adapter->dev_id,
+							"RemoteNameRequested",
+							DBUS_TYPE_STRING, &peer_addr,
+							DBUS_TYPE_INVALID);
+			}
+		}
+
 		free(peer_addr);
 
-		if (!failed_signal) {
-			req_sent = 1;
-			break;
+		if (signal) {
+			send_message_and_unref(connection, signal);
+			signal = NULL;
 		}
 
-		send_message_and_unref(connection, failed_signal);
-		failed_signal = NULL;
+		if (req_sent)
+			break;
 
 		/* if failed, request the next element */
 		/* remove the element from the list */

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#2 lore raw

Hi Frederic,

Quoted 2 lines

A new version of the patch.
Are you okay with it ?

the patch looks okay to me. However I prefer if Claudio or Johan can have an additional look.

My question is why this signal is actually needed. Please elaborate on the use cases of this signal.

Regards

Marcel

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#3 lore raw

Hello Marcel,

This allows discovery applications to inform user when a device name is bei= ng retrieved (changing icon or displaying something like "getting name ..."=
in front =

of the remote device icon). This offers a better user experience because us= er is informed of discovery process.

Regards

Fred

Marcel Holtmann a =E9crit :

Quoted 21 lines

Hi Frederic,
=

Quoted 2 lines

A new version of the patch.
Are you okay with it ?

=

the patch looks okay to me. However I prefer if Claudio or Johan can have an additional look.
=

My question is why this signal is actually needed. Please elaborate on the use cases of this signal.
=

Regards
=

Marcel
=

Quoted 7 lines

=

=

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share y=

our

Quoted 2 lines

opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D=

DEVDEV

Quoted 4 lines

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3DDE=
VDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#4 lore raw
In reply to Marcel Holtmann

Hi,

Quoted 5 lines · Marcel Holtmann
Quoted 2 lines

A new version of the patch.
Are you okay with it ?

the patch looks okay to me. However I prefer if Claudio or Johan can have an additional look.

Looks good to me.

Johan

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#5 lore raw

Hi Johan,

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

A new version of the patch.
Are you okay with it ?

the patch looks okay to me. However I prefer if Claudio or Johan can have an additional look.

Looks good to me.

feel free to commit it to the CVS then.

Regards

Marcel

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#6 lore raw

Hi Johan,

I can not submit this patch into cvs (no access other than anonymous). Can you do it please ?

Thanks

Fred

Marcel Holtmann a =E9crit :

Quoted 19 lines

Hi Johan,
=

Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

A new version of the patch.
Are you okay with it ?

the patch looks okay to me. However I prefer if Claudio or Johan can have an additional look.

Looks good to me.

=

feel free to commit it to the CVS then.
=

Regards
=

Marcel
=

Quoted 7 lines

=

=

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share y=

our

Quoted 2 lines

opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D=

DEVDEV

Quoted 4 lines

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#7 lore raw

Hi Frederic,

Quoted 2 lines

I can not submit this patch into cvs (no access other than anonymous). Can you do it please ?

your patch has been committed to the CVS now. Thanks.

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel