* [Bluez-devel] [PATCH] Set D-BUS signal paths according to local device
@ 2005-10-13 17:20 Johan Hedberg
2005-10-13 17:36 ` Claudio Takahasi
0 siblings, 1 reply; 4+ messages in thread
From: Johan Hedberg @ 2005-10-13 17:20 UTC (permalink / raw)
To: bluez-devel
[-- Attachment #1: Type: text/plain, Size: 208 bytes --]
Hi,
The attached patch sets the object path of D-BUS signals according to
the local device id, e.g. /org/bluez/Manager/hci0/Controller. It also
removes the local address arguments from those signals.
Johan
[-- Attachment #2: signal-path.patch --]
[-- Type: text/plain, Size: 4501 bytes --]
Index: hcid/dbus.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus.c,v
retrieving revision 1.23
diff -u -r1.23 dbus.c
--- hcid/dbus.c 13 Oct 2005 09:36:00 -0000 1.23
+++ hcid/dbus.c 13 Oct 2005 16:52:47 -0000
@@ -338,23 +338,29 @@
void hcid_dbus_inquiry_start(bdaddr_t *local)
{
- DBusMessage *message;
+ DBusMessage *message = NULL;
+ char path[MAX_PATH_LENGTH];
char *local_addr;
bdaddr_t tmp;
+ int id;
baswap(&tmp, local); local_addr = batostr(&tmp);
- message = dbus_message_new_signal(BLUEZ_HCI_PATH,
+ id = hci_devid(local_addr);
+ if (id < 0) {
+ syslog(LOG_ERR, "No matching device id for %s", local_addr);
+ goto failed;
+ }
+
+ snprintf(path, sizeof(path), "%s/hci%d/%s", MANAGER_PATH, id, BLUEZ_HCI);
+
+ message = dbus_message_new_signal(path,
BLUEZ_HCI_INTERFACE, BLUEZ_HCI_INQ_START);
if (message == NULL) {
syslog(LOG_ERR, "Can't allocate D-BUS inquiry start message");
goto failed;
}
- dbus_message_append_args(message,
- DBUS_TYPE_STRING, &local_addr,
- DBUS_TYPE_INVALID);
-
if (dbus_connection_send(connection, message, NULL) == FALSE) {
syslog(LOG_ERR, "Can't send D-BUS inquiry start message");
goto failed;
@@ -372,23 +378,29 @@
void hcid_dbus_inquiry_complete(bdaddr_t *local)
{
- DBusMessage *message;
+ DBusMessage *message = NULL;
+ char path[MAX_PATH_LENGTH];
char *local_addr;
bdaddr_t tmp;
+ int id;
baswap(&tmp, local); local_addr = batostr(&tmp);
- message = dbus_message_new_signal(BLUEZ_HCI_PATH,
+ id = hci_devid(local_addr);
+ if (id < 0) {
+ syslog(LOG_ERR, "No matching device id for %s", local_addr);
+ goto failed;
+ }
+
+ snprintf(path, sizeof(path), "%s/hci%d/%s", MANAGER_PATH, id, BLUEZ_HCI);
+
+ message = dbus_message_new_signal(path,
BLUEZ_HCI_INTERFACE, BLUEZ_HCI_INQ_COMPLETE);
if (message == NULL) {
syslog(LOG_ERR, "Can't allocate D-BUS inquiry complete message");
goto failed;
}
- dbus_message_append_args(message,
- DBUS_TYPE_STRING, &local_addr,
- DBUS_TYPE_INVALID);
-
if (dbus_connection_send(connection, message, NULL) == FALSE) {
syslog(LOG_ERR, "Can't send D-BUS inquiry complete message");
goto failed;
@@ -406,16 +418,26 @@
void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class, int8_t rssi)
{
- DBusMessage *message;
+ DBusMessage *message = NULL;
+ char path[MAX_PATH_LENGTH];
char *local_addr, *peer_addr;
dbus_uint32_t tmp_class = class;
dbus_int32_t tmp_rssi = rssi;
bdaddr_t tmp;
+ int id;
baswap(&tmp, local); local_addr = batostr(&tmp);
baswap(&tmp, peer); peer_addr = batostr(&tmp);
- message = dbus_message_new_signal(BLUEZ_HCI_PATH,
+ id = hci_devid(local_addr);
+ if (id < 0) {
+ syslog(LOG_ERR, "No matching device id for %s", local_addr);
+ goto failed;
+ }
+
+ snprintf(path, sizeof(path), "%s/hci%d/%s", MANAGER_PATH, id, BLUEZ_HCI);
+
+ message = dbus_message_new_signal(path,
BLUEZ_HCI_INTERFACE, BLUEZ_HCI_INQ_RESULT);
if (message == NULL) {
syslog(LOG_ERR, "Can't allocate D-BUS inquiry result message");
@@ -423,7 +445,6 @@
}
dbus_message_append_args(message,
- DBUS_TYPE_STRING, &local_addr,
DBUS_TYPE_STRING, &peer_addr,
DBUS_TYPE_UINT32, &tmp_class,
DBUS_TYPE_INT32, &tmp_rssi,
@@ -447,14 +468,24 @@
void hcid_dbus_remote_name(bdaddr_t *local, bdaddr_t *peer, char *name)
{
- DBusMessage *message;
+ DBusMessage *message = NULL;
+ char path[MAX_PATH_LENGTH];
char *local_addr, *peer_addr;
bdaddr_t tmp;
+ int id;
baswap(&tmp, local); local_addr = batostr(&tmp);
baswap(&tmp, peer); peer_addr = batostr(&tmp);
- message = dbus_message_new_signal(BLUEZ_HCI_PATH,
+ id = hci_devid(local_addr);
+ if (id < 0) {
+ syslog(LOG_ERR, "No matching device id for %s", local_addr);
+ goto failed;
+ }
+
+ snprintf(path, sizeof(path), "%s/hci%d/%s", MANAGER_PATH, id, BLUEZ_HCI);
+
+ message = dbus_message_new_signal(path,
BLUEZ_HCI_INTERFACE, BLUEZ_HCI_REMOTE_NAME);
if (message == NULL) {
syslog(LOG_ERR, "Can't allocate D-BUS remote name message");
@@ -462,7 +493,6 @@
}
dbus_message_append_args(message,
- DBUS_TYPE_STRING, &local_addr,
DBUS_TYPE_STRING, &peer_addr,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_INVALID);
@@ -1314,7 +1344,7 @@
struct hci_dbus_data *dbus_data = data;
int i;
int dev_id = -1;
- int sk;
+ int sk = -1;
if (dbus_data->id == DEFAULT_DEVICE_PATH_ID) {
if ((dev_id = hci_get_route(NULL)) < 0) {
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [Bluez-devel] [PATCH] Set D-BUS signal paths according to local device
2005-10-13 17:20 [Bluez-devel] [PATCH] Set D-BUS signal paths according to local device Johan Hedberg
@ 2005-10-13 17:36 ` Claudio Takahasi
2005-10-13 18:02 ` Johan Hedberg
0 siblings, 1 reply; 4+ messages in thread
From: Claudio Takahasi @ 2005-10-13 17:36 UTC (permalink / raw)
To: bluez-devel
[-- Attachment #1: Type: text/plain, Size: 690 bytes --]
Hi Johan,
I didn't analized all the patch content, but I guess it's possible change
the signature of the functions passing the dev id instead of receive the BT
address and convert it.
What do you think?
Regards,
Claudio
On 10/13/05, Johan Hedberg <johan.hedberg@nokia.com> wrote:
>
> Hi,
>
> The attached patch sets the object path of D-BUS signals according to
> the local device id, e.g. /org/bluez/Manager/hci0/Controller. It also
> removes the local address arguments from those signals.
>
> Johan
>
>
>
--
---------------------------------------------------------
Claudio Takahasi
Nokia's Institute of Technology - INdT
claudio.takahasi@indt.org.br
[-- Attachment #2: Type: text/html, Size: 1076 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Bluez-devel] [PATCH] Set D-BUS signal paths according to local device
2005-10-13 17:36 ` Claudio Takahasi
@ 2005-10-13 18:02 ` Johan Hedberg
2005-10-13 22:51 ` Marcel Holtmann
0 siblings, 1 reply; 4+ messages in thread
From: Johan Hedberg @ 2005-10-13 18:02 UTC (permalink / raw)
To: bluez-devel
On Thu, Oct 13, 2005, Claudio Takahasi wrote:
> I didn't analized all the patch content, but I guess it's possible change
> the signature of the functions passing the dev id instead of receive the BT
> address and convert it.
>
> What do you think?
Yes, that would also be one possibility. However, it requires some
changes to security.c (where those functions are being called from).
Also, if we decide to start using the device address (instead of the id)
in the object paths, there's no point in changing the function
parameters. Maybe Marcel has an opinion about this?
Johan
-------------------------------------------------------
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] [PATCH] Set D-BUS signal paths according to local device
2005-10-13 18:02 ` Johan Hedberg
@ 2005-10-13 22:51 ` Marcel Holtmann
0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2005-10-13 22:51 UTC (permalink / raw)
To: bluez-devel
Hi Johan,
> > I didn't analized all the patch content, but I guess it's possible change
> > the signature of the functions passing the dev id instead of receive the BT
> > address and convert it.
> >
> > What do you think?
>
> Yes, that would also be one possibility. However, it requires some
> changes to security.c (where those functions are being called from).
> Also, if we decide to start using the device address (instead of the id)
> in the object paths, there's no point in changing the function
> parameters. Maybe Marcel has an opinion about this?
I applied your patch to get it started. However for the final solution
we should send around a string inside the hcid API that will maybe
"hci0" or also an alias. For example you can rename Ethernet interfaces
and at some point I like to rename Bluetooth HCI interfaces, too.
Internally it will still use an id number, but that is only inside the
kernel.
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
end of thread, other threads:[~2005-10-13 22:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-13 17:20 [Bluez-devel] [PATCH] Set D-BUS signal paths according to local device Johan Hedberg
2005-10-13 17:36 ` Claudio Takahasi
2005-10-13 18:02 ` Johan Hedberg
2005-10-13 22:51 ` Marcel Holtmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.