Linux bluetooth development
 help / color / mirror / Atom feed
* [Bluez-devel] [DBUS-PATCH] new signals(DeviceAdded and DeviceRemoved)
@ 2005-10-17 21:37 Claudio Takahasi
       [not found] ` <20051018071545.GA7228@localhost.localdomain>
  0 siblings, 1 reply; 4+ messages in thread
From: Claudio Takahasi @ 2005-10-17 21:37 UTC (permalink / raw)
  To: bluez-devel

[-- Attachment #1: Type: text/plain, Size: 759 bytes --]

Hi folks,

This patch add two new signals: DeviceAdded and DeviceRemoved.
These signals are sent in the path /org/bluez/Manager/Controller

I am accepting suggestions to change the path if someone think it can be
changed.
The signal "DeviceAdded" can't related to a device specific path (eg:
/org/bluez/Manager/hci0/Controller )
and put the "DeviceRemoved" signal in a different path is not a good idea.

If you notice a conflict with the lastest Johan's patch let me know that I
can create the patch again.

The handle_inq_req reply was fixed too, the return was wrong.

Regards,
Claudio.
--
---------------------------------------------------------
Claudio Takahasi
Nokia's Institute of Technology - INdT
claudio.takahasi@indt.org.br

[-- Attachment #2: Type: text/html, Size: 900 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Bluez-devel] [DBUS-PATCH] new signals(DeviceAdded and DeviceRemoved)
       [not found] ` <20051018071545.GA7228@localhost.localdomain>
@ 2005-10-18 11:13   ` Claudio Takahasi
  2005-10-18 17:35     ` Marcel Holtmann
  0 siblings, 1 reply; 4+ messages in thread
From: Claudio Takahasi @ 2005-10-18 11:13 UTC (permalink / raw)
  To: bluez-devel, Claudio Takahasi


