Linux bluetooth development
 help / color / mirror / Atom feed
* Re: [RFC v8 04/10] Bluetooth: Remove unused function
From: Marcel Holtmann @ 2014-02-14 22:28 UTC (permalink / raw)
  To: Andre Guedes; +Cc: bluez mailin list (linux-bluetooth@vger.kernel.org)
In-Reply-To: <1391639006-26311-4-git-send-email-andre.guedes@openbossa.org>

Hi Andre,

> This patch removes hci_create_le_conn() since it is not used anymore.
> 
> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
> ---
> net/bluetooth/hci_conn.c | 32 --------------------------------
> 1 file changed, 32 deletions(-)
> 
> diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
> index 166d7a5..70f4226 100644
> --- a/net/bluetooth/hci_conn.c
> +++ b/net/bluetooth/hci_conn.c
> @@ -551,38 +551,6 @@ done:
> 	hci_dev_unlock(hdev);
> }
> 
> -static int hci_create_le_conn(struct hci_conn *conn)
> -{
> -	struct hci_dev *hdev = conn->hdev;
> -	struct hci_cp_le_create_conn cp;
> -	struct hci_request req;
> -	int err;
> -
> -	hci_req_init(&req, hdev);
> -
> -	memset(&cp, 0, sizeof(cp));
> -	cp.scan_interval = cpu_to_le16(hdev->le_scan_interval);
> -	cp.scan_window = cpu_to_le16(hdev->le_scan_window);
> -	bacpy(&cp.peer_addr, &conn->dst);
> -	cp.peer_addr_type = conn->dst_type;
> -	cp.own_address_type = conn->src_type;
> -	cp.conn_interval_min = cpu_to_le16(conn->le_conn_min_interval);
> -	cp.conn_interval_max = cpu_to_le16(conn->le_conn_max_interval);
> -	cp.supervision_timeout = __constant_cpu_to_le16(0x002a);
> -	cp.min_ce_len = __constant_cpu_to_le16(0x0000);
> -	cp.max_ce_len = __constant_cpu_to_le16(0x0000);
> -
> -	hci_req_add(&req, HCI_OP_LE_CREATE_CONN, sizeof(cp), &cp);
> -
> -	err = hci_req_run(&req, create_le_conn_complete);
> -	if (err) {
> -		hci_conn_del(conn);
> -		return err;
> -	}
> -
> -	return 0;
> -}
> -
> static void create_le_conn_req(struct hci_request *req, struct hci_conn *conn)
> {
> 	struct hci_cp_le_create_conn cp;

not about this patch, but with my other comment, this one might be better renamed into hci_req_add_le_create_conn at some point. Not urgent though.

Regards

Marcel


^ permalink raw reply

* Re: [RFC v8 02/10] Bluetooth: Declare le_conn_failed in hci_core.h
From: Marcel Holtmann @ 2014-02-14 22:26 UTC (permalink / raw)
  To: Andre Guedes; +Cc: bluez mailin list (linux-bluetooth@vger.kernel.org)
In-Reply-To: <1391639006-26311-2-git-send-email-andre.guedes@openbossa.org>

Hi Andre,

> This patch adds the "hci_" prefix to le_conn_failed() helper and
> declares it in hci_core.h so it can be reused in hci_event.c.
> 
> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
> ---
> include/net/bluetooth/hci_core.h | 2 ++
> net/bluetooth/hci_conn.c         | 4 ++--
> net/bluetooth/hci_event.c        | 6 +-----
> 3 files changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index 8aff7f9..6e5062c 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -627,6 +627,8 @@ int hci_conn_switch_role(struct hci_conn *conn, __u8 role);
> 
> void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active);
> 
> +void hci_le_conn_failed(struct hci_conn *conn, u8 status);
> +
> /*
>  * hci_conn_get() and hci_conn_put() are used to control the life-time of an
>  * "hci_conn" object. They do not guarantee that the hci_conn object is running,
> diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
> index 6797292..4f5029c 100644
> --- a/net/bluetooth/hci_conn.c
> +++ b/net/bluetooth/hci_conn.c
> @@ -515,7 +515,7 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
> EXPORT_SYMBOL(hci_get_route);
> 
> /* This function requires the caller holds hdev->lock */
> -static void le_conn_failed(struct hci_conn *conn, u8 status)
> +void hci_le_conn_failed(struct hci_conn *conn, u8 status)
> {
> 	struct hci_dev *hdev = conn->hdev;
> 
> @@ -545,7 +545,7 @@ static void create_le_conn_complete(struct hci_dev *hdev, u8 status)
> 	if (!conn)
> 		goto done;
> 
> -	le_conn_failed(conn, status);
> +	hci_le_conn_failed(conn, status);
> 
> done:
> 	hci_dev_unlock(hdev);
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index d2c6878..df58cde 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -3601,11 +3601,7 @@ static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
> 	}
> 
> 	if (ev->status) {
> -		mgmt_connect_failed(hdev, &conn->dst, conn->type,
> -				    conn->dst_type, ev->status);
> -		hci_proto_connect_cfm(conn, ev->status);
> -		conn->state = BT_CLOSED;
> -		hci_conn_del(conn);
> +		hci_le_conn_failed(conn, ev->status);
> 		goto unlock;
> 	}

what is the difference between a le_conn_failed and a generic conn_failed.

I am not sure about the naming of this function if we make it non-static. Not that I have a better name at the moment. So we might just go ahead with it.

Regards

Marcel


^ permalink raw reply

* Re: [RFC v8 01/10] Bluetooth: Create hci_stop_le_scan_req() helper
From: Marcel Holtmann @ 2014-02-14 22:21 UTC (permalink / raw)
  To: Andre Guedes; +Cc: bluez mailin list (linux-bluetooth@vger.kernel.org)
In-Reply-To: <1391639006-26311-1-git-send-email-andre.guedes@openbossa.org>

Hi Andre,

> This patch moves stop LE scanning duplicate code to one single
> place and reuses it. This will avoid more duplicate code in
> upcoming patches.
> 
> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
> ---
> include/net/bluetooth/hci_core.h |  2 ++
> net/bluetooth/hci_core.c         | 14 ++++++++++----
> net/bluetooth/mgmt.c             |  6 +-----
> 3 files changed, 13 insertions(+), 9 deletions(-)
> 
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index 92fa75f..8aff7f9 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -1212,4 +1212,6 @@ void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8],
> #define SCO_AIRMODE_CVSD       0x0000
> #define SCO_AIRMODE_TRANSP     0x0003
> 
> +void hci_stop_le_scan_req(struct hci_request *req);
> +

this should be close to hci_req_add definition.

> #endif /* __HCI_CORE_H */
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index e774669..6529f4a 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -3058,7 +3058,6 @@ static void le_scan_disable_work(struct work_struct *work)
> {
> 	struct hci_dev *hdev = container_of(work, struct hci_dev,
> 					    le_scan_disable.work);
> -	struct hci_cp_le_set_scan_enable cp;
> 	struct hci_request req;
> 	int err;
> 
> @@ -3066,9 +3065,7 @@ static void le_scan_disable_work(struct work_struct *work)
> 
> 	hci_req_init(&req, hdev);
> 
> -	memset(&cp, 0, sizeof(cp));
> -	cp.enable = LE_SCAN_DISABLE;
> -	hci_req_add(&req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp);
> +	hci_stop_le_scan_req(&req);
> 
> 	err = hci_req_run(&req, le_scan_disable_work_complete);
> 	if (err)
> @@ -4523,3 +4520,12 @@ static void hci_cmd_work(struct work_struct *work)
> 		}
> 	}
> }
> +
> +void hci_stop_le_scan_req(struct hci_request *req)
> +{
> +	struct hci_cp_le_set_scan_enable cp;
> +
> +	memset(&cp, 0, sizeof(cp));
> +	cp.enable = LE_SCAN_DISABLE;
> +	hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp);
> +}

Can we call this function hci_req_add_le_scan_disable. We should be explicit on what functions are doing. Helpers are just helpers.

> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index ce7ef33..5c0d55d 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -3400,7 +3400,6 @@ static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data,
> 	struct hci_cp_remote_name_req_cancel cp;
> 	struct inquiry_entry *e;
> 	struct hci_request req;
> -	struct hci_cp_le_set_scan_enable enable_cp;
> 	int err;
> 
> 	BT_DBG("%s", hdev->name);
> @@ -3436,10 +3435,7 @@ static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data,
> 		} else {
> 			cancel_delayed_work(&hdev->le_scan_disable);
> 
> -			memset(&enable_cp, 0, sizeof(enable_cp));
> -			enable_cp.enable = LE_SCAN_DISABLE;
> -			hci_req_add(&req, HCI_OP_LE_SET_SCAN_ENABLE,
> -				    sizeof(enable_cp), &enable_cp);
> +			hci_stop_le_scan_req(&req);
> 		}
> 
> 		break;

Regards

Marcel


^ permalink raw reply

* Re: [PATCH 00/24] rfcomm fixes
From: Marcel Holtmann @ 2014-02-14 21:45 UTC (permalink / raw)
  To: Peter Hurley
  Cc: Gustavo F. Padovan, Johan Hedberg, Gianluca Anzolin,
	Alexander Holler, Andrey Vihrov, Sander Eikelenboom,
	bluez mailin list (linux-bluetooth@vger.kernel.org), linux-kernel
