* [PATCH BlueZ 0/2] Some more prerequisites for the playstation-peripheral plugin @ 2013-02-24 9:54 Antonio Ospite 2013-02-24 9:54 ` [PATCH BlueZ 1/2] adapter: add a btd_adapter_get_default_address() call Antonio Ospite 2013-02-24 9:54 ` [PATCH BlueZ 2/2] adapter: add a btd_create_stored_device() call Antonio Ospite 0 siblings, 2 replies; 5+ messages in thread From: Antonio Ospite @ 2013-02-24 9:54 UTC (permalink / raw) To: linux-bluetooth; +Cc: Bastien Nocera, Antonio Ospite Hi, if you recall some older discussions we decided to have the playstation-peripheral plugin as an _external_ plugin, because it will be used by only a few people and allowing to make its installation optional makes a lot of sense. But external plugins can only use a subset of the BlueZ API, the one marked as "global" in src/bluetooth.ver Hence some more btd_* APIs are needed for the playstation-peripheral plugin. Here I propose the last missing pieces of the jigsaw before I can submit the actual plugin. Please comment, in the hope that at most one more review round will be enough to have these functionalities merged. Patch 1 is needed because the playstation-peripheral plugin will send the adapter bdaddr to the peripheral via USB, to have it set as the "master bdaddr". I can very well avoid a new API in this case but then I'd need to make some symbols global, let me know if that's what you prefer instead. Patch 2 is to create the device in the BlueZ database, any comment on this one is appreciated: the name can be improved, the implementation can be changed, but the point is that in one way or another we need some mechanism to add new devices programmatically before they show up via Bluetooth. An alternative proposal by someone else would also be very welcome :) Patches are against BlueZ 5.3. I can submit the plugin as well, if you really want to see the code using these APIs, I didn't just yet in order to keep the discussion more focused. Thanks, Antonio Antonio Ospite (2): adapter: add a btd_adapter_get_default_address() call adapter: add a btd_create_stored_device() call src/adapter.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/adapter.h | 12 ++++++++++ 2 files changed, 81 insertions(+) -- Antonio Ospite http://ao2.it A: Because it messes up the order in which people normally read text. See http://en.wikipedia.org/wiki/Posting_style Q: Why is top-posting such a bad thing? ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH BlueZ 1/2] adapter: add a btd_adapter_get_default_address() call 2013-02-24 9:54 [PATCH BlueZ 0/2] Some more prerequisites for the playstation-peripheral plugin Antonio Ospite @ 2013-02-24 9:54 ` Antonio Ospite 2013-02-26 11:51 ` Johan Hedberg 2013-02-24 9:54 ` [PATCH BlueZ 2/2] adapter: add a btd_create_stored_device() call Antonio Ospite 1 sibling, 1 reply; 5+ messages in thread From: Antonio Ospite @ 2013-02-24 9:54 UTC (permalink / raw) To: linux-bluetooth; +Cc: Bastien Nocera, Antonio Ospite Add a new btd_* call to get the default adapter address as a string. This is meant to be used, for instance, by _external_ plugins which want to know the default adapter address for some reason (e.g. to send it to a device for some custom pairing scheme like in the case of Playstation peripherals). External plugins can only use symbols marked as "global" in src/bluetooth.ver, this patch avoids making global these symbols: adapter_get_address bt_malloc ba2str --- src/adapter.h | 1 + src/adapter.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/adapter.h b/src/adapter.h index 8d23a64..cb6d0d6 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -38,6 +38,7 @@ struct btd_adapter; struct btd_adapter *btd_adapter_get_default(void); +char *btd_adapter_get_default_address(void); bool btd_adapter_is_default(struct btd_adapter *adapter); uint16_t btd_adapter_get_index(struct btd_adapter *adapter); diff --git a/src/adapter.c b/src/adapter.c index e553626..5eac84f 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -217,6 +217,23 @@ struct btd_adapter *btd_adapter_get_default(void) return NULL; } +char *btd_adapter_get_default_address(void) +{ + struct btd_adapter *adapter; + char *str; + + adapter = btd_adapter_get_default(); + if (adapter == NULL) + return NULL; + + str = bt_malloc(18); + if (str == NULL) + return NULL; + + ba2str(adapter_get_address(adapter), str); + return str; +} + bool btd_adapter_is_default(struct btd_adapter *adapter) { if (!adapter) -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH BlueZ 1/2] adapter: add a btd_adapter_get_default_address() call 2013-02-24 9:54 ` [PATCH BlueZ 1/2] adapter: add a btd_adapter_get_default_address() call Antonio Ospite @ 2013-02-26 11:51 ` Johan Hedberg 0 siblings, 0 replies; 5+ messages in thread From: Johan Hedberg @ 2013-02-26 11:51 UTC (permalink / raw) To: Antonio Ospite; +Cc: linux-bluetooth, Bastien Nocera Hi Antonio, On Sun, Feb 24, 2013, Antonio Ospite wrote: > Add a new btd_* call to get the default adapter address as a string. > > This is meant to be used, for instance, by _external_ plugins which want > to know the default adapter address for some reason (e.g. to send it to > a device for some custom pairing scheme like in the case of Playstation > peripherals). > > External plugins can only use symbols marked as "global" in > src/bluetooth.ver, this patch avoids making global these symbols: > > adapter_get_address > bt_malloc > ba2str > --- > src/adapter.h | 1 + > src/adapter.c | 17 +++++++++++++++++ > 2 files changed, 18 insertions(+) > > diff --git a/src/adapter.h b/src/adapter.h > index 8d23a64..cb6d0d6 100644 > --- a/src/adapter.h > +++ b/src/adapter.h > @@ -38,6 +38,7 @@ > struct btd_adapter; > > struct btd_adapter *btd_adapter_get_default(void); > +char *btd_adapter_get_default_address(void); > bool btd_adapter_is_default(struct btd_adapter *adapter); > uint16_t btd_adapter_get_index(struct btd_adapter *adapter); Please fix adapter_get_address to have a btd_ prefix instead. There's no reason why that should be hidden from plugins. As for the libbluetooth symbols, I don't get what the issue is. Those should always be available to any binary that links with libbluetooth. If they don't work then I think we need to fix something in the way the plugins and/or bluetoothd are built. Johan ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH BlueZ 2/2] adapter: add a btd_create_stored_device() call 2013-02-24 9:54 [PATCH BlueZ 0/2] Some more prerequisites for the playstation-peripheral plugin Antonio Ospite 2013-02-24 9:54 ` [PATCH BlueZ 1/2] adapter: add a btd_adapter_get_default_address() call Antonio Ospite @ 2013-02-24 9:54 ` Antonio Ospite 2013-02-26 11:53 ` Johan Hedberg 1 sibling, 1 reply; 5+ messages in thread From: Antonio Ospite @ 2013-02-24 9:54 UTC (permalink / raw) To: linux-bluetooth; +Cc: Bastien Nocera, Antonio Ospite Add a new btd_* call to add a new device to the database of known devices. This is particularly useful to register Bluetooth devices using a non-Bluetooth mechanism (e.g. USB-pairing in the case of Playstation peripherals). The interface uses a btd_ prefix and relies only on native C types in order to be more easily used by _external_ plugins. External plugins can only use symbols marked as "global" in src/bluetooth.ver, this patch avoids making global these symbols: store_sdp_record str2ba adapter_get_device device_set_name device_set_temporary device_set_trusted --- src/adapter.h | 11 +++++++++++ src/adapter.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/src/adapter.h b/src/adapter.h index cb6d0d6..13aadb5 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -207,3 +207,14 @@ void adapter_store_cached_name(const bdaddr_t *local, const bdaddr_t *peer, void btd_adapter_for_each_device(struct btd_adapter *adapter, void (*cb)(struct btd_device *device, void *data), void *data); + +int btd_create_stored_device(char *adapter_address, + char *device_address, + char *name, + uint16_t vendor_id_source, + uint16_t vendor_id, + uint16_t product_id, + uint16_t version_id, + const char *uuid, + char *sdp_record, + bool trusted); diff --git a/src/adapter.c b/src/adapter.c index 5eac84f..7aee8f3 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -6196,3 +6196,55 @@ void adapter_shutdown(void) if (!adapter_remaining) btd_exit(); } + +int btd_create_stored_device(char *adapter_address, + char *device_address, + char *name, + uint16_t vendor_id_source, + uint16_t vendor_id, + uint16_t product_id, + uint16_t version_id, + const char *uuid, + char *sdp_record, + bool trusted) +{ + struct btd_adapter *adapter; + struct btd_device *device; + bdaddr_t dst; + int ret = 0; + + store_sdp_record(adapter_address, device_address, 0x10000, sdp_record); + + str2ba(device_address, &dst); + + adapter = btd_adapter_get_default(); + if (adapter == NULL) { + DBG("Failed to get the adapter"); + ret = -EPERM; + goto out; + } + + /* This will create the device if necessary */ + device = adapter_get_device(adapter, &dst, BDADDR_BREDR); + if (device == NULL) { + DBG("Failed to get the device"); + ret = -ENODEV; + goto out; + } + + if (name) + device_set_name(device, name); + + btd_device_set_pnpid(device, vendor_id_source, + vendor_id, product_id, version_id); + + if (uuid) + btd_device_add_uuid(device, uuid); + + device_set_temporary(device, FALSE); + + if (trusted) + device_set_trusted(device, TRUE); +out: + return ret; +} -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH BlueZ 2/2] adapter: add a btd_create_stored_device() call 2013-02-24 9:54 ` [PATCH BlueZ 2/2] adapter: add a btd_create_stored_device() call Antonio Ospite @ 2013-02-26 11:53 ` Johan Hedberg 0 siblings, 0 replies; 5+ messages in thread From: Johan Hedberg @ 2013-02-26 11:53 UTC (permalink / raw) To: Antonio Ospite; +Cc: linux-bluetooth, Bastien Nocera Hi Antonio, On Sun, Feb 24, 2013, Antonio Ospite wrote: > store_sdp_record Why do you need to export this. Where do you get the input data from? > str2ba This is a libbluetooth function. See my comment about that in my previous email. > adapter_get_device > device_set_name > device_set_temporary > device_set_trusted I have nothing against adding a btd_ prefix to these. Johan ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-02-26 11:53 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-02-24 9:54 [PATCH BlueZ 0/2] Some more prerequisites for the playstation-peripheral plugin Antonio Ospite 2013-02-24 9:54 ` [PATCH BlueZ 1/2] adapter: add a btd_adapter_get_default_address() call Antonio Ospite 2013-02-26 11:51 ` Johan Hedberg 2013-02-24 9:54 ` [PATCH BlueZ 2/2] adapter: add a btd_create_stored_device() call Antonio Ospite 2013-02-26 11:53 ` Johan Hedberg
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox