From: Johan Hedberg <johan.hedberg@nokia.com>
To: bluez-devel@lists.sourceforge.net
Subject: [Bluez-devel] [PATCH] Set D-BUS signal paths according to local device
Date: Thu, 13 Oct 2005 20:20:36 +0300 [thread overview]
Message-ID: <20051013172036.GA24585@localhost.localdomain> (raw)
[-- 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) {
next reply other threads:[~2005-10-13 17:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-13 17:20 Johan Hedberg [this message]
2005-10-13 17:36 ` [Bluez-devel] [PATCH] Set D-BUS signal paths according to local device Claudio Takahasi
2005-10-13 18:02 ` Johan Hedberg
2005-10-13 22:51 ` Marcel Holtmann
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=20051013172036.GA24585@localhost.localdomain \
--to=johan.hedberg@nokia.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