In-Reply-To: <1391997564-1805-1-git-send-email-peter@hurleysoftware.com>

Hi Peter,

> This patch series addresses a number of previously unknown issues
> with the RFCOMM tty device implementation, in addition to
> addressing the locking regression recently reported [1].
> 
> As Gianluca suggested and I agree, this series first reverts
> 3 of the 4 patches of 3.14-rc1 for bluetooth/rfcomm/tty.c.
> 
> The reasoning is detailed in the changelog for
>  Revert "Bluetooth: Always wait for a connection on RFCOMM open()"
> but the short answer is that it re-implements a long-standing
> bug by blocking on a non-blocking open.
> 
> This patch series corrects the reported regressions from 3.13
> (to the extent that correction is required). Specifically,
> the ModemManager regression reported by Gianluca Anzolin [2]
> and the rfcomm bind with wvdial reported by Andrey Vihrov [3].
> 
> tty: Fix ref counting for port krefs
> Bluetooth: Fix racy acquire of rfcomm_dev reference
> Bluetooth: Exclude released devices from RFCOMMGETDEVLIST ioctl
> Bluetooth: Release rfcomm_dev only once
> Bluetooth: Fix unreleased rfcomm_dev reference
>   These first 5 patches after the reverts
>   fix 4 different rfcomm_dev ref count mishandling bugs.
> 
> Bluetooth: Fix RFCOMM tty teardown race and
> Bluetooth: Serialize RFCOMMCREATEDEV and RFCOMMRELEASEDEV ioctls
>   Fix races which occur due to the design of the rfcomm ioctls
>   (note that buses don't have these kinds of races).
> 
> Bluetooth: Verify dlci not in use before rfcomm_dev create
> Bluetooth: Simplify RFCOMM session state eval
> Bluetooth: Refactor deferred setup test in rfcomm_dlc_close()
> Bluetooth: Refactor dlc disconnect logic in rfcomm_dlc_close()
> Bluetooth: Directly close dlc for not yet started RFCOMM session
>   These 5 patches fix issues with reusing the dlci after
>   closing the tty (found by unit test).
> 
> Bluetooth: Fix unsafe RFCOMM device parenting
> Bluetooth: Fix RFCOMM parent device for reused dlc
>   These 2 patches fix the ModemManager regression.
> 
> Bluetooth: Refactor rfcomm_dev_add()
> Bluetooth: Cleanup RFCOMM device registration error handling
>   These 2 patches fix an unreleased module reference while
>   error handling.
> 
> Bluetooth: Rename __rfcomm_dev_get() to __rfcomm_dev_lookup()
>   This is a trivial naming patch with no functional impact.
> 
> Bluetooth: Force -EIO from tty read/write if .activate() fails
>   The tty core provides an existing mechanism for failing
>   reads/writes if device activation fails (like an error
>   allocating the dlc).
> 
> Bluetooth: Don't fail RFCOMM tty writes
>   This patch implements buffered writes even if the device
>   is not connected.
> 
> While unit testing this, I discovered a serious defect in
> the way available space is computed that under-utilizes
> rfcomm i/o and may even halt further tx on that link, which
> is fixed by:
>  Bluetooth: Refactor write_room() calculation
>  Bluetooth: Fix write_room() calculation
> 
> 
> Note that this series does not fix the naively inefficient
> method of packetizing tty output; packetizing should be
> done on the krfcommd thread to take advantage of aggregating
> multiple tty writes into 1 or more packets. Look at any
> line-by-line console output to realize how under-utilized
> the rfcomm tty packeting is.
> 
> [1] http://www.spinics.net/lists/linux-wireless/msg117818.html
> [2] http://www.spinics.net/lists/linux-bluetooth/msg42075.html
> [3] http://www.spinics.net/lists/linux-bluetooth/msg42057.html
> 
> 
> Regards,
> 
> 
> Peter Hurley (24):
>  Revert "Bluetooth: Remove rfcomm_carrier_raised()"
>  Revert "Bluetooth: Always wait for a connection on RFCOMM open()"
>  Revert "Bluetooth: Move rfcomm_get_device() before
>    rfcomm_dev_activate()”

these 3 patches are in bluetooth-next to give them extra testing. We will get them into 3.14-rc4 after an extra week of them being in linux-next.

>  tty: Fix ref counting for port krefs

I am taking this one with Greg’s ack through bluetooth-next. Unless someone objects.

>  Bluetooth: Fix racy acquire of rfcomm_dev reference
>  Bluetooth: Exclude released devices from RFCOMMGETDEVLIST ioctl
>  Bluetooth: Release rfcomm_dev only once
>  Bluetooth: Fix unreleased rfcomm_dev reference
>  Bluetooth: Fix RFCOMM tty teardown race
>  Bluetooth: Verify dlci not in use before rfcomm_dev create
>  Bluetooth: Simplify RFCOMM session state eval
>  Bluetooth: Refactor deferred setup test in rfcomm_dlc_close()
>  Bluetooth: Refactor dlc disconnect logic in rfcomm_dlc_close()
>  Bluetooth: Directly close dlc for not yet started RFCOMM session
>  Bluetooth: Fix unsafe RFCOMM device parenting
>  Bluetooth: Fix RFCOMM parent device for reused dlc
>  Bluetooth: Rename __rfcomm_dev_get() to __rfcomm_dev_lookup()
>  Bluetooth: Serialize RFCOMMCREATEDEV and RFCOMMRELEASEDEV ioctls
>  Bluetooth: Refactor rfcomm_dev_add()
>  Bluetooth: Cleanup RFCOMM device registration error handling
>  Bluetooth: Force -EIO from tty read/write if .activate() fails
>  Bluetooth: Don't fail RFCOMM tty writes
>  Bluetooth: Refactor write_room() calculation
>  Bluetooth: Fix write_room() calculation
> 
> include/linux/tty.h            |   6 +-
> include/net/bluetooth/rfcomm.h |   9 +-
> net/bluetooth/rfcomm/core.c    |  88 ++++++++++----
> net/bluetooth/rfcomm/tty.c     | 262 ++++++++++++++++++++++-------------------
> 4 files changed, 223 insertions(+), 142 deletions(-)

all patches have been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply

* Re: [PATCH] Bluetooth: Officially enable LE CoC support
From: Marcel Holtmann @ 2014-02-14 21:15 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: bluez mailin list (linux-bluetooth@vger.kernel.org)
In-Reply-To: <1392356451-14435-1-git-send-email-johan.hedberg@gmail.com>

Hi Johan,

> Now that the LE Connection oriented Channel support has undergone a
> decent amount of testing we can make it officially supported. This patch
> removes the enable_lecoc debugfs switch which was previously needed to
> enable support for LE CoC.
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/l2cap_core.c | 11 -----------
> net/bluetooth/l2cap_sock.c | 29 -----------------------------
> 2 files changed, 40 deletions(-)

I had to fix the description a bit ;)

Patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply

* Re: [PATCH] btusb.c add IMC Networks id 13d3:3404 (bcm20702A0) - retry
From: Marcel Holtmann @ 2014-02-14 21:02 UTC (permalink / raw)
  To: Jurgen Kramer; +Cc: BlueZ development
In-Reply-To: <1392370354.2437.2.camel@develbox>

Hi Jurgen,