[-- Attachment #1.1: Type: text/plain, Size: 471 bytes --]

done!

I removed the handle_inq_reply reply message fix to avoid
conflict with the latest Johan's patch.

Regards,
Claudio.

On 10/18/05, Johan Hedberg <johan.hedberg@nokia.com> wrote:
>
> Hi Claudio,
>
> I think you forgot to attach the actual path to your previous email.
> However, before sending it I would suggest removing the
> handle_inquiry_req reply fix since my patch fixes that also (so the
> patches will most likely conflict).
>
> Johan
>

[-- Attachment #1.2: Type: text/html, Size: 777 bytes --]

[-- Attachment #2: new_signals_02.patch --]
[-- Type: application/octet-stream, Size: 3177 bytes --]

--- bluez-utils-cvs.orig/hcid/dbus.h	2005-10-17 18:16:53.000000000 -0200
+++ bluez-utils-cvs-hcid/hcid/dbus.h	2005-10-18 08:08:10.000000000 -0200
@@ -111,12 +111,16 @@
 #define BLUEZ_HCI_PATH			MANAGER_PATH "/" BLUEZ_HCI
 #define BLUEZ_HCI_INTERFACE		MANAGER_INTERFACE "." BLUEZ_HCI
 
-//HCI signals
+//Device based HCI signals
 #define BLUEZ_HCI_INQ_START		"InquiryStart"
 #define BLUEZ_HCI_INQ_COMPLETE		"InquiryComplete"
 #define BLUEZ_HCI_INQ_RESULT		"InquiryResult"
 #define BLUEZ_HCI_REMOTE_NAME		"RemoteName"
 
+//HCI signals sent in the BLUEZ_HCI_PATH
+#define BLUEZ_HCI_DEV_ADDED		"DeviceAdded"
+#define BLUEZ_HCI_DEV_REMOVED		"DeviceRemoved"
+
 //HCI Provided services
 #define HCI_PERIODIC_INQ		"PeriodicInquiry"
 #define HCI_CANCEL_PERIODIC_INQ		"CancelPeriodic"
@@ -169,6 +173,7 @@
 							DBUS_STRUCT_END_CHAR_AS_STRING\
 							__END_SIG__
 
+
 /* BLUEZ_DBUS_ERROR 
  * EFailed error messages signature is : su
  * Where the first argument is a string(error message description),
--- bluez-utils-cvs.orig/hcid/dbus.c	2005-10-17 18:16:38.000000000 -0200
+++ bluez-utils-cvs-hcid/hcid/dbus.c	2005-10-18 08:05:43.000000000 -0200
@@ -743,7 +743,11 @@
 
 gboolean hcid_dbus_register_device(uint16_t id)
 {
+	char dev[BLUETOOTH_DEVICE_NAME_LEN];
 	struct profile_obj_path_data *ptr = obj_path_table;
+	DBusMessage *message = NULL;
+	const char *pdev = dev;
+	DBusMessageIter iter;
 	int ret = -1; 
 
 	if (!connection)
@@ -757,12 +761,43 @@
 	if (!ret)
 		num_adapters++;
 
+
+	message = dbus_message_new_signal(BLUEZ_HCI_PATH,
+			BLUEZ_HCI_INTERFACE, BLUEZ_HCI_DEV_ADDED);
+
+	if (message == NULL) {
+		syslog(LOG_ERR, "Can't allocate D-BUS remote name message");
+		goto failed;
+	}
+
+	sprintf(dev, "hci%d", id);
+
+	dbus_message_iter_init_append(message, &iter);
+	dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING ,&pdev);
+
+	if (dbus_connection_send(connection, message, NULL) == FALSE) {
+		syslog(LOG_ERR, "Can't send D-BUS added device message");
+		goto failed;
+	}
+
+	dbus_connection_flush(connection);
+
+failed:
+	/* if the signal can't be sent ignore the error */
+
+	if (message)
+		dbus_message_unref(message);
+
 	return TRUE;
 }
 
 gboolean hcid_dbus_unregister_device(uint16_t id)
 {
+	char dev[BLUETOOTH_DEVICE_NAME_LEN];
 	struct profile_obj_path_data *ptr = obj_path_table;
+	DBusMessage *message = NULL;
+	const char *pdev = dev;
+	DBusMessageIter iter;
 	int dft_unreg = 0;
 
 	if (!connection)
@@ -777,6 +812,33 @@
 			ptr->dft_reg = 0;
 	}
 
+
+	message = dbus_message_new_signal(BLUEZ_HCI_PATH,
+			BLUEZ_HCI_INTERFACE, BLUEZ_HCI_DEV_REMOVED);
+
+	if (message == NULL) {
+		syslog(LOG_ERR, "Can't allocate D-BUS device removed  message");
+		goto failed;
+	}
+
+	sprintf(dev, "hci%d", id);
+
+	dbus_message_iter_init_append(message, &iter);
+	dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING ,&pdev);
+
+	if (dbus_connection_send(connection, message, NULL) == FALSE) {
+		syslog(LOG_ERR, "Can't send D-BUS removed device message");
+		goto failed;
+	}
+
+	dbus_connection_flush(connection);
+
+failed:
+	/* if the signal can't be sent ignore the error */
+
+	if (message)
+		dbus_message_unref(message);
+
 	return TRUE;
 }
 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Bluez-devel] [DBUS-PATCH] new signals(DeviceAdded and DeviceRemoved)
  2005-10-18 11:13   ` Claudio Takahasi
@ 2005-10-18 17:35     ` Marcel Holtmann
       [not found]       ` <e1effdeb0510181213x77832121t236cf91e83a6befa@mail.gmail.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Marcel Holtmann @ 2005-10-18 17:35 UTC (permalink / raw)
  To: bluez-devel; +Cc: Claudio Takahasi

Hi Claudio,

> I removed the handle_inq_reply reply message fix to avoid 
> conflict with the latest Johan's patch.

the patch is in the CVS now. Send the cleanup patch, once the CVS update
is propagated.

Regards

Marcel




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Bluez-devel] [DBUS-PATCH] new signals(DeviceAdded and DeviceRemoved)
       [not found]         ` <1129718124.5362.0.camel@localhost.localdomain>
@ 2005-10-19 11:03           ` Claudio Takahasi
  0 siblings, 0 replies; 4+ messages in thread
From: Claudio Takahasi @ 2005-10-19 11:03 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: bluez-devel

[-- Attachment #1: Type: text/plain, Size: 486 bytes --]

Hi Marcel,

This bug was already fixed in the latest Johan's patch (revision 1.26).


Regards,
Claudio.

On 10/19/05, Marcel Holtmann <marcel@holtmann.org> wrote:
>
> Hi Claudio,
>
> > Which cleanup patch are you asking for?
>
> the handle_inq_reply() fix you were talking about.
>
> Regards
>
> Marcel
>
>
>


--
---------------------------------------------------------
Claudio Takahasi
Nokia's Institute of Technology - INdT
claudio.takahasi@indt.org.br

[-- Attachment #2: Type: text/html, Size: 867 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-10-19 11:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-17 21:37 [Bluez-devel] [DBUS-PATCH] new signals(DeviceAdded and DeviceRemoved) Claudio Takahasi
     [not found] ` <20051018071545.GA7228@localhost.localdomain>
2005-10-18 11:13   ` Claudio Takahasi
2005-10-18 17:35     ` Marcel Holtmann
     [not found]       ` <e1effdeb0510181213x77832121t236cf91e83a6befa@mail.gmail.com>
     [not found]         ` <1129718124.5362.0.camel@localhost.localdomain>
2005-10-19 11:03           ` Claudio Takahasi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox