All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] core/device: Add support for setting SDP record
@ 2017-11-08 19:38 Bastien Nocera
  2017-11-08 19:38 ` [PATCH v2 2/2] plugins/sixaxis: Provide DualShock 3 SDP record while adding new device Bastien Nocera
  2017-11-09  9:18 ` [PATCH v2 1/2] core/device: Add support for setting SDP record Szymon Janc
  0 siblings, 2 replies; 4+ messages in thread
From: Bastien Nocera @ 2017-11-08 19:38 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

From: Szymon Janc <szymon.janc@codecoup.pl>

This allows to set SDP record for device without resolving services
over SDP. After SDP is provided profiles are probed.
---
 src/device.c | 33 +++++++++++++++++++++++++++++++++
 src/device.h |  3 +++
 2 files changed, 36 insertions(+)

diff --git a/src/device.c b/src/device.c
index c12407a73..e8118112e 100644
--- a/src/device.c
+++ b/src/device.c
@@ -6073,6 +6073,39 @@ static sdp_list_t *read_device_records(struct btd_device *device)
 	return recs;
 }
 
+void btd_device_set_record(struct btd_device *device, const char *uuid,
+							const char *record)
+{
+	/* This API is only used for BR/EDR */
+	struct bearer_state *state = &device->bredr_state;
+	struct browse_req *req;
+	sdp_list_t *recs = NULL;
+	sdp_record_t *rec;
+
+	if (!record)
+		return;
+
+	req = browse_request_new(device, BROWSE_SDP, NULL);
+	if (!req)
+		return;
+
+	rec = record_from_string(record);
+	recs = sdp_list_append(recs, rec);
+	update_bredr_services(req, recs);
+	sdp_list_free(recs, NULL);
+
+	device->svc_refreshed = true;
+	state->svc_resolved = true;
+
+	device_probe_profiles(device, req->profiles_added);
+
+	/* Propagate services changes */
+	g_dbus_emit_property_changed(dbus_conn, req->device->path,
+						DEVICE_INTERFACE, "UUIDs");
+
+	device_svc_resolved(device, BROWSE_SDP, device->bdaddr_type, 0);
+}
+
 const sdp_record_t *btd_device_get_record(struct btd_device *device,
 							const char *uuid)
 {
diff --git a/src/device.h b/src/device.h
index 850561729..32f8edce5 100644
--- a/src/device.h
+++ b/src/device.h
@@ -62,6 +62,9 @@ struct device_addr_type {
 int device_addr_type_cmp(gconstpointer a, gconstpointer b);
 GSList *btd_device_get_uuids(struct btd_device *device);
 void device_probe_profiles(struct btd_device *device, GSList *profiles);
+
+void btd_device_set_record(struct btd_device *device, const char *uuid,
+							const char *record);
 const sdp_record_t *btd_device_get_record(struct btd_device *device,
 						const char *uuid);
 struct gatt_primary *btd_device_get_primary(struct btd_device *device,
-- 
2.14.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] plugins/sixaxis: Provide DualShock 3 SDP record while adding new device
  2017-11-08 19:38 [PATCH v2 1/2] core/device: Add support for setting SDP record Bastien Nocera
@ 2017-11-08 19:38 ` Bastien Nocera
  2017-11-08 19:59   ` Bastien Nocera
  2017-11-09  9:18 ` [PATCH v2 1/2] core/device: Add support for setting SDP record Szymon Janc
  1 sibling, 1 reply; 4+ messages in thread
From: Bastien Nocera @ 2017-11-08 19:38 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Bastien Nocera

This allows to skip SDP search for DualShock 3 devices, since some
DS3 clones do not provide any SDP record. This allows them to operate
nonetheless.

The HID SDP record is lifted straight off an original DualShock 3
controller. The PNPID SDP record is not set as not required to provide
a working device.

Tested with a "SHANWAN" clone controller.
---
 plugins/sixaxis.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c
index 22e4bb537..c5f90498d 100644
--- a/plugins/sixaxis.c
+++ b/plugins/sixaxis.c
@@ -40,6 +40,8 @@
 
 #include "lib/bluetooth.h"
 #include "lib/sdp.h"
+#include "lib/sdp_lib.h"
+#include "lib/sdp.h"
 #include "lib/uuid.h"
 
 #include "src/adapter.h"
@@ -71,6 +73,8 @@ static guint watch_id = 0;
 /* key = sysfs_path (const str), value = auth_closure */
 static GHashTable *pending_auths = NULL;
 
+#define SIXAXIS_HID_SDP_RECORD "3601920900000A000100000900013503191124090004350D35061901000900113503190011090006350909656E09006A0901000900093508350619112409010009000D350F350D350619010009001335031900110901002513576972656C65737320436F6E74726F6C6C65720901012513576972656C65737320436F6E74726F6C6C6572090102251B536F6E7920436F6D707574657220456E7465727461696E6D656E740902000901000902010901000902020800090203082109020428010902052801090206359A35980822259405010904A101A102850175089501150026FF00810375019513150025013500450105091901291381027501950D0600FF8103150026FF0005010901A10075089504350046FF0009300931093209358102C0050175089527090181027508953009019102750895300901B102C0A1028502750895300901B102C0A10285EE750895300901B102C0A10285EF750895300901B102C0C0090207350835060904090901000902082800090209280109020A280109020B09010009020C093E8009020D280009020E2800"
+
 /* Make sure to unset auth_id if already handled */
 static void auth_closure_destroy(struct authentication_closure *closure,
 				bool remove_device)
@@ -360,6 +364,9 @@ static void agent_auth_cb(DBusError *derr, void *user_data)
 	btd_device_set_trusted(closure->device, true);
 	btd_device_set_temporary(closure->device, false);
 
+	if (closure->type == CABLE_PAIRING_SIXAXIS)
+		btd_device_set_record(closure->device, HID_UUID, SIXAXIS_HID_SDP_RECORD);
+
 	ba2str(&closure->bdaddr, device_addr);
 	ba2str(&master_bdaddr, master_addr);
 	ba2str(adapter_bdaddr, adapter_addr);
-- 
2.14.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 2/2] plugins/sixaxis: Provide DualShock 3 SDP record while adding new device
  2017-11-08 19:38 ` [PATCH v2 2/2] plugins/sixaxis: Provide DualShock 3 SDP record while adding new device Bastien Nocera
@ 2017-11-08 19:59   ` Bastien Nocera
  0 siblings, 0 replies; 4+ messages in thread
From: Bastien Nocera @ 2017-11-08 19:59 UTC (permalink / raw)
  To: linux-bluetooth

On Wed, 2017-11-08 at 20:38 +0100, Bastien Nocera wrote:
> This allows to skip SDP search for DualShock 3 devices, since some
> DS3 clones do not provide any SDP record. This allows them to operate
> nonetheless.
> 
> The HID SDP record is lifted straight off an original DualShock 3
> controller. The PNPID SDP record is not set as not required to
> provide
> a working device.
> 
> Tested with a "SHANWAN" clone controller.
> ---
>  plugins/sixaxis.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c
> index 22e4bb537..c5f90498d 100644
> --- a/plugins/sixaxis.c
> +++ b/plugins/sixaxis.c
> @@ -40,6 +40,8 @@
>  
>  #include "lib/bluetooth.h"
>  #include "lib/sdp.h"
> +#include "lib/sdp_lib.h"
> +#include "lib/sdp.h"

If whoever pushes this could remove this hunk of the patch, or I can
spin a v3, let me know.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] core/device: Add support for setting SDP record
  2017-11-08 19:38 [PATCH v2 1/2] core/device: Add support for setting SDP record Bastien Nocera
  2017-11-08 19:38 ` [PATCH v2 2/2] plugins/sixaxis: Provide DualShock 3 SDP record while adding new device Bastien Nocera
@ 2017-11-09  9:18 ` Szymon Janc
  1 sibling, 0 replies; 4+ messages in thread
From: Szymon Janc @ 2017-11-09  9:18 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-bluetooth

Hi,

On Wednesday, 8 November 2017 20:38:27 CET Bastien Nocera wrote:
> From: Szymon Janc <szymon.janc@codecoup.pl>
> 
> This allows to set SDP record for device without resolving services
> over SDP. After SDP is provided profiles are probed.
> ---
>  src/device.c | 33 +++++++++++++++++++++++++++++++++
>  src/device.h |  3 +++
>  2 files changed, 36 insertions(+)
> 
> diff --git a/src/device.c b/src/device.c
> index c12407a73..e8118112e 100644
> --- a/src/device.c
> +++ b/src/device.c
> @@ -6073,6 +6073,39 @@ static sdp_list_t *read_device_records(struct
> btd_device *device) return recs;
>  }
> 
> +void btd_device_set_record(struct btd_device *device, const char *uuid,
> +							const char *record)
> +{
> +	/* This API is only used for BR/EDR */
> +	struct bearer_state *state = &device->bredr_state;
> +	struct browse_req *req;
> +	sdp_list_t *recs = NULL;
> +	sdp_record_t *rec;
> +
> +	if (!record)
> +		return;
> +
> +	req = browse_request_new(device, BROWSE_SDP, NULL);
> +	if (!req)
> +		return;
> +
> +	rec = record_from_string(record);
> +	recs = sdp_list_append(recs, rec);
> +	update_bredr_services(req, recs);
> +	sdp_list_free(recs, NULL);
> +
> +	device->svc_refreshed = true;
> +	state->svc_resolved = true;
> +
> +	device_probe_profiles(device, req->profiles_added);
> +
> +	/* Propagate services changes */
> +	g_dbus_emit_property_changed(dbus_conn, req->device->path,
> +						DEVICE_INTERFACE, "UUIDs");
> +
> +	device_svc_resolved(device, BROWSE_SDP, device->bdaddr_type, 0);
> +}
> +
>  const sdp_record_t *btd_device_get_record(struct btd_device *device,
>  							const char *uuid)
>  {
> diff --git a/src/device.h b/src/device.h
> index 850561729..32f8edce5 100644
> --- a/src/device.h
> +++ b/src/device.h
> @@ -62,6 +62,9 @@ struct device_addr_type {
>  int device_addr_type_cmp(gconstpointer a, gconstpointer b);
>  GSList *btd_device_get_uuids(struct btd_device *device);
>  void device_probe_profiles(struct btd_device *device, GSList *profiles);
> +
> +void btd_device_set_record(struct btd_device *device, const char *uuid,
> +							const char *record);
>  const sdp_record_t *btd_device_get_record(struct btd_device *device,
>  						const char *uuid);
>  struct gatt_primary *btd_device_get_primary(struct btd_device *device,

Both patches applied, thanks.

-- 
pozdrawiam
Szymon Janc

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-09  9:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-08 19:38 [PATCH v2 1/2] core/device: Add support for setting SDP record Bastien Nocera
2017-11-08 19:38 ` [PATCH v2 2/2] plugins/sixaxis: Provide DualShock 3 SDP record while adding new device Bastien Nocera
2017-11-08 19:59   ` Bastien Nocera
2017-11-09  9:18 ` [PATCH v2 1/2] core/device: Add support for setting SDP record Szymon Janc

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.