> From 343f62050b33972929db749aee296e98332600d6 Mon Sep 17 00:00:00 2001
> From: Jurgen Kramer <gtmkramer@xs4all.nl>
> Date: Fri, 14 Feb 2014 10:22:51 +0100
> Subject: [PATCH] btusb.c add IMC Networks id 13d3:3404 (bcm20702A0)
> 
> ---
> drivers/bluetooth/btusb.c | 1 +
> 1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index 3980fd1..5dce16d 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -106,6 +106,7 @@ static const struct usb_device_id btusb_table[] = {
> 	{ USB_DEVICE(0x04ca, 0x2003) },
> 	{ USB_DEVICE(0x0489, 0xe042) },
> 	{ USB_DEVICE(0x413c, 0x8197) },
> +	{ USB_DEVICE(0x13d3, 0x3404) },
> 
> 	/* Foxconn - Hon Hai */
> 	{ USB_VENDOR_AND_INTERFACE_INFO(0x0489, 0xff, 0x01, 0x01) },
> -- 
> 1.8.5.3
> 
> Signed-off-by: Jurgen Kramer <gtm.kramer@xs4all.nl>
> 
> Retry. I've included the relevant part of the
> requested /sys/kernel/debug/usb/devices output.
> 
> Jurgen
> <sys-kernel-debug-usb-devices-0x13d3-0x3404.txt>

can please create a proper patch with git-format-patch and send it with git-send-email. Look at how others have done it. I want the debug/usb/devices part as part of the commit message.

Also since the vendor id 13d3 belongs to IMC networks, you might want to add a comment saying “IMC Networks (Broadcom based)”. Alternative using USB_VENDOR_AND_INTERFACE_INFO might be an option as well.

Regards

Marcel



^ permalink raw reply

* Re: [PATCHv3] hog: Use HoG device name as uHID input device name
From: Petri Gynther @ 2014-02-14 20:49 UTC (permalink / raw)
  To: Johan Hedberg, linux-bluetooth
In-Reply-To: <20140213091902.GA2754@x220.p-661hnu-f1>

Hi Johan,

On Thu, Feb 13, 2014 at 1:19 AM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Petri,
>
> On Wed, Jan 29, 2014, Petri Gynther wrote:
>> If HoG BLE device name is known, use it when creating uHID input device.
>> Pass adapter and device addresses to uHID as well.
>
> Could you perhaps elaborate a bit what exactly the "uniq" and "phys"
> members are in the request (possibly with a reference to the uHID
> documentation). That would make it easier to verify that the content
> you're adding to them makes sense.
>

>From linux/include/linux/hid.h:
struct hid_device {
  ...
  char name[128];    /* Device name */
  char phys[64];        /* Device physical location */
  char uniq[64];         /* Device unique identifier (serial #) */

So, for a Bluetooth HID or HoG device, BT adapter MAC address is good
fit for "phys" and device MAC address is good for "uniq". This is what
hidp module in kernel already does. But, we can be more descriptive
here if we want. These values are readable in sysfs under
/sys/devices/virtual/input/<input-device>.

>> +     if (device_name_known(hogdev->device)) {
>> +             device_get_name(hogdev->device, (char *) ev.u.create.name,
>> +                             sizeof(ev.u.create.name) - 1);
>> +     } else {
>> +             strcpy((char *) ev.u.create.name, "bluez-hog-device");
>> +     }
>
> We don't use { } for single line branches, so you can drop these here.
>

I'll fix this.

>> +     ba2str(btd_adapter_get_address(device_get_adapter(hogdev->device)),
>> +             (char *) ev.u.create.phys);
>
> This is getting a bit messy with the nested function calls. I'd add
> separate adapter variable here to make this a bit more readable.
>
> Also note our coding style wrt split lines: indent the continuation
> lines as much as you can (with tabs) as long as it's under 80 chars.
>
> Also, it might be good to split this up into two patches since you've
> essentially got two independent improvements here. One is making sure
> the name member contains something more useful and the other is adding
> some content to the uniq and phys members.

I'll add name, phys, and uniq variables in struct hog_device, so that
they are easy to pass to uHID when it is time to create the uHID
device.

>
> Johan

^ permalink raw reply

* Re: [PATCH v2] Bluetooth: Add hci_h4p driver
From: Sebastian Reichel @ 2014-02-14 17:28 UTC (permalink / raw)
  To: Pali Rohár, Ben Hutchings
  Cc: Pavel Machek,
	Ивайло Димитров,
	linux-kernel, linux-bluetooth@vger.kernel.org development
In-Reply-To: <CAHYPw2EJC9RwgzXmGuQgh5_L6EMtS7MW8N3u2dR8KeVc0kb43g@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2141 bytes --]

Hi Pali,

On Thu, Feb 13, 2014 at 04:33:28PM +0100, Pali Rohár wrote:
> 2014-01-08 22:36 GMT+01:00 Pali Rohár <pali.rohar@gmail.com>:
> > On Monday 30 December 2013 15:52:51 Sebastian Reichel wrote:
> >> > > > +MODULE_DESCRIPTION("Bluetooth h4 driver with nokia
> >> > > > extensions"); +MODULE_LICENSE("GPL");
> >> > > > +MODULE_AUTHOR("Ville Tervo");
> >> > > > +MODULE_FIRMWARE(FW_NAME_TI1271_PRELE);
> >> > > > +MODULE_FIRMWARE(FW_NAME_TI1271_LE);
> >> > > > +MODULE_FIRMWARE(FW_NAME_TI1271);
> >> > > > +MODULE_FIRMWARE(FW_NAME_BCM2048);
> >> > > > +MODULE_FIRMWARE(FW_NAME_CSR);
> >> > >
> >> > > Do we actually have all these firmware files still
> >> > > available. If not, then focus on the ones we have.
> >> >
> >> > Firmware files are available for download from nemo project:
> >> >
> >> > https://api.merproject.org/public/source/nemo:devel:hw:ti:om
> >> > ap3:n900/bcm-bt-firmware/bcm-bt-firmware-0.21rc3.tar.bz2
> >> > https://api.merproject.org/public/source/nemo:devel:hw:ti:o
> >> > map3:n950-n9/ti-wl1273-bt-firmware/bt-firmware-ti1273_0.23+0
> >> > m6.tar.gz
> >>
> >> Would be nice to have them added to the linux-firmware.git.
> >
> Now when driver is queued for staging, can somebody add firmware files
> to linux-firmware repository? Note that without firmware files, driver
> not working...

I just had a look at the file for the Nokia N900
(bcm-bt-firmware-0.21rc3.tar.bz2) and I think the license is too
restrictive for linux-firmware.git. Actually I can't see any
statement allowing redistribution. For reference this is the license
text:

Copyright (c) Nokia Corporation 2010
All Rights Reserved.

This material, including documentation and any related computer programs, is
protected by copyright controlled by Nokia Corporation. All rights are
reserved. Modifying, adapting and/or translating, any or all of this material
requires the prior written consent of Nokia. Distribution for commercial
purposes not allowed without prior written approval from Nokia.

Anyways, I added Ben to the discussion (maintainer of the
linux-firmware repository)

-- Sebastian

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply

* [PATCH BlueZ 8/8] doc/obex-api: Update documentation
From: Luiz Augusto von Dentz @ 2014-02-14 15:53 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: patrick.ohly
In-Reply-To: <1392393184-15266-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds Suspend and Resume methods and 'suspended' value as status in
the Transfer interface documentation.
---
 doc/obex-api.txt | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/doc/obex-api.txt b/doc/obex-api.txt
index 1f22fea..0f57ce1 100644
--- a/doc/obex-api.txt
+++ b/doc/obex-api.txt
@@ -90,12 +90,26 @@ Methods		void Cancel()
 					 org.bluez.obex.Error.InProgress
 					 org.bluez.obex.Error.Failed
 
+		void Suspend()
+
+			Suspend transference.
+
+			Possible errors: org.bluez.obex.Error.NotAuthorized
+					 org.bluez.obex.Error.NotInProgress
+
+		void Resume()
+
+			Resume transference.
+
+			Possible errors: org.bluez.obex.Error.NotAuthorized
+					 org.bluez.obex.Error.NotInProgress
+
 Properties	string Status [readonly]
 
 			Inform the current status of the transfer.
 
-			Possible values: "queued", "active", "complete" or
-					"error"
+			Possible values: "queued", "active", "suspended",
+					"complete" or "error"
 
 		object Session [readonly]
 
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH BlueZ 7/8] gobex: Handle suspending/resuming for GET when SRM is active
From: Luiz Augusto von Dentz @ 2014-02-14 15:53 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: patrick.ohly
In-Reply-To: <1392393184-15266-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds support for suspending/resuming GET requests GET when SRM is
active, in this case suspending the TX queue wont stop the remote
to continue sending packets, to do that SRMP header should be set to wait
so the remote should wait.
---
 gobex/gobex-transfer.c |  2 +-
 gobex/gobex.c          | 56 ++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/gobex/gobex-transfer.c b/gobex/gobex-transfer.c
index b815d60..09f56ba 100644
--- a/gobex/gobex-transfer.c
+++ b/gobex/gobex-transfer.c
@@ -390,7 +390,7 @@ static void transfer_put_req(GObex *obex, GObexPacket *req, gpointer user_data)
 
 	rspcode = put_get_bytes(transfer, req);
 
-	/* Don't send continue while in SRM */
+	/* Don't send continue while SRM is active */
 	if (g_obex_srm_active(transfer->obex) &&
 				rspcode == G_OBEX_RSP_CONTINUE)
 		goto done;
diff --git a/gobex/gobex.c b/gobex/gobex.c
index 291ed72..0d9b449 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
@@ -105,6 +105,7 @@ struct pending_pkt {
 	GObexResponseFunc rsp_func;
 	gpointer rsp_data;
 	gboolean cancelled;
+	gboolean suspended;
 };
 
 struct req_handler {
@@ -407,7 +408,9 @@ static void setup_srm(GObex *obex, GObexPacket *pkt, gboolean outgoing)
 		g_obex_header_get_uint8(hdr, &srmp);
 		g_obex_debug(G_OBEX_DEBUG_COMMAND, "srmp 0x%02x", srmp);
 		set_srmp(obex, srmp, outgoing);
-	} else
+	} else if (obex->pending_req && obex->pending_req->suspended)
+		g_obex_packet_add_uint8(pkt, G_OBEX_HDR_SRMP, G_OBEX_SRMP_WAIT);
+	else
 		set_srmp(obex, -1, outgoing);
 
 	if (final)
@@ -845,24 +848,73 @@ gboolean g_obex_remove_request_function(GObex *obex, guint id)
 	return TRUE;
 }
 
