* [PATCH BlueZ 1/4] Add Vendor, Product and Version properties to org.bluez.Device
@ 2011-09-22 15:51 Luiz Augusto von Dentz
2011-09-22 15:51 ` [PATCH BlueZ 2/4] Print Vendor/Product/Version in hexadecimal Luiz Augusto von Dentz
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2011-09-22 15:51 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This identifiers can be used by applications to implements quirks which
seems to be very common in some profiles such as syncml and since this
information is already stored permanently we can quickly retrieve it
without having to connect or parse the records again.
---
doc/device-api.txt | 12 +++++++
src/device.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/device.h | 3 ++
3 files changed, 101 insertions(+), 0 deletions(-)
diff --git a/doc/device-api.txt b/doc/device-api.txt
index d1feb18..e8fc314 100644
--- a/doc/device-api.txt
+++ b/doc/device-api.txt
@@ -125,6 +125,18 @@ Properties string Address [readonly]
The Bluetooth remote name. This value can not be
changed. Use the Alias property instead.
+ uint16 Vendor [readonly]
+
+ Vendor unique numeric identifier.
+
+ uint16 Product [readonly]
+
+ Product unique numeric identifier.
+
+ uint16 Version [readonly]
+
+ Version unique numeric identifier.
+
string Icon [readonly]
Proposed icon name according to the freedesktop.org
diff --git a/src/device.c b/src/device.c
index 4372a8d..698b232 100644
--- a/src/device.c
+++ b/src/device.c
@@ -121,6 +121,9 @@ struct btd_device {
gchar *path;
char name[MAX_NAME_LENGTH + 1];
char *alias;
+ uint16_t vendor;
+ uint16_t product;
+ uint16_t version;
struct btd_adapter *adapter;
GSList *uuids;
GSList *services; /* Primary services path */
@@ -325,6 +328,21 @@ static DBusMessage *get_properties(DBusConnection *conn,
DBUS_TYPE_STRING, &icon);
}
+ /* Vendor */
+ if (device->vendor)
+ dict_append_entry(&dict, "Vendor", DBUS_TYPE_UINT16,
+ &device->vendor);
+
+ /* Product */
+ if (device->product)
+ dict_append_entry(&dict, "Product", DBUS_TYPE_UINT16,
+ &device->product);
+
+ /* Version */
+ if (device->product)
+ dict_append_entry(&dict, "Version", DBUS_TYPE_UINT16,
+ &device->version);
+
/* Paired */
boolean = device_is_paired(device);
dict_append_entry(&dict, "Paired", DBUS_TYPE_BOOLEAN, &boolean);
@@ -905,6 +923,45 @@ void device_remove_disconnect_watch(struct btd_device *device, guint id)
}
}
+static void device_set_vendor(struct btd_device *device, uint16_t value)
+{
+ DBusConnection *conn = get_dbus_connection();
+
+ if (device->vendor == value)
+ return;
+
+ device->vendor = value;
+
+ emit_property_changed(conn, device->path, DEVICE_INTERFACE, "Vendor",
+ DBUS_TYPE_UINT16, &value);
+}
+
+static void device_set_product(struct btd_device *device, uint16_t value)
+{
+ DBusConnection *conn = get_dbus_connection();
+
+ if (device->product == value)
+ return;
+
+ device->product = value;
+
+ emit_property_changed(conn, device->path, DEVICE_INTERFACE, "Product",
+ DBUS_TYPE_UINT16, &value);
+}
+
+static void device_set_version(struct btd_device *device, uint16_t value)
+{
+ DBusConnection *conn = get_dbus_connection();
+
+ if (device->version == value)
+ return;
+
+ device->version = value;
+
+ emit_property_changed(conn, device->path, DEVICE_INTERFACE, "Version",
+ DBUS_TYPE_UINT16, &value);
+}
+
struct btd_device *device_create(DBusConnection *conn,
struct btd_adapter *adapter,
const gchar *address, device_type_t type)
@@ -914,6 +971,7 @@ struct btd_device *device_create(DBusConnection *conn,
const gchar *adapter_path = adapter_get_path(adapter);
bdaddr_t src;
char srcaddr[18], alias[MAX_NAME_LENGTH + 1];
+ uint16_t vendor, product, version;
device = g_try_malloc0(sizeof(struct btd_device));
if (device == NULL)
@@ -951,6 +1009,13 @@ struct btd_device *device_create(DBusConnection *conn,
device_set_bonded(device, TRUE);
}
+ if (read_device_id(srcaddr, address, NULL, &vendor, &product, &version)
+ == 0) {
+ device_set_vendor(device, vendor);
+ device_set_product(device, product);
+ device_set_version(device, version);
+ }
+
return btd_device_ref(device);
}
@@ -985,6 +1050,21 @@ device_type_t device_get_type(struct btd_device *device)
return device->type;
}
+uint16_t btd_device_get_vendor(struct btd_device *device)
+{
+ return device->vendor;
+}
+
+uint16_t btd_device_get_product(struct btd_device *device)
+{
+ return device->product;
+}
+
+uint16_t btd_device_get_version(struct btd_device *device)
+{
+ return device->version;
+}
+
static void device_remove_stored(struct btd_device *device)
{
bdaddr_t src;
@@ -1312,12 +1392,18 @@ static void update_services(struct browse_req *req, sdp_list_t *recs)
pdlist = sdp_data_get(rec, SDP_ATTR_VENDOR_ID);
vendor = pdlist ? pdlist->val.uint16 : 0x0000;
+ device_set_vendor(device, vendor);
+
pdlist = sdp_data_get(rec, SDP_ATTR_PRODUCT_ID);
product = pdlist ? pdlist->val.uint16 : 0x0000;
+ device_set_product(device, product);
+
pdlist = sdp_data_get(rec, SDP_ATTR_VERSION);
version = pdlist ? pdlist->val.uint16 : 0x0000;
+ device_set_version(device, version);
+
if (source || vendor || product || version)
store_device_id(srcaddr, dstaddr, source,
vendor, product, version);
diff --git a/src/device.h b/src/device.h
index b6349bc..2e17a83 100644
--- a/src/device.h
+++ b/src/device.h
@@ -46,6 +46,9 @@ struct btd_device *device_create(DBusConnection *conn,
void device_set_name(struct btd_device *device, const char *name);
void device_get_name(struct btd_device *device, char *name, size_t len);
device_type_t device_get_type(struct btd_device *device);
+uint16_t btd_device_get_vendor(struct btd_device *device);
+uint16_t btd_device_get_product(struct btd_device *device);
+uint16_t btd_device_get_version(struct btd_device *device);
void device_remove(struct btd_device *device, gboolean remove_stored);
gint device_address_cmp(struct btd_device *device, const gchar *address);
int device_browse_primary(struct btd_device *device, DBusConnection *conn,
--
1.7.6.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH BlueZ 2/4] Print Vendor/Product/Version in hexadecimal
2011-09-22 15:51 [PATCH BlueZ 1/4] Add Vendor, Product and Version properties to org.bluez.Device Luiz Augusto von Dentz
@ 2011-09-22 15:51 ` Luiz Augusto von Dentz
2011-09-22 15:51 ` [PATCH BlueZ 3/4] Remove use of read_device_id in input plugin Luiz Augusto von Dentz
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2011-09-22 15:51 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This is how their are more commonly known.
---
test/list-devices | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/test/list-devices b/test/list-devices
index 9120714..cb564be 100755
--- a/test/list-devices
+++ b/test/list-devices
@@ -67,6 +67,12 @@ for i in adapter_list:
print " %s = %s" % (key, list)
elif (key == "Class"):
print " %s = 0x%06x" % (key, value)
+ elif (key == "Vendor"):
+ print " %s = 0x%04x" % (key, value)
+ elif (key == "Product"):
+ print " %s = 0x%04x" % (key, value)
+ elif (key == "Version"):
+ print " %s = 0x%04x" % (key, value)
else:
print " %s = %s" % (key, value)
--
1.7.6.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH BlueZ 3/4] Remove use of read_device_id in input plugin
2011-09-22 15:51 [PATCH BlueZ 1/4] Add Vendor, Product and Version properties to org.bluez.Device Luiz Augusto von Dentz
2011-09-22 15:51 ` [PATCH BlueZ 2/4] Print Vendor/Product/Version in hexadecimal Luiz Augusto von Dentz
@ 2011-09-22 15:51 ` Luiz Augusto von Dentz
2011-09-22 15:51 ` [PATCH BlueZ 4/4] Remove use of read_device_id in wiimote plugin Luiz Augusto von Dentz
2011-10-02 22:45 ` [PATCH BlueZ 1/4] Add Vendor, Product and Version properties to org.bluez.Device Johan Hedberg
3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2011-09-22 15:51 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Make use of btd_device_get_vendor, btd_device_get_product and
btd_device_get_version intead.
---
input/device.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/input/device.c b/input/device.c
index 70d0ba2..9ff7f20 100644
--- a/input/device.c
+++ b/input/device.c
@@ -596,8 +596,9 @@ static int hidp_add_connection(const struct input_device *idev,
extract_hid_record(rec, req);
sdp_record_free(rec);
- read_device_id(src_addr, dst_addr, NULL,
- &req->vendor, &req->product, &req->version);
+ req->vendor = btd_device_get_vendor(idev->device);
+ req->product = btd_device_get_product(idev->device);
+ req->version = btd_device_get_version(idev->device);
fake_hid = get_fake_hid(req->vendor, req->product);
if (fake_hid) {
--
1.7.6.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH BlueZ 4/4] Remove use of read_device_id in wiimote plugin
2011-09-22 15:51 [PATCH BlueZ 1/4] Add Vendor, Product and Version properties to org.bluez.Device Luiz Augusto von Dentz
2011-09-22 15:51 ` [PATCH BlueZ 2/4] Print Vendor/Product/Version in hexadecimal Luiz Augusto von Dentz
2011-09-22 15:51 ` [PATCH BlueZ 3/4] Remove use of read_device_id in input plugin Luiz Augusto von Dentz
@ 2011-09-22 15:51 ` Luiz Augusto von Dentz
2011-10-02 22:45 ` [PATCH BlueZ 1/4] Add Vendor, Product and Version properties to org.bluez.Device Johan Hedberg
3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2011-09-22 15:51 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Make use of btd_device_get_vendor and btd_device_get_product intead.
---
plugins/wiimote.c | 23 ++++++++++++-----------
1 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/plugins/wiimote.c b/plugins/wiimote.c
index e60231b..fead72a 100644
--- a/plugins/wiimote.c
+++ b/plugins/wiimote.c
@@ -60,20 +60,21 @@ static ssize_t wii_pincb(struct btd_adapter *adapter, struct btd_device *device,
{
uint16_t vendor, product;
bdaddr_t sba, dba;
- char src_addr[18], dst_addr[18];
+ char addr[18];
adapter_get_address(adapter, &sba);
device_get_address(device, &dba);
- ba2str(&sba, src_addr);
- ba2str(&dba, dst_addr);
-
- if (0 == read_device_id(src_addr, dst_addr, NULL, &vendor, &product,
- NULL)) {
- if (vendor == 0x057e && product == 0x0306) {
- DBG("Forcing fixed pin on detected wiimote %s", dst_addr);
- memcpy(pinbuf, &sba, 6);
- return 6;
- }
+ ba2str(&dba, addr);
+
+ vendor = btd_device_get_vendor(device);
+ if (vendor != 0x057e)
+ return 0;
+
+ product = btd_device_get_product(device);
+ if (product == 0x0306) {
+ DBG("Forcing fixed pin on detected wiimote %s", addr);
+ memcpy(pinbuf, &sba, 6);
+ return 6;
}
return 0;
--
1.7.6.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH BlueZ 1/4] Add Vendor, Product and Version properties to org.bluez.Device
2011-09-22 15:51 [PATCH BlueZ 1/4] Add Vendor, Product and Version properties to org.bluez.Device Luiz Augusto von Dentz
` (2 preceding siblings ...)
2011-09-22 15:51 ` [PATCH BlueZ 4/4] Remove use of read_device_id in wiimote plugin Luiz Augusto von Dentz
@ 2011-10-02 22:45 ` Johan Hedberg
3 siblings, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2011-10-02 22:45 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
Hi Luiz,
On Thu, Sep 22, 2011, Luiz Augusto von Dentz wrote:
> This identifiers can be used by applications to implements quirks which
> seems to be very common in some profiles such as syncml and since this
> information is already stored permanently we can quickly retrieve it
> without having to connect or parse the records again.
> ---
> doc/device-api.txt | 12 +++++++
> src/device.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> src/device.h | 3 ++
> 3 files changed, 101 insertions(+), 0 deletions(-)
All four patches applied. Thanks.
Johan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-10-02 22:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-22 15:51 [PATCH BlueZ 1/4] Add Vendor, Product and Version properties to org.bluez.Device Luiz Augusto von Dentz
2011-09-22 15:51 ` [PATCH BlueZ 2/4] Print Vendor/Product/Version in hexadecimal Luiz Augusto von Dentz
2011-09-22 15:51 ` [PATCH BlueZ 3/4] Remove use of read_device_id in input plugin Luiz Augusto von Dentz
2011-09-22 15:51 ` [PATCH BlueZ 4/4] Remove use of read_device_id in wiimote plugin Luiz Augusto von Dentz
2011-10-02 22:45 ` [PATCH BlueZ 1/4] Add Vendor, Product and Version properties to org.bluez.Device Johan Hedberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox