Linux bluetooth development
 help / color / mirror / Atom feed
From: Claudio Takahasi <cktakahasi@gmail.com>
To: bluez-devel@lists.sourceforge.net,
	Claudio Takahasi <cktakahasi@gmail.com>
Subject: Re: [Bluez-devel] [DBUS-PATCH] new signals(DeviceAdded and DeviceRemoved)
Date: Tue, 18 Oct 2005 09:13:33 -0200	[thread overview]
Message-ID: <e1effdeb0510180413m6f88b23etdf98e16c530dbc4e@mail.gmail.com> (raw)
In-Reply-To: <20051018071545.GA7228@localhost.localdomain>


[-- 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;
 }
 


  parent reply	other threads:[~2005-10-18 11:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=e1effdeb0510180413m6f88b23etdf98e16c530dbc4e@mail.gmail.com \
    --to=cktakahasi@gmail.com \
    --cc=bluez-devel@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