+static void g_obex_srm_suspend(GObex *obex)
+{
+	struct pending_pkt *p = obex->pending_req;
+	GObexPacket *req;
+
+	g_source_remove(p->timeout_id);
+	p->suspended = TRUE;
+
+	req = g_obex_packet_new(G_OBEX_OP_GET, TRUE,
+					G_OBEX_HDR_SRMP, G_OBEX_SRMP_WAIT,
+					G_OBEX_HDR_INVALID);
+
+	g_obex_send(obex, req, NULL);
+}
+
 void g_obex_suspend(GObex *obex)
 {
+	struct pending_pkt *req = obex->pending_req;
+
 	g_obex_debug(G_OBEX_DEBUG_COMMAND, "conn %u", obex->conn_id);
 
+	if (!g_obex_srm_active(obex) || !req)
+		goto done;
+
+	/* Send SRMP wait in case of GET */
+	if (g_obex_packet_get_operation(req->pkt, NULL) == G_OBEX_OP_GET) {
+		g_obex_srm_suspend(obex);
+		return;
+	}
+
+done:
+	obex->suspended = TRUE;
+
 	if (obex->write_source > 0) {
 		g_source_remove(obex->write_source);
 		obex->write_source = 0;
 	}
+}
 
-	obex->suspended = TRUE;
+static void g_obex_srm_resume(GObex *obex)
+{
+	struct pending_pkt *p = obex->pending_req;
+	GObexPacket *req;
+
+	p->timeout_id = g_timeout_add_seconds(p->timeout, req_timeout, obex);
+	p->suspended = FALSE;
+
+	req = g_obex_packet_new(G_OBEX_OP_GET, TRUE, G_OBEX_HDR_INVALID);
+
+	g_obex_send(obex, req, NULL);
 }
 
 void g_obex_resume(GObex *obex)
 {
+	struct pending_pkt *req = obex->pending_req;
+
 	g_obex_debug(G_OBEX_DEBUG_COMMAND, "conn %u", obex->conn_id);
 
 	obex->suspended = FALSE;
 
+	if (g_obex_srm_active(obex) || !req)
+		goto done;
+
+	if (g_obex_packet_get_operation(req->pkt, NULL) == G_OBEX_OP_GET)
+		g_obex_srm_resume(obex);
+
+done:
 	if (g_queue_get_length(obex->tx_queue) > 0 || obex->tx_data > 0)
 		enable_tx(obex);
 }
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH BlueZ 6/8] gobex: Fix not handling SRM properly
From: Luiz Augusto von Dentz @ 2014-02-14 15:53 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: patrick.ohly
In-Reply-To: <1392393184-15266-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

SRM can be enabled but while not active with use of SRMP header so the
handling of this states needs to be separated.
---
 gobex/gobex.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/gobex/gobex.c b/gobex/gobex.c
index 8c08b1e..291ed72 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
@@ -355,9 +355,20 @@ done:
 	obex->srm = NULL;
 }
 
+static gboolean g_obex_srm_enabled(GObex *obex)
+{
+	if (!obex->use_srm)
+		return FALSE;
+
+	if (obex->srm == NULL)
+		return FALSE;
+
+	return obex->srm->enabled;
+}
+
 static void check_srm_final(GObex *obex, guint8 op)
 {
-	if (obex->srm == NULL || !obex->srm->enabled)
+	if (!g_obex_srm_enabled(obex))
 		return;
 
 	switch (obex->srm->op) {
@@ -423,7 +434,7 @@ static gboolean write_data(GIOChannel *io, GIOCondition cond,
 
 		setup_srm(obex, p->pkt, TRUE);
 
-		if (g_obex_srm_active(obex))
+		if (g_obex_srm_enabled(obex))
 			goto encode;
 
 		/* Can't send a request while there's a pending one */
@@ -646,7 +657,7 @@ guint g_obex_send_req(GObex *obex, GObexPacket *req, int timeout,
 	if (obex->rx_last_op == G_OBEX_RSP_CONTINUE)
 		goto create_pending;
 
-	if (g_obex_srm_active(obex) && obex->pending_req != NULL)
+	if (g_obex_srm_enabled(obex) && obex->pending_req != NULL)
 		goto create_pending;
 
 	hdr = g_obex_packet_get_header(req, G_OBEX_HDR_CONNECTION);
@@ -860,10 +871,7 @@ gboolean g_obex_srm_active(GObex *obex)
 {
 	gboolean ret = FALSE;
 
-	if (!obex->use_srm)
-		return FALSE;
-
-	if (obex->srm == NULL || !obex->srm->enabled)
+	if (!g_obex_srm_enabled(obex))
 		goto done;
 
 	if (obex->srm->srmp <= G_OBEX_SRMP_NEXT_WAIT)
@@ -912,7 +920,7 @@ static gboolean parse_response(GObex *obex, GObexPacket *rsp)
 
 	setup_srm(obex, rsp, FALSE);
 
-	if (!g_obex_srm_active(obex))
+	if (!g_obex_srm_enabled(obex))
 		return final;
 
 	/*
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH BlueZ 5/8] unit/test-gobex-transfer: Add /gobex/test_packet_get_req_suspend_resume
From: Luiz Augusto von Dentz @ 2014-02-14 15:53 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: patrick.ohly
In-Reply-To: <1392393184-15266-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds a test to call g_obex_suspend and latter g_obex_resume while
SRM is enabled.
---
 unit/test-gobex-transfer.c | 81 +++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 77 insertions(+), 4 deletions(-)

diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c
index 7c9fd43..0d26111 100644
--- a/unit/test-gobex-transfer.c
+++ b/unit/test-gobex-transfer.c
@@ -106,6 +106,9 @@ static guint8 get_req_first_srm_wait[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x27
 	0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0,
 	G_OBEX_HDR_SRMP, 0x01 };
 
+static guint8 get_req_srm_wait[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x05,
+	G_OBEX_HDR_SRMP, 0x01 };
+
 static guint8 get_req_last[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x03, };
 
 static guint8 get_rsp_first_app[] = { G_OBEX_RSP_CONTINUE | FINAL_BIT, 0x00, 0x0A,
@@ -124,6 +127,8 @@ static guint8 get_rsp_first_srm_wait_next[] = { G_OBEX_RSP_CONTINUE | FINAL_BIT,
 					G_OBEX_HDR_SRMP, 0x02,
 					G_OBEX_HDR_BODY, 0x00, 0x0d,
 					0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+static guint8 get_rsp_srm_wait[] = { G_OBEX_RSP_CONTINUE | FINAL_BIT,
+					0x00, 0x03 };
 static guint8 get_rsp_zero[255] = { G_OBEX_RSP_CONTINUE | FINAL_BIT, 0x00, 0xff,
 					G_OBEX_HDR_BODY, 0x00, 0xfc };
 static guint8 get_rsp_zero_wait_next[255] = { G_OBEX_RSP_CONTINUE | FINAL_BIT,
@@ -191,7 +196,13 @@ static void transfer_complete(GObex *obex, GError *err, gpointer user_data)
 
 static gboolean resume_obex(gpointer user_data)
 {
-	g_obex_resume(user_data);
+	struct test_data *d = user_data;
+
+	if (!g_main_loop_is_running(d->mainloop))
+		return FALSE;
+
+	g_obex_resume(d->obex);
+
 	return FALSE;
 }
 
@@ -232,7 +243,7 @@ static gssize provide_eagain(void *buf, gsize len, gpointer user_data)
 	}
 
 	if (d->provide_delay > 0) {
-		g_timeout_add(d->provide_delay, resume_obex, d->obex);
+		g_timeout_add(d->provide_delay, resume_obex, d);
 		d->provide_delay = 0;
 		return -EAGAIN;
 	}
@@ -260,7 +271,7 @@ static gssize provide_data(void *buf, gsize len, gpointer user_data)
 
 	if (d->provide_delay > 0) {
 		g_obex_suspend(d->obex);
-		g_timeout_add(d->provide_delay, resume_obex, d->obex);
+		g_timeout_add(d->provide_delay, resume_obex, d);
 	}
 
 	d->total += sizeof(body_data);
@@ -852,6 +863,66 @@ static void test_packet_get_req_wait(void)
 	g_assert_no_error(d.err);
 }
 
+static gboolean rcv_seq_delay(const void *buf, gsize len, gpointer user_data)
+{
+	struct test_data *d = user_data;
+
+	if (d->provide_delay > 0) {
+		g_obex_suspend(d->obex);
+		g_idle_add(resume_obex, d);
+		d->provide_delay = 0;
+	}
+
+	return TRUE;
+}
+
+static void test_packet_get_req_suspend_resume(void)
+{
+	GIOChannel *io;
+	GIOCondition cond;
+	guint io_id, timer_id;
+	GObex *obex;
+	struct test_data d = { 0, NULL, {
+		{ get_req_first_srm, sizeof(get_req_first_srm) },
+		{ get_req_srm_wait, sizeof(get_req_srm_wait) },
+		{ get_req_srm_wait, sizeof(get_req_srm_wait) },
+		{ get_req_last, sizeof(get_req_last) } }, {
+		{ get_rsp_first_srm, sizeof(get_rsp_first_srm) },
+		{ get_rsp_srm_wait, sizeof(get_rsp_srm_wait) },
+		{ get_rsp_srm_wait, sizeof(get_rsp_srm_wait) },
+		{ get_rsp_last, sizeof(get_rsp_last) } } };
+
+	create_endpoints(&obex, &io, SOCK_SEQPACKET);
+	d.obex = obex;
+	d.provide_delay = 1;
+
+	cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
+	io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+
+	d.mainloop = g_main_loop_new(NULL, FALSE);
+
+	timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+
+	g_obex_get_req(obex, rcv_seq_delay, transfer_complete, &d, &d.err,
+				G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type),
+				G_OBEX_HDR_NAME, "file.txt",
+				G_OBEX_HDR_INVALID);
+	g_assert_no_error(d.err);
+
+	g_main_loop_run(d.mainloop);
+
+	g_assert_cmpuint(d.count, ==, 4);
+
+	g_main_loop_unref(d.mainloop);
+
+	g_source_remove(timer_id);
+	g_io_channel_unref(io);
+	g_source_remove(io_id);
+	g_obex_unref(obex);
+
+	g_assert_no_error(d.err);
+}
+
 static void test_packet_get_req_wait_next(void)
 {
 	GIOChannel *io;
@@ -1549,7 +1620,7 @@ static gboolean rcv_data_delay(const void *buf, gsize len, gpointer user_data)
 
 	if (d->provide_delay > 0) {
 		g_obex_suspend(d->obex);
-		g_timeout_add(d->provide_delay, resume_obex, d->obex);
+		g_timeout_add(d->provide_delay, resume_obex, d);
 	}
 
 	return TRUE;
@@ -2253,6 +2324,8 @@ int main(int argc, char *argv[])
 	g_test_add_func("/gobex/test_packet_get_req", test_packet_get_req);
 	g_test_add_func("/gobex/test_packet_get_req_wait",
 						test_packet_get_req_wait);
+	g_test_add_func("/gobex/test_packet_get_req_suspend_resume",
+					test_packet_get_req_suspend_resume);
 
 	g_test_add_func("/gobex/test_packet_get_req_wait_next",
 						test_packet_get_req_wait_next);
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH BlueZ 4/8] tools/obexctl: Add resume command
From: Luiz Augusto von Dentz @ 2014-02-14 15:53 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: patrick.ohly
In-Reply-To: <1392393184-15266-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Add support for resume command which can be used to resume ongoing
transfers.
---
 tools/obexctl.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/tools/obexctl.c b/tools/obexctl.c
index 000e44d..fc051d7 100644
--- a/tools/obexctl.c
+++ b/tools/obexctl.c
@@ -636,6 +636,46 @@ static void cmd_suspend(int argc, char *argv[])
 						g_dbus_proxy_get_path(proxy));
 }
 
+static void resume_reply(DBusMessage *message, void *user_data)
+{
+	DBusError error;
+
+	dbus_error_init(&error);
+
+	if (dbus_set_error_from_message(&error, message) == TRUE) {
+		rl_printf("Failed to resume: %s\n", error.name);
+		dbus_error_free(&error);
+		return;
+	}
+
+	rl_printf("Resume successful\n");
+}
+
+static void cmd_resume(int argc, char *argv[])
+{
+	GDBusProxy *proxy;
+
+	if (argc < 2) {
+		rl_printf("Missing transfer address argument\n");
+		return;
+	}
+
+	proxy = find_transfer(argv[1]);
+	if (!proxy) {
+		rl_printf("Transfer %s not available\n", argv[1]);
+		return;
+	}
+
+	if (g_dbus_proxy_method_call(proxy, "Resume", NULL, resume_reply,
+						NULL, NULL) == FALSE) {
+		rl_printf("Failed to resume transfer\n");
+		return;
+	}
+
+	rl_printf("Attempting to resume transfer %s\n",
+						g_dbus_proxy_get_path(proxy));
+}
+
 static GDBusProxy *find_opp(const char *path)
 {
 	GSList *l;
@@ -1897,6 +1937,7 @@ static const struct {
 	{ "info",         "<object>", cmd_info, "Object information" },
 	{ "cancel",       "<transfer>", cmd_cancel, "Cancel transfer" },
 	{ "suspend",      "<transfer>", cmd_suspend, "Suspend transfer" },
+	{ "resume",       "<transfer>", cmd_resume, "Resume transfer" },
 	{ "send",         "<file>",   cmd_send, "Send file" },
 	{ "cd",           "<path>",   cmd_cd, "Change current folder" },
 	{ "ls",           NULL,       cmd_ls, "List current folder" },
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH BlueZ 3/8] tools/obexctl: Add suspend command
From: Luiz Augusto von Dentz @ 2014-02-14 15:52 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: patrick.ohly
In-Reply-To: <1392393184-15266-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Add support for suspend command which can be used to suspend ongoing
transfers.
---
 tools/obexctl.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/tools/obexctl.c b/tools/obexctl.c
index f0d5438..000e44d 100644
--- a/tools/obexctl.c
+++ b/tools/obexctl.c
@@ -596,6 +596,46 @@ static void cmd_cancel(int argc, char *argv[])
 						g_dbus_proxy_get_path(proxy));
 }
 
+static void suspend_reply(DBusMessage *message, void *user_data)
+{
+	DBusError error;
+
+	dbus_error_init(&error);
+
+	if (dbus_set_error_from_message(&error, message) == TRUE) {
+		rl_printf("Failed to suspend: %s\n", error.name);
+		dbus_error_free(&error);
+		return;
+	}
+
+	rl_printf("Suspend successful\n");
+}
+
+static void cmd_suspend(int argc, char *argv[])
+{
+	GDBusProxy *proxy;
+
+	if (argc < 2) {
+		rl_printf("Missing transfer address argument\n");
+		return;
+	}
+
+	proxy = find_transfer(argv[1]);
+	if (!proxy) {
+		rl_printf("Transfer %s not available\n", argv[1]);
+		return;
+	}
+
+	if (g_dbus_proxy_method_call(proxy, "Suspend", NULL, suspend_reply,
+						NULL, NULL) == FALSE) {
+		rl_printf("Failed to suspend transfer\n");
+		return;
+	}
+
+	rl_printf("Attempting to suspend transfer %s\n",
+						g_dbus_proxy_get_path(proxy));
+}
+
 static GDBusProxy *find_opp(const char *path)
 {
 	GSList *l;
@@ -1856,6 +1896,7 @@ static const struct {
 	{ "select",       "<session>", cmd_select, "Select default session" },
 	{ "info",         "<object>", cmd_info, "Object information" },
 	{ "cancel",       "<transfer>", cmd_cancel, "Cancel transfer" },
+	{ "suspend",      "<transfer>", cmd_suspend, "Suspend transfer" },
 	{ "send",         "<file>",   cmd_send, "Send file" },
 	{ "cd",           "<path>",   cmd_cd, "Change current folder" },
 	{ "ls",           NULL,       cmd_ls, "List current folder" },
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH BlueZ 2/8] obexd/transfer: Add Transfer.Resume method
From: Luiz Augusto von Dentz @ 2014-02-14 15:52 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: patrick.ohly
In-Reply-To: <1392393184-15266-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This method can be used to resume ongoing transfers.
---
 obexd/client/transfer.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/obexd/client/transfer.c b/obexd/client/transfer.c
index 813d20b..6295b83 100644
--- a/obexd/client/transfer.c
+++ b/obexd/client/transfer.c
@@ -223,6 +223,30 @@ static DBusMessage *obc_transfer_suspend(DBusConnection *connection,
 	return g_dbus_create_reply(message, DBUS_TYPE_INVALID);
 }
 
+static DBusMessage *obc_transfer_resume(DBusConnection *connection,
+					DBusMessage *message, void *user_data)
+{
+	struct obc_transfer *transfer = user_data;
+	const char *sender;
+
+	sender = dbus_message_get_sender(message);
+	if (g_strcmp0(transfer->owner, sender) != 0)
+		return g_dbus_create_error(message,
+				ERROR_INTERFACE ".NotAuthorized",
+				"Not Authorized");
+
+	if (transfer->xfer == 0)
+		return g_dbus_create_error(message,
+				ERROR_INTERFACE ".NotInProgress",
+				"Not in progress");
+
+	g_obex_resume(transfer->obex);
+
+	transfer_set_status(transfer, TRANSFER_STATUS_ACTIVE);
+
+	return g_dbus_create_reply(message, DBUS_TYPE_INVALID);
+}
+
 static gboolean name_exists(const GDBusPropertyTable *property, void *data)
 {
 	struct obc_transfer *transfer = data;
@@ -339,6 +363,7 @@ static gboolean get_session(const GDBusPropertyTable *property,
 
 static const GDBusMethodTable obc_transfer_methods[] = {
 	{ GDBUS_METHOD("Suspend", NULL, NULL, obc_transfer_suspend) },
+	{ GDBUS_METHOD("Resume", NULL, NULL, obc_transfer_resume) },
 	{ GDBUS_ASYNC_METHOD("Cancel", NULL, NULL,
 				obc_transfer_cancel) },
 	{ }
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH BlueZ 1/8] obexd/transfer: Add Transfer.Suspend method
From: Luiz Augusto von Dentz @ 2014-02-14 15:52 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: patrick.ohly

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This method can be used to suspend ongoing transfers.
---
 obexd/client/transfer.c | 60 ++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 47 insertions(+), 13 deletions(-)

diff --git a/obexd/client/transfer.c b/obexd/client/transfer.c
index 5a8d4f2..813d20b 100644
--- a/obexd/client/transfer.c
+++ b/obexd/client/transfer.c
@@ -60,6 +60,7 @@ struct transfer_callback {
 enum {
 	TRANSFER_STATUS_QUEUED = 0,
 	TRANSFER_STATUS_ACTIVE,
+	TRANSFER_STATUS_SUSPENDED,
 	TRANSFER_STATUS_COMPLETE,
 	TRANSFER_STATUS_ERROR
 };
@@ -187,6 +188,41 @@ static DBusMessage *obc_transfer_cancel(DBusConnection *connection,
 	return NULL;
 }
 
+static void transfer_set_status(struct obc_transfer *transfer, uint8_t status)
+{
+	if (transfer->status == status)
+		return;
+
+	transfer->status = status;
+
+	g_dbus_emit_property_changed(transfer->conn, transfer->path,
+					TRANSFER_INTERFACE, "Status");
+}
+
+static DBusMessage *obc_transfer_suspend(DBusConnection *connection,
+					DBusMessage *message, void *user_data)
+{
+	struct obc_transfer *transfer = user_data;
+	const char *sender;
+
+	sender = dbus_message_get_sender(message);
+	if (g_strcmp0(transfer->owner, sender) != 0)
+		return g_dbus_create_error(message,
+				ERROR_INTERFACE ".NotAuthorized",
+				"Not Authorized");
+
+	if (transfer->xfer == 0)
+		return g_dbus_create_error(message,
+				ERROR_INTERFACE ".NotInProgress",
+				"Not in progress");
+
+	g_obex_suspend(transfer->obex);
+
+	transfer_set_status(transfer, TRANSFER_STATUS_SUSPENDED);
+
+	return g_dbus_create_reply(message, DBUS_TYPE_INVALID);
+}
+
 static gboolean name_exists(const GDBusPropertyTable *property, void *data)
 {
 	struct obc_transfer *transfer = data;
@@ -269,6 +305,8 @@ static const char *status2str(uint8_t status)
 		return "queued";
 	case TRANSFER_STATUS_ACTIVE:
 		return "active";
+	case TRANSFER_STATUS_SUSPENDED:
+		return "suspended";
 	case TRANSFER_STATUS_COMPLETE:
 		return "complete";
 	case TRANSFER_STATUS_ERROR:
@@ -300,6 +338,7 @@ static gboolean get_session(const GDBusPropertyTable *property,
 }
 
 static const GDBusMethodTable obc_transfer_methods[] = {
+	{ GDBUS_METHOD("Suspend", NULL, NULL, obc_transfer_suspend) },
 	{ GDBUS_ASYNC_METHOD("Cancel", NULL, NULL,
 				obc_transfer_cancel) },
 	{ }
@@ -549,14 +588,6 @@ static gboolean get_xfer_progress(const void *buf, gsize len,
 	return TRUE;
 }
 
-static void transfer_set_status(struct obc_transfer *transfer, uint8_t status)
-{
-	transfer->status = status;
-
-	g_dbus_emit_property_changed(transfer->conn, transfer->path,
-					TRANSFER_INTERFACE, "Status");
-}
-
 static void xfer_complete(GObex *obex, GError *err, gpointer user_data)
 {
 	struct obc_transfer *transfer = user_data;
@@ -634,13 +665,15 @@ static void get_xfer_progress_first(GObex *obex, GError *err, GObexPacket *rsp,
 		return;
 	}
 
-	if (!g_obex_srm_active(obex)) {
-		req = g_obex_packet_new(G_OBEX_OP_GET, TRUE, G_OBEX_HDR_INVALID);
+	if (g_obex_srm_active(obex) ||
+				transfer->status == TRANSFER_STATUS_SUSPENDED)
+		return;
 
-		transfer->xfer = g_obex_get_req_pkt(obex, req, get_xfer_progress,
+	req = g_obex_packet_new(G_OBEX_OP_GET, TRUE, G_OBEX_HDR_INVALID);
+
+	transfer->xfer = g_obex_get_req_pkt(obex, req, get_xfer_progress,
 						xfer_complete, transfer,
 						&err);
-	}
 }
 
 static gssize put_xfer_progress(void *buf, gsize len, gpointer user_data)
@@ -689,7 +722,8 @@ static gboolean report_progress(gpointer data)
 		return FALSE;
 	}
 
-	if (transfer->status != TRANSFER_STATUS_ACTIVE)
+	if (transfer->status != TRANSFER_STATUS_ACTIVE &&
+				transfer->status != TRANSFER_STATUS_SUSPENDED)
 		transfer_set_status(transfer, TRANSFER_STATUS_ACTIVE);
 
 	g_dbus_emit_property_changed(transfer->conn, transfer->path,
-- 
1.8.5.3


^ permalink raw reply related

* Re: Help in getting BlueZ version - 5.14 running please
From: tony @ 2014-02-14 13:27 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <CABBYNZKTveir=GZ0VjPt=WmpbDUCk9MzVH+R-5cvd=NGS7TxCQ@mail.gmail.com>

Thank you for the information.  Yes, my kernel is 3.2. I shall try blueZ 
4.101. Hopefully that wont have any dependency on the kernel version?

Thanks,
Tony

On 14/02/14 11:59, Luiz Augusto von Dentz wrote:
>
> On Feb 13, 2014 10:13 PM, "tony" <tony.makkiel@convergeddevices.net
> <mailto:tony.makkiel@convergeddevices.net>> wrote:
>  >
>  > Hi,
>  >         I am trying to familiarize with blueZ commands. I can scan
> devices and see HCI commands and events using hcidump. But am having
> some problems which I have been trying to figure out the past two days.
> Any suggestions or pointers will be much appreciated.
>  >
>  > 1) I found a lot of forums talking about creating connection. But
> couldn't find any which says how to accept connection. I am trying to
> accept an A2DP connection. The peer device is sending an AVDTP Connect
> request but don't know how to make blueZ respond. Can somebody please help?
>  >
>  > 2) I tried to start bluetooth daemon by running
>  >>
>  >> ../src/bluetoothd -n -d
>  >> bluetoothd[4440]: Bluetooth daemon 5.14
>  >> bluetoothd[4440]: Failed to access management interface
>  >> bluetoothd[4440]: Adapter handling initialization failed
>
> Looks like you don't have mgmt interface enabled in your kernel,
> probably because it is too old for using with BlueZ 5 which require at
> least 3.4 but nowadays it is probably recommended to use 3.10 or latter.
>
>  >
>  > The kernel modules I have are
>  >
>  >> lsmod | grep blue
>  >> bluetooth             158447  7 rfcomm,bnep,btusb
>  >
>  >
>  > Should I be running any other command before bluetoothd?
>  >
>  > 3) I am get problem in getting the python scripts in the test folder.
>  > For example when I try to run simple-agent it throws up dbus error as
> below. I tried googling from which I understand some people had the same
> error with 5.13 as well. The dbus version I have is 1.6.4 (I had to
> upgrade from 1.4 to build blueZ)
>  >
>  >
>  >> ./simple-agent hci0 00:1B:DC:07:2E:95
>  >> Traceback (most recent call last):
>  >>   File "./simple-agent", line 158, in <module>
>  >>     obj = bus.get_object(BUS_NAME, "/org/bluez");
>  >>   File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 241, in
> get_object
>  >>     follow_name_owner_changes=follow_name_owner_changes)
>  >>   File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 248,
> in __init__
>  >>     self._named_service = conn.activate_name_owner(bus_name)
>  >>   File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 180, in
> activate_name_owner
>  >>     self.start_service_by_name(bus_name)
>  >>   File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 278, in
> start_service_by_name
>  >>     'su', (bus_name, flags)))
>  >>   File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line
> 651, in call_blocking
>  >>     message, timeout)
>  >> dbus.exceptions.DBusException:
> org.freedesktop.DBus.Error.Spawn.ChildExited: Launch helper exited with
> unknown return code 1
>  >
>  >
>  > Thank you for any suggestions or pointers in advance.
>  >
>  > Tony
>  >
>  >
>  > --
>  > To unsubscribe from this list: send the line "unsubscribe
> linux-bluetooth" in
>  > the body of a message to majordomo@vger.kernel.org
> <mailto:majordomo@vger.kernel.org>
>  > More majordomo info at http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply

* Re: [PATCH] bluetooth: Do not free priv until timer handler hasn't actually stopped using it
From: Kirill Tkhai @ 2014-02-14 12:10 UTC (permalink / raw)
  To: Michael Knudsen
  Cc: linux-bluetooth, Marcel Holtmann, Gustavo Padovan, Johan Hedberg
In-Reply-To: <52FE0582.3010702@samsung.com>

В Птн, 14/02/2014 в 13:01 +0100, Michael Knudsen пишет:
> On 02/14/2014 12:35 PM, Kirill Tkhai wrote:
> > Function del_timer() does not guarantee that timer was really deleted.
> > If the timer handler is beeing executed at the moment, the function
> > just returns. So, it's possible to use already freed memory in the handler:
> 
> This is not enough.  The timer must be deleted in bcsp_close() before
> hu->priv is set to NULL as the timer code dereferences hu->priv.
> 
> There is a similar issue in hci_h5.c where the timer must be stopped
> before purging h5->unack.
> 
> -m.

Good, consider my email as reported-by. Please, fix that if you get on
well with bluetooth stack. I am far from it.

Kirill

^ permalink raw reply

* Re: [PATCH] bluetooth: Do not free priv until timer handler hasn't actually stopped using it
From: Michael Knudsen @ 2014-02-14 12:01 UTC (permalink / raw)
  To: Kirill Tkhai, linux-bluetooth
  Cc: Marcel Holtmann, Gustavo Padovan, Johan Hedberg
In-Reply-To: <1392377748.5384.28.camel@tkhai>

On 02/14/2014 12:35 PM, Kirill Tkhai wrote:
> Function del_timer() does not guarantee that timer was really deleted.
> If the timer handler is beeing executed at the moment, the function
> just returns. So, it's possible to use already freed memory in the handler:

This is not enough.  The timer must be deleted in bcsp_close() before
hu->priv is set to NULL as the timer code dereferences hu->priv.

There is a similar issue in hci_h5.c where the timer must be stopped
before purging h5->unack.

-m.

^ permalink raw reply

* [PATCH] bluetooth: Do not free priv until timer handler hasn't actually stopped using it
From: Kirill Tkhai @ 2014-02-14 11:35 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Marcel Holtmann, Gustavo Padovan, Johan Hedberg

Function del_timer() does not guarantee that timer was really deleted.
If the timer handler is beeing executed at the moment, the function
just returns. So, it's possible to use already freed memory in the handler:

[ref: Documentation/DocBook/kernel-locking.tmpl]

This was found using grep and compile-tested only.

Signed-off-by: Kirill Tkhai <ktkhai@parallels.com>
CC: Marcel Holtmann <marcel@holtmann.org>
CC: Gustavo Padovan <gustavo@padovan.org>
CC: Johan Hedberg <johan.hedberg@gmail.com>
---
 drivers/bluetooth/hci_bcsp.c |    2 +-
 drivers/bluetooth/hci_h5.c   |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c
index 0bc87f7..d796a6d 100644
--- a/drivers/bluetooth/hci_bcsp.c
+++ b/drivers/bluetooth/hci_bcsp.c
@@ -722,7 +722,7 @@ static int bcsp_close(struct hci_uart *hu)
 	skb_queue_purge(&bcsp->unack);
 	skb_queue_purge(&bcsp->rel);
 	skb_queue_purge(&bcsp->unrel);
-	del_timer(&bcsp->tbcsp);
+	del_timer_sync(&bcsp->tbcsp);
 
 	kfree(bcsp);
 	return 0;
diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
index f6f4974..9f007f6 100644
--- a/drivers/bluetooth/hci_h5.c
+++ b/drivers/bluetooth/hci_h5.c
@@ -210,7 +210,7 @@ static int h5_close(struct hci_uart *hu)
 	skb_queue_purge(&h5->rel);
 	skb_queue_purge(&h5->unrel);
 
-	del_timer(&h5->timer);
+	del_timer_sync(&h5->timer);
 
 	kfree(h5);
 

^ permalink raw reply related

* Re: [PATCH] android: Fix memory leak: uuid free
From: Szymon Janc @ 2014-02-14 10:36 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1392214927-2715-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Wednesday 12 of February 2014 16:22:07 Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> Free uuid before exiting.
> ---
>  android/bluetooth.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/android/bluetooth.c b/android/bluetooth.c
> index 5de3401..b818e88 100644
> --- a/android/bluetooth.c
> +++ b/android/bluetooth.c
> @@ -1557,6 +1557,8 @@ int bt_adapter_add_record(sdp_record_t *rec, uint8_t svc_hint)
>  
>  		sdp_uuid2strn(uuid, uuid_str, sizeof(uuid_str));
>  		DBG("UUID %s already added", uuid_str);
> +
> +		bt_free(uuid);
>  		return -EALREADY;
>  	}

Applied, thanks.

-- 
Best regards, 
Szymon Janc

^ permalink raw reply

* Re: [PATCH BlueZ 01/12] android/hal-ipc-api: Add Remote Features notification
From: Szymon Janc @ 2014-02-14 10:34 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1392304728-5061-1-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

On Thursday 13 of February 2014 17:18:37 Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> ---
>  android/hal-ipc-api.txt | 14 ++++++++++++--
>  android/hal-msg.h       |  6 ++++++
>  2 files changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
> index c1609c9..70f947d 100644
> --- a/android/hal-ipc-api.txt
> +++ b/android/hal-ipc-api.txt
> @@ -1300,8 +1300,18 @@ Android HAL name: "avrcp" (BT_PROFILE_AV_RC_ID)
>  		Valid type values : 0x00 = Interim
>  		                    0x01 = Changed
>  
> -	Opcode 0x81 - Get Play Status notification
> -	Opcode 0x82 - List Player Application Attributes notification
> +	Opcode 0x81 - Remote Features notification
> +
> +		Notification parameters: Remote address (6 octets)
> +		                         Features (1 octet)
> +
> +		Valid features values : 0x00 = None
> +		                        0x01 = Metadata
> +		                        0x02 = Absolute Volume
> +		                        0x03 = Browse
> +
> +	Opcode 0x82 - Get Play Status notification
> +	Opcode 0x83 - List Player Application Attributes notification
>  	...
>  
>  
> diff --git a/android/hal-msg.h b/android/hal-msg.h
> index ca1f6b5..f6cdf58 100644
> --- a/android/hal-msg.h
> +++ b/android/hal-msg.h
> @@ -881,3 +881,9 @@ struct hal_cmd_avrcp_register_notification {
>  	uint8_t len;
>  	uint8_t data[0];
>  } __attribute__((packed));
> +
> +#define HAL_EV_AVRCP_REMOTE_FEATURES		0x81
> +struct hal_ev_avrcp_remote_features {
> +	uint8_t bdaddr[6];
> +	uint8_t features;
> +} __attribute__((packed));
> 

All patches applied, thanks.

-- 
Best regards, 
Szymon Janc

^ permalink raw reply

* [PATCH] btusb.c add IMC Networks id 13d3:3404 (bcm20702A0) - retry
From: Jurgen Kramer @ 2014-02-14  9:32 UTC (permalink / raw)
  To: BlueZ development

[-- Attachment #1: Type: text/plain, Size: 919 bytes --]

>From 343f62050b33972929db749aee296e98332600d6 Mon Sep 17 00:00:00 2001
From: Jurgen Kramer <gtmkramer@xs4all.nl>
Date: Fri, 14 Feb 2014 10:22:51 +0100
Subject: [PATCH] btusb.c add IMC Networks id 13d3:3404 (bcm20702A0)

---
 drivers/bluetooth/btusb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 3980fd1..5dce16d 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -106,6 +106,7 @@ static const struct usb_device_id btusb_table[] = {
 	{ USB_DEVICE(0x04ca, 0x2003) },
 	{ USB_DEVICE(0x0489, 0xe042) },
 	{ USB_DEVICE(0x413c, 0x8197) },
+	{ USB_DEVICE(0x13d3, 0x3404) },
 
 	/* Foxconn - Hon Hai */
 	{ USB_VENDOR_AND_INTERFACE_INFO(0x0489, 0xff, 0x01, 0x01) },
-- 
1.8.5.3

Signed-off-by: Jurgen Kramer <gtm.kramer@xs4all.nl>

Retry. I've included the relevant part of the
requested /sys/kernel/debug/usb/devices output.

Jurgen

[-- Attachment #2: sys-kernel-debug-usb-devices-0x13d3-0x3404.txt --]
[-- Type: text/plain, Size: 1651 bytes --]

T:  Bus=01 Lev=02 Prnt=02 Port=04 Cnt=01 Dev#=  3 Spd=12   MxCh= 0
D:  Ver= 2.00 Cls=ff(vend.) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=13d3 ProdID=3404 Rev= 1.12
S:  Manufacturer=Broadcom Corp
S:  Product=BCM20702A0
S:  SerialNumber=240A649F8246
C:* #Ifs= 4 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
I:  If#= 1 Alt= 1 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
I:  If#= 1 Alt= 2 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
I:  If#= 1 Alt= 3 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
I:  If#= 1 Alt= 4 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
I:  If#= 1 Alt= 5 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
E:  Ad=84(I) Atr=02(Bulk) MxPS=  32 Ivl=0ms
E:  Ad=04(O) Atr=02(Bulk) MxPS=  32 Ivl=0ms
I:* If#= 3 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=01 Driver=(none)

^ permalink raw reply related

* Re: [PATCH] android: Fix memory leak: uuid free
From: Andrei Emeltchenko @ 2014-02-14  9:01 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392214927-2715-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

On Wed, Feb 12, 2014 at 04:22:07PM +0200, Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> Free uuid before exiting.

ping

> ---
>  android/bluetooth.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/android/bluetooth.c b/android/bluetooth.c
> index 5de3401..b818e88 100644
> --- a/android/bluetooth.c
> +++ b/android/bluetooth.c
> @@ -1557,6 +1557,8 @@ int bt_adapter_add_record(sdp_record_t *rec, uint8_t svc_hint)
>  
>  		sdp_uuid2strn(uuid, uuid_str, sizeof(uuid_str));
>  		DBG("UUID %s already added", uuid_str);
> +
> +		bt_free(uuid);
>  		return -EALREADY;
>  	}
>  
> -- 
> 1.8.3.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [RFCv3] android/avrcp: Decouple AVRCP logic from btio
From: Andrei Emeltchenko @ 2014-02-14  9:00 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392304807-19488-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

On Thu, Feb 13, 2014 at 05:20:07PM +0200, Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> The patch makes AVRCP to be channel-agnostic so that it might be used in
> unit tests. The idea is that all AVRCP logic would come to avrcp-lib and
> channel stuff got to avrcp.

ping

> ---
>  android/Android.mk  |  1 +
>  android/Makefile.am |  1 +
>  android/avrcp-lib.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  android/avrcp-lib.h | 29 ++++++++++++++++++++
>  android/avrcp.c     | 28 ++++++++++++-------
>  5 files changed, 128 insertions(+), 9 deletions(-)
>  create mode 100644 android/avrcp-lib.c
>  create mode 100644 android/avrcp-lib.h
> 
> diff --git a/android/Android.mk b/android/Android.mk
> index 20602f3..72676e1 100644
> --- a/android/Android.mk
> +++ b/android/Android.mk
> @@ -39,6 +39,7 @@ LOCAL_SRC_FILES := \
>  	bluez/android/avdtp.c \
>  	bluez/android/a2dp.c \
>  	bluez/android/avctp.c \
> +	bluez/android/avrcp-lib.c \
>  	bluez/android/avrcp.c \
>  	bluez/android/pan.c \
>  	bluez/android/handsfree.c \
> diff --git a/android/Makefile.am b/android/Makefile.am
> index 1913b42..07cc851 100644
> --- a/android/Makefile.am
> +++ b/android/Makefile.am
> @@ -36,6 +36,7 @@ android_bluetoothd_SOURCES = android/main.c \
>  				android/avdtp.h android/avdtp.c \
>  				android/a2dp.h android/a2dp.c \
>  				android/avctp.h android/avctp.c \
> +				android/avrcp-lib.h android/avrcp-lib.c \
>  				android/avrcp.h android/avrcp.c \
>  				android/socket.h android/socket.c \
>  				android/pan.h android/pan.c \
> diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
> new file mode 100644
> index 0000000..b2b1b82
> --- /dev/null
> +++ b/android/avrcp-lib.c
> @@ -0,0 +1,78 @@
> +/*
> + *
> + *  BlueZ - Bluetooth protocol stack for Linux
> + *
> + *  Copyright (C) 2014  Intel Corporation. All rights reserved.
> + *
> + *
> + *  This library is free software; you can redistribute it and/or
> + *  modify it under the terms of the GNU Lesser General Public
> + *  License as published by the Free Software Foundation; either
> + *  version 2.1 of the License, or (at your option) any later version.
> + *
> + *  This library is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + *  Lesser General Public License for more details.
> + *
> + *  You should have received a copy of the GNU Lesser General Public
> + *  License along with this library; if not, write to the Free Software
> + *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> + *
> + */
> +
> +#ifdef HAVE_CONFIG_H
> +#include <config.h>
> +#endif
> +
> +#include <stdbool.h>
> +#include <glib.h>
> +
> +#include "lib/bluetooth.h"
> +
> +#include "src/log.h"
> +
> +#include "avctp.h"
> +#include "avrcp-lib.h"
> +
> +struct avrcp {
> +	struct avctp	*session;
> +};
> +
> +void avrcp_free(void *data)
> +{
> +	struct avrcp *session = data;
> +
> +	if (session->session)
> +		avctp_shutdown(session->session);
> +
> +	g_free(session);
> +}
> +
> +struct avrcp *avrcp_new(int fd, size_t imtu, size_t omtu,
> +							uint16_t version)
> +{
> +	struct avrcp *session;
> +
> +	session = g_new0(struct avrcp, 1);
> +
> +	session->session = avctp_new(fd, imtu, omtu, version);
> +	if (!session->session) {
> +		g_free(session);
> +		return NULL;
> +	}
> +
> +	return session;
> +}
> +
> +void avrcp_set_destroy_cb(struct avrcp *session, avctp_destroy_cb_t cb,
> +							void *user_data)
> +{
> +	avctp_set_destroy_cb(session->session, cb, user_data);
> +}
> +
> +int avrcp_init_uinput(struct avrcp *session, const char *name,
> +							const char *address)
> +{
> +	return avctp_init_uinput(session->session, name, address);
> +}
> diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
> new file mode 100644
> index 0000000..8490722
> --- /dev/null
> +++ b/android/avrcp-lib.h
> @@ -0,0 +1,29 @@
> +/*
> + *
> + *  BlueZ - Bluetooth protocol stack for Linux
> + *
> + *  Copyright (C) 2014  Intel Corporation. All rights reserved.
> + *
> + *
> + *  This library is free software; you can redistribute it and/or
> + *  modify it under the terms of the GNU Lesser General Public
> + *  License as published by the Free Software Foundation; either
> + *  version 2.1 of the License, or (at your option) any later version.
> + *
> + *  This library is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + *  Lesser General Public License for more details.
> + *
> + *  You should have received a copy of the GNU Lesser General Public
> + *  License along with this library; if not, write to the Free Software
> + *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> + *
> + */
> +
> +struct avrcp *avrcp_new(int fd, size_t imtu, size_t omtu, uint16_t version);
> +void avrcp_free(void *data);
> +void avrcp_set_destroy_cb(struct avrcp *session, avctp_destroy_cb_t cb,
> +							void *user_data);
> +int avrcp_init_uinput(struct avrcp *session, const char *name,
> +							const char *address);
> diff --git a/android/avrcp.c b/android/avrcp.c
> index b8304f5..a2bb1df 100644
> --- a/android/avrcp.c
> +++ b/android/avrcp.c
> @@ -38,6 +38,7 @@
>  #include "hal-msg.h"
>  #include "ipc.h"
>  #include "avctp.h"
> +#include "avrcp-lib.h"
>  
>  #define L2CAP_PSM_AVCTP 0x17
>  
> @@ -53,7 +54,7 @@ static GIOChannel *server = NULL;
>  
>  struct avrcp_device {
>  	bdaddr_t	dst;
> -	struct avctp	*session;
> +	struct avrcp	*session;
>  	GIOChannel	*io;
>  };
>  
> @@ -133,7 +134,7 @@ static void avrcp_device_free(void *data)
>  	struct avrcp_device *dev = data;
>  
>  	if (dev->session)
> -		avctp_shutdown(dev->session);
> +		avrcp_free(dev->session);
>  
>  	if (dev->io) {
>  		g_io_channel_shutdown(dev->io, FALSE, NULL);
> @@ -168,6 +169,17 @@ static int device_cmp(gconstpointer s, gconstpointer user_data)
>  	return bacmp(&dev->dst, dst);
>  }
>  
> +static struct avrcp_device *avrcp_find(const bdaddr_t *dst)
> +{
> +	GSList *l;
> +
> +	l = g_slist_find_custom(devices, dst, device_cmp);
> +	if (!l)
> +		return NULL;
> +
> +	return l->data;
> +}
> +
>  static void disconnect_cb(void *data)
>  {
>  	struct avrcp_device *dev = data;
> @@ -222,17 +234,17 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
>  	}
>  
>  	fd = g_io_channel_unix_get_fd(chan);
> -	dev->session = avctp_new(fd, imtu, omtu, 0x0100);
>  
> +	dev->session = avrcp_new(fd, imtu, omtu, 0x0100);
>  	if (!dev->session) {
>  		avrcp_device_free(dev);
>  		return;
>  	}
>  
> -	avctp_set_destroy_cb(dev->session, disconnect_cb, dev);
> +	avrcp_set_destroy_cb(dev->session, disconnect_cb, dev);
>  
>  	/* FIXME: get the real name of the device */
> -	avctp_init_uinput(dev->session, "bluetooth", address);
> +	avrcp_init_uinput(dev->session, "bluetooth", address);
>  
>  	g_io_channel_set_close_on_unref(chan, FALSE);
>  
> @@ -331,12 +343,10 @@ void bt_avrcp_connect(const bdaddr_t *dst)
>  {
>  	struct avrcp_device *dev;
>  	char addr[18];
> -	GSList *l;
>  
>  	DBG("");
>  
> -	l = g_slist_find_custom(devices, dst, device_cmp);
> -	if (l)
> +	if (avrcp_find(dst))
>  		return;
>  
>  	dev = avrcp_device_new(dst);
> @@ -363,7 +373,7 @@ void bt_avrcp_disconnect(const bdaddr_t *dst)
>  	dev = l->data;
>  
>  	if (dev->session) {
> -		avctp_shutdown(dev->session);
> +		avrcp_free(dev->session);
>  		return;
>  	}
>  
> -- 
> 1.8.3.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox