Linux bluetooth development
 help / color / mirror / Atom feed
* Re: [PATCH_v2 1/2] android/hidhost: Fix miscalculation of get report event notification length
From: Szymon Janc @ 2014-01-21 15:20 UTC (permalink / raw)
  To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1390307059-7772-1-git-send-email-ravikumar.veeramally@linux.intel.com>

Hi Ravi,

On Tuesday 21 of January 2014 14:24:18 Ravi kumar Veeramally wrote:
> Event length is size of struct + data len (if any). It is miscalulated.
> ---
>  android/hidhost.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/android/hidhost.c b/android/hidhost.c
> index 3da77c8..108493a 100644
> --- a/android/hidhost.c
> +++ b/android/hidhost.c
> @@ -371,7 +371,7 @@ static void bt_hid_notify_get_report(struct hid_device *dev, uint8_t *buf,
>  	ba2str(&dev->dst, address);
>  	DBG("device %s", address);
>  
> -	ev_len = sizeof(*ev) + sizeof(struct hal_ev_hidhost_get_report) + 1;
> +	ev_len = sizeof(*ev);
>  
>  	if (!((buf[0] == (HID_MSG_DATA | HID_DATA_TYPE_INPUT)) ||
>  			(buf[0] == (HID_MSG_DATA | HID_DATA_TYPE_OUTPUT)) ||
> 

Both patches applied, thanks.

-- 
Best regards, 
Szymon Janc

^ permalink raw reply

* Re: [PATCH BlueZ 1/2] android/A2DP: Add retry logic to Audio IPC
From: Szymon Janc @ 2014-01-21 15:24 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1390312859-27349-1-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

On Tuesday 21 of January 2014 16:00:58 Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> In case the audio HAL disconnects without cleaning up its endpoints treat
> it as unclean disconnection and attempt to reconnect.
> ---
>  android/a2dp.c      | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++---
>  android/audio-ipc.c | 13 +++++++---
>  android/audio-ipc.h |  2 +-
>  android/ipc.c       |  9 +++----
>  android/ipc.h       |  3 ++-
>  5 files changed, 83 insertions(+), 12 deletions(-)

Both patches applied, thanks.

-- 
Best regards, 
Szymon Janc

^ permalink raw reply

* Re: [PATCH 0/1] HIDP: Add a special case for the Dualshock 4
From: Frank Praznik @ 2014-01-21 16:01 UTC (permalink / raw)
  To: David Herrmann, Simon Wood; +Cc: Frank Praznik, linux-bluetooth@vger.kernel.org
In-Reply-To: <CANq1E4Ruo6C9gFbv=ZdtmVmvYC61UFW1AR+C_LVUEA3xj9iO9A@mail.gmail.com>

On 1/21/2014 03:26, David Herrmann wrote:
> Hi
>
> On Tue, Jan 21, 2014 at 3:00 AM,  <simon@mungewell.org> wrote:
>>> This adds a special case in the HIDP core for the Dualshock 4
>> controller.
>>> The controller only recognizes output reports with the report type 0x52
>> and only accepts reports sent via the ctrl channel.
>>
>> Which part of the system is 'at fault' here, is it simply the DS4 behaving
>> incorrectly or that Bluez is not picking up some data or that 'we' are
>> just the incorrect method to send the data (in the hid-sony kernel
>> driver)?
> No-one is at fault. Well, strictly speaking the DS4 is, as it has to
> accept SET_REPORT and asynchronous OUTPUT_REPORTs, but it doesn't.
> That's quite common. What we actually want is HIDP to provide to
> functions, one to call SET_REPORT and one to do the async
> OUTPUT_REPORT is currently does.
>
> I implemented this some time ago here:
>    http://cgit.freedesktop.org/~dvdhrm/linux/log/?h=hid
>
> Maybe it's time to get that merged. But that hack here is ugly and not
> the way to go.
>
> Thanks
> David
Believe me, I know that my hack is ugly :).  The raw_request 
functionality in your repo is exactly what is needed in this scenario.  
I have the Bluetooth work on the Sony driver module done, so now it's 
just a matter of waiting on if or when this gets merged.

^ permalink raw reply

* Re: [PATCH 0/1] HIDP: Add a special case for the Dualshock 4
From: David Herrmann @ 2014-01-21 16:34 UTC (permalink / raw)
  To: Frank Praznik; +Cc: Simon Wood, Frank Praznik, linux-bluetooth@vger.kernel.org
In-Reply-To: <52DE99CA.8030305@gmail.com>

Hi

On Tue, Jan 21, 2014 at 5:01 PM, Frank Praznik <frank.praznik@gmail.com> wrote:
> On 1/21/2014 03:26, David Herrmann wrote:
>>
>> Hi
>>
>> On Tue, Jan 21, 2014 at 3:00 AM,  <simon@mungewell.org> wrote:
>>>>
>>>> This adds a special case in the HIDP core for the Dualshock 4
>>>
>>> controller.
>>>>
>>>> The controller only recognizes output reports with the report type 0x52
>>>
>>> and only accepts reports sent via the ctrl channel.
>>>
>>> Which part of the system is 'at fault' here, is it simply the DS4
>>> behaving
>>> incorrectly or that Bluez is not picking up some data or that 'we' are
>>> just the incorrect method to send the data (in the hid-sony kernel
>>> driver)?
>>
>> No-one is at fault. Well, strictly speaking the DS4 is, as it has to
>> accept SET_REPORT and asynchronous OUTPUT_REPORTs, but it doesn't.
>> That's quite common. What we actually want is HIDP to provide to
>> functions, one to call SET_REPORT and one to do the async
>> OUTPUT_REPORT is currently does.
>>
>> I implemented this some time ago here:
>>    http://cgit.freedesktop.org/~dvdhrm/linux/log/?h=hid
>>
>> Maybe it's time to get that merged. But that hack here is ugly and not
>> the way to go.
>>
>> Thanks
>> David
>
> Believe me, I know that my hack is ugly :).  The raw_request functionality
> in your repo is exactly what is needed in this scenario.  I have the
> Bluetooth work on the Sony driver module done, so now it's just a matter of
> waiting on if or when this gets merged.

My backlog is continuously growing.. it's not the only patch-series I
have pending for too long, I'm sincerely sorry. I'm working hard on
getting all that stuff out, but note that I will not be able to get
this ready before FOSDEM (in 2 weeks). So if you want to pick this up
before 3rd of February, I would be more than glad about it. I will
review any changes. Otherwise, you'd have to wait for at least 2 more
weeks before I can send it out.

Also feel free to extract any small part of the series if you don't
feel confident about the other stuff. So you can just move the
raw_request()/raw_report() into a separate patch. We *definitely* need
this callback, so I'd be fine if we add it early.

Cheers
David

^ permalink raw reply

* Re: [PATCH BlueZ v2 01/18] doc: Add GATT API
From: Marcel Holtmann @ 2014-01-21 16:50 UTC (permalink / raw)
  To: Claudio Takahasi; +Cc: linux-bluetooth@vger.kernel.org development
In-Reply-To: <1390310814-19880-2-git-send-email-claudio.takahasi@openbossa.org>

Hi Claudio,

> This patch proposes an unified GATT API for local and remote services.
> ---
> doc/gatt-api.txt | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 145 insertions(+)
> create mode 100644 doc/gatt-api.txt
> 
> diff --git a/doc/gatt-api.txt b/doc/gatt-api.txt
> new file mode 100644
> index 0000000..df60fb8
> --- /dev/null
> +++ b/doc/gatt-api.txt
> @@ -0,0 +1,145 @@
> +BlueZ D-Bus GATT API description
> +********************************
> +
> +GATT local and remote services share the same high-level D-Bus API. Local
> +refers to GATT based service exported by a BlueZ plugin or an external
> +application. Remote refers to GATT services exported by the peer.
> +
> +BlueZ acts as a proxy, translating ATT operations to D-Bus method calls and
> +Properties (or the opposite). Support for D-Bus Object Manager is mandatory for
> +external services to allow seamless GATT declarations (Service, Characteristic
> +and Descriptors) discovery.
> +
> +Service hierarchy
> +=================
> +
> +GATT remote and local service representation. Object path for local services
> +is freely definable.
> +
> +External applications implementing local services must register the services
> +using GattServiceManager1 registration method and must implement the methods
> +and properties defined in GattService1 interface.
> +
> +Service		org.bluez
> +Interface	org.bluez.GattService1 [Experimental]
> +Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/serviceXX
> +
> +Methods		void Release()
> +
> +			Release this service. At this point, it will not be
> +			used by BlueZ anymore and can be destroyed by the
> +			owner. Method applicable to external GATT services
> +			implementations only (GATT servers).
> +
> +Properties	string UUID [read-only]
> +
> +			128-bit service UUID.
> +
> +		array{object} Includes [read-only]: Not implemented
> +
> +			Array of object paths representing the included
> +			services of this service.
> +
> +
> +Characteristic hierarchy
> +========================
> +
> +For local GATT defined services, the object paths need to follow the service
> +path hierarchy and are freely definable.
> +
> +Service		org.bluez
> +Interface	org.bluez.Characteristic1 [Experimental]
> +Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/serviceXX/charYYYY

this is an all or nothing deal. So better GattCharacteristic1.

> +
> +Properties	string UUID [read-only]
> +
> +			128-bit characteristic UUID.
> +
> +		object Service [read-only]
> +
> +			Object path of the GATT service the characteristc
> +			belongs to.
> +
> +		array{byte} Value [read-write]
> +
> +			Value read from the remote Bluetooth device or from
> +			the external application implementing GATT services.
> +
> +		array{string} Flags [read-only, optional]
> +
> +			Defines how the characteristic value can be used. See
> +			Core spec page 1898, "Table 3.5: Characteristic
> +			Properties bit field" and page 1900, "Table 3.8:
> +			Characteristic Extended Properties bit field". Allowed
> +			values: "broadcast", "read", "write-without-response",
> +			"write", "notify", "indicate",
> +			"authenticated-signed-writes", "reliable-write", and
> +			"writable-auxiliaries".
> +
> +
> +Characteristic Descriptors hierarchy
> +====================================
> +
> +Local or remote GATT characteristic descriptors hierarchy.
> +
> +Service		org.bluez
> +Interface	org.bluez.Descriptor1 [Experimental]
> +Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/serviceXX/charYYYY/descriptorZZZ

Same here. GattDescriptor1.

> +
> +Properties	string UUID [read-only]
> +
> +			128-bit descriptor UUID.
> +
> +		object Characteristic [read-only]
> +
> +			Object path of the GATT characteristc the descriptor
> +			belongs to.
> +
> +		array{byte} Value [read-write]
> +
> +			Raw characteristic descriptor value read from the
> +			remote Bluetooth device or from the external
> +			application implementing GATT services.
> +
> +		string Permissions [read-only]: To be defined
> +
> +			Defines read/write authentication and authorization
> +			requirements.
> +
> +Service Manager hierarchy
> +=============================
> +
> +Service Manager allows external applications to register GATT based
> +services. Services must follow the API for Service and Characteristic
> +described above.
> +
> +Local GATT services, characteristics and characteristic descriptors are
> +discovered automatically using the D-Bus Object Manager interface.
> +
> +Service		org.bluez
> +Interface	org.bluez.GattServiceManager1 [Experimental]
> +Object path	/org/bluez

Here we could discuss to use GattManager1 to make it shorter, but I am not sure if that actually helps. I currently tend to leave it as GattServiceManager1.

> +
> +Methods		RegisterService(object service, dict options)
> +
> +			Registers remote application service exported under
> +			interface GattService1. Characteristic objects must
> +			be hierarchical to their service and must use the
> +			interface Characteristic1. D-Bus Object Manager is
> +			used to fetch the exported objects.
> +
> +			"service" object path together with the D-Bus system
> +			bus connection ID define the identification of the
> +			application registering a GATT based service.
> +
> +			Possible errors: org.bluez.Error.InvalidArguments
> +					 org.bluez.Error.AlreadyExists
> +
> +		UnregisterService(object service)
> +
> +			This unregisters the service that has been
> +			previously registered. The object path parameter
> +			must match the same value that has been used
> +			on registration.
> +
> +			Possible errors: org.bluez.Error.DoesNotExist

Regards

Marcel


^ permalink raw reply

* Re: [PATCH 2/5] android/bluetooth: Use defines for settings and devices files paths
From: Marcel Holtmann @ 2014-01-21 16:54 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth@vger.kernel.org development, Szymon Janc
In-Reply-To: <1390316497-18451-3-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

> ---
> android/bluetooth.c | 24 +++++++++++-------------
> 1 file changed, 11 insertions(+), 13 deletions(-)
> 
> diff --git a/android/bluetooth.c b/android/bluetooth.c
> index 8f08122..3314267 100644
> --- a/android/bluetooth.c
> +++ b/android/bluetooth.c
> @@ -54,6 +54,9 @@
> 
> #define DUT_MODE_FILE "/sys/kernel/debug/bluetooth/hci%u/dut_mode"
> 
> +#define SETTINGS_FILE ANDROID_STORAGEDIR"/settings"
> +#define DEVICES_FILE ANDROID_STORAGEDIR"/devices”

is there any good reason to keep cached devices together with the bonded devices? I get the feeling a cached device should be safe to throw away. So deleting the cache file should not cause any problems. Meaning it should be a separate file.

Regards

Marcel


^ permalink raw reply

* Re: [PATCH 2/5] android/bluetooth: Use defines for settings and devices files paths
From: Szymon Janc @ 2014-01-21 17:41 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: Szymon Janc, linux-bluetooth@vger.kernel.org development
In-Reply-To: <2F525C49-B02B-4A87-8CAE-633BF53A8ADF@holtmann.org>

Hi Marcel,

On Tuesday 21 January 2014 08:54:35 Marcel Holtmann wrote:
> Hi Szymon,
>=20
> > ---
> > android/bluetooth.c | 24 +++++++++++-------------
> > 1 file changed, 11 insertions(+), 13 deletions(-)
> >=20
> > diff --git a/android/bluetooth.c b/android/bluetooth.c
> > index 8f08122..3314267 100644
> > --- a/android/bluetooth.c
> > +++ b/android/bluetooth.c
> > @@ -54,6 +54,9 @@
> >=20
> > #define DUT_MODE_FILE "/sys/kernel/debug/bluetooth/hci%u/dut_mode"
> >=20
> > +#define SETTINGS_FILE ANDROID_STORAGEDIR"/settings"
> > +#define DEVICES_FILE ANDROID_STORAGEDIR"/devices=E2=80=9D
>=20
> is there any good reason to keep cached devices together with the bon=
ded
> devices? I get the feeling a cached device should be safe to throw aw=
ay. So
> deleting the cache file should not cause any problems. Meaning it sho=
uld be
> a separate file.

I'm fine with having separate files too (even have this implemented on =
my=20
local branch), but wanted to avoid handling multiple files. Anyway, add=
/remove=20
bond doesn't happen that often so maybe this is not a problem.

So, is "device_cache" name OK? Or just "cache"?

--=20
Szymon K. Janc
szymon.janc@gmail.com

^ permalink raw reply

* Re: [PATCH 2/5] android/bluetooth: Use defines for settings and devices files paths
From: Marcel Holtmann @ 2014-01-21 19:13 UTC (permalink / raw)
  To: Szymon Janc; +Cc: Szymon Janc, linux-bluetooth@vger.kernel.org development
In-Reply-To: <1699475.kPZvhNixD9@athlon>

Hi Szymon,

>>> ---
>>> android/bluetooth.c | 24 +++++++++++-------------
>>> 1 file changed, 11 insertions(+), 13 deletions(-)
>>> 
>>> diff --git a/android/bluetooth.c b/android/bluetooth.c
>>> index 8f08122..3314267 100644
>>> --- a/android/bluetooth.c
>>> +++ b/android/bluetooth.c
>>> @@ -54,6 +54,9 @@
>>> 
>>> #define DUT_MODE_FILE "/sys/kernel/debug/bluetooth/hci%u/dut_mode"
>>> 
>>> +#define SETTINGS_FILE ANDROID_STORAGEDIR"/settings"
>>> +#define DEVICES_FILE ANDROID_STORAGEDIR"/devices”
>> 
>> is there any good reason to keep cached devices together with the bonded
>> devices? I get the feeling a cached device should be safe to throw away. So
>> deleting the cache file should not cause any problems. Meaning it should be
>> a separate file.
> 
> I'm fine with having separate files too (even have this implemented on my 
> local branch), but wanted to avoid handling multiple files. Anyway, add/remove 
> bond doesn't happen that often so maybe this is not a problem.
> 
> So, is "device_cache" name OK? Or just "cache”?

I would just do “cache” and see where it takes us.

Regards

Marcel


^ permalink raw reply

* Re: [PATCH BlueZ v2 01/18] doc: Add GATT API
From: Claudio Takahasi @ 2014-01-21 19:40 UTC (permalink / raw)
  To: Marcel Holtmann, Johan Hedberg
  Cc: linux-bluetooth@vger.kernel.org development
In-Reply-To: <B5AE7C1F-664D-4859-9793-E853DFF02FC5@holtmann.org>

Hi Marcel/Johan:

On Tue, Jan 21, 2014 at 1:50 PM, Marcel Holtmann <marcel@holtmann.org> wrote:
> Hi Claudio,
>
>> This patch proposes an unified GATT API for local and remote services.
>> ---
>> doc/gatt-api.txt | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 145 insertions(+)
>> create mode 100644 doc/gatt-api.txt
>>
>> diff --git a/doc/gatt-api.txt b/doc/gatt-api.txt
>> new file mode 100644
>> index 0000000..df60fb8
>> --- /dev/null
>> +++ b/doc/gatt-api.txt
>> @@ -0,0 +1,145 @@
>> +BlueZ D-Bus GATT API description
>> +********************************
>> +
>> +GATT local and remote services share the same high-level D-Bus API. Local
>> +refers to GATT based service exported by a BlueZ plugin or an external
>> +application. Remote refers to GATT services exported by the peer.
>> +
>> +BlueZ acts as a proxy, translating ATT operations to D-Bus method calls and
>> +Properties (or the opposite). Support for D-Bus Object Manager is mandatory for
>> +external services to allow seamless GATT declarations (Service, Characteristic
>> +and Descriptors) discovery.
>> +
>> +Service hierarchy
>> +=================
>> +
>> +GATT remote and local service representation. Object path for local services
>> +is freely definable.
>> +
>> +External applications implementing local services must register the services
>> +using GattServiceManager1 registration method and must implement the methods
>> +and properties defined in GattService1 interface.
>> +
>> +Service              org.bluez
>> +Interface    org.bluez.GattService1 [Experimental]
>> +Object path  [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/serviceXX
>> +
>> +Methods              void Release()
>> +
>> +                     Release this service. At this point, it will not be
>> +                     used by BlueZ anymore and can be destroyed by the
>> +                     owner. Method applicable to external GATT services
>> +                     implementations only (GATT servers).
>> +
>> +Properties   string UUID [read-only]
>> +
>> +                     128-bit service UUID.
>> +
>> +             array{object} Includes [read-only]: Not implemented
>> +
>> +                     Array of object paths representing the included
>> +                     services of this service.
>> +
>> +
>> +Characteristic hierarchy
>> +========================
>> +
>> +For local GATT defined services, the object paths need to follow the service
>> +path hierarchy and are freely definable.
>> +
>> +Service              org.bluez
>> +Interface    org.bluez.Characteristic1 [Experimental]
>> +Object path  [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/serviceXX/charYYYY
>
> this is an all or nothing deal. So better GattCharacteristic1.

OK. It will be changed in the next patchset.

>
>> +
>> +Properties   string UUID [read-only]
>> +
>> +                     128-bit characteristic UUID.
>> +
>> +             object Service [read-only]
>> +
>> +                     Object path of the GATT service the characteristc
>> +                     belongs to.
>> +
>> +             array{byte} Value [read-write]
>> +
>> +                     Value read from the remote Bluetooth device or from
>> +                     the external application implementing GATT services.
>> +
>> +             array{string} Flags [read-only, optional]
>> +
>> +                     Defines how the characteristic value can be used. See
>> +                     Core spec page 1898, "Table 3.5: Characteristic
>> +                     Properties bit field" and page 1900, "Table 3.8:
>> +                     Characteristic Extended Properties bit field". Allowed
>> +                     values: "broadcast", "read", "write-without-response",
>> +                     "write", "notify", "indicate",
>> +                     "authenticated-signed-writes", "reliable-write", and
>> +                     "writable-auxiliaries".
>> +
>> +
>> +Characteristic Descriptors hierarchy
>> +====================================
>> +
>> +Local or remote GATT characteristic descriptors hierarchy.
>> +
>> +Service              org.bluez
>> +Interface    org.bluez.Descriptor1 [Experimental]
>> +Object path  [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/serviceXX/charYYYY/descriptorZZZ
>
> Same here. GattDescriptor1.

OK. It will be changed in the next patchset.

>
>> +
>> +Properties   string UUID [read-only]
>> +
>> +                     128-bit descriptor UUID.
>> +
>> +             object Characteristic [read-only]
>> +
>> +                     Object path of the GATT characteristc the descriptor
>> +                     belongs to.
>> +
>> +             array{byte} Value [read-write]
>> +
>> +                     Raw characteristic descriptor value read from the
>> +                     remote Bluetooth device or from the external
>> +                     application implementing GATT services.
>> +
>> +             string Permissions [read-only]: To be defined
>> +
>> +                     Defines read/write authentication and authorization
>> +                     requirements.
>> +
>> +Service Manager hierarchy
>> +=============================
>> +
>> +Service Manager allows external applications to register GATT based
>> +services. Services must follow the API for Service and Characteristic
>> +described above.
>> +
>> +Local GATT services, characteristics and characteristic descriptors are
>> +discovered automatically using the D-Bus Object Manager interface.
>> +
>> +Service              org.bluez
>> +Interface    org.bluez.GattServiceManager1 [Experimental]
>> +Object path  /org/bluez
>
> Here we could discuss to use GattManager1 to make it shorter, but I am not sure if that actually helps. I currently tend to leave it as GattServiceManager1.

I prefer GattManager1. I have two reasons:
* "Service" is included in the methods names: RegisterService and
UnregisterService
* GattManager1 name is more generic and we can use it for other GATT
methods not directly related to "Service". At the moment, I don't have
examples, but I was thinking on potential methods related to GATT
Client.

Marcel/Johan: Please define which name will be used.

>
>> +
>> +Methods              RegisterService(object service, dict options)
>> +
>> +                     Registers remote application service exported under
>> +                     interface GattService1. Characteristic objects must
>> +                     be hierarchical to their service and must use the
>> +                     interface Characteristic1. D-Bus Object Manager is
>> +                     used to fetch the exported objects.
>> +
>> +                     "service" object path together with the D-Bus system
>> +                     bus connection ID define the identification of the
>> +                     application registering a GATT based service.
>> +
>> +                     Possible errors: org.bluez.Error.InvalidArguments
>> +                                      org.bluez.Error.AlreadyExists
>> +
>> +             UnregisterService(object service)
>> +
>> +                     This unregisters the service that has been
>> +                     previously registered. The object path parameter
>> +                     must match the same value that has been used
>> +                     on registration.
>> +
>> +                     Possible errors: org.bluez.Error.DoesNotExist
>
> Regards
>
> Marcel

Regards,
Claudio

^ permalink raw reply

* [PATCH v2 1/2] android: Add btmgmt to debug builds
From: Andrzej Kaczmarek @ 2014-01-21 19:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek

---
 android/Android.mk | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/android/Android.mk b/android/Android.mk
index e66d70a..e3a31c1 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -296,3 +296,33 @@ LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
 
 include $(BUILD_PREBUILT)
+
+#
+# btmgmt
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	../tools/btmgmt.c \
+	../lib/bluetooth.c \
+	../lib/sdp.c \
+	../monitor/mainloop.c \
+	../src/shared/io-mainloop.c \
+	../src/shared/mgmt.c \
+	../src/shared/queue.c \
+	../src/shared/util.c \
+	../src/uuid-helper.c \
+
+LOCAL_C_INCLUDES := \
+	$(LOCAL_PATH)/.. \
+	$(LOCAL_PATH)/../src \
+	$(LOCAL_PATH)/../lib \
+
+LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE := btmgmt
+
+include $(BUILD_EXECUTABLE)
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH v2 2/2] android: Add l2ping to debug builds
From: Andrzej Kaczmarek @ 2014-01-21 19:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1390333570-13196-1-git-send-email-andrzej.kaczmarek@tieto.com>

---
 android/Android.mk | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/android/Android.mk b/android/Android.mk
index e3a31c1..3b8d471 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -326,3 +326,25 @@ LOCAL_MODULE_TAGS := debug
 LOCAL_MODULE := btmgmt
 
 include $(BUILD_EXECUTABLE)
+
+#
+# l2ping
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	../tools/l2ping.c \
+	../lib/bluetooth.c \
+	../lib/hci.c \
+
+LOCAL_C_INCLUDES := \
+	$(LOCAL_PATH)/../lib \
+
+LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE := l2ping
+
+include $(BUILD_EXECUTABLE)
-- 
1.8.5.2


^ permalink raw reply related

* Re: [PATCH BlueZ v2 01/18] doc: Add GATT API
From: Johan Hedberg @ 2014-01-21 19:48 UTC (permalink / raw)
  To: Claudio Takahasi
  Cc: Marcel Holtmann, linux-bluetooth@vger.kernel.org development
In-Reply-To: <CAKT1EBc-VL5M0c1yt8LpGvaTyyE7P=9w5jGOZs7wUpRpsS7A8Q@mail.gmail.com>

Hi Claudio,

On Tue, Jan 21, 2014, Claudio Takahasi wrote:
> >> +Interface    org.bluez.GattServiceManager1 [Experimental]
> >> +Object path  /org/bluez
> >
> > Here we could discuss to use GattManager1 to make it shorter, but I
> > am not sure if that actually helps. I currently tend to leave it as
> > GattServiceManager1.
> 
> I prefer GattManager1. I have two reasons:
> * "Service" is included in the methods names: RegisterService and
> UnregisterService
> * GattManager1 name is more generic and we can use it for other GATT
> methods not directly related to "Service". At the moment, I don't have
> examples, but I was thinking on potential methods related to GATT
> Client.
> 
> Marcel/Johan: Please define which name will be used.

I'm voting for GattManager1, but Marcel has veto rights :)

Johan

^ permalink raw reply

* Re: [PATCH BlueZ v2 01/18] doc: Add GATT API
From: Marcel Holtmann @ 2014-01-21 19:51 UTC (permalink / raw)
  To: Johan Hedberg
  Cc: Claudio Takahasi, linux-bluetooth@vger.kernel.org development
In-Reply-To: <20140121194842.GA3342@x220.p-661hnu-f1>

Hi Johan,

>>>> +Interface    org.bluez.GattServiceManager1 [Experimental]
>>>> +Object path  /org/bluez
>>> 
>>> Here we could discuss to use GattManager1 to make it shorter, but I
>>> am not sure if that actually helps. I currently tend to leave it as
>>> GattServiceManager1.
>> 
>> I prefer GattManager1. I have two reasons:
>> * "Service" is included in the methods names: RegisterService and
>> UnregisterService
>> * GattManager1 name is more generic and we can use it for other GATT
>> methods not directly related to "Service". At the moment, I don't have
>> examples, but I was thinking on potential methods related to GATT
>> Client.
>> 
>> Marcel/Johan: Please define which name will be used.
> 
> I'm voting for GattManager1, but Marcel has veto rights :)

lets go with GattManager1 and see where it takes us.

Regards

Marcel


^ permalink raw reply

* [PATCH 60/73] drivers/bluetooth: delete non-required instances of include <linux/init.h>
From: Paul Gortmaker @ 2014-01-21 21:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, Paul Gortmaker, Marcel Holtmann, Gustavo Padovan,
	Johan Hedberg, linux-bluetooth
In-Reply-To: <1390339396-3479-1-git-send-email-paul.gortmaker@windriver.com>

None of these files are actually using any __init type directives
and hence don't need to include <linux/init.h>.  Most are just a
left over from __devinit and __cpuinit removal, or simply due to
code getting copied from one driver to the next.

Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 drivers/bluetooth/ath3k.c       | 1 -
 drivers/bluetooth/bcm203x.c     | 1 -
 drivers/bluetooth/bfusb.c       | 1 -
 drivers/bluetooth/bluecard_cs.c | 1 -
 drivers/bluetooth/bpa10x.c      | 1 -
 drivers/bluetooth/bt3c_cs.c     | 1 -
 drivers/bluetooth/btuart_cs.c   | 1 -
 drivers/bluetooth/dtl1_cs.c     | 1 -
 8 files changed, 8 deletions(-)

diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index 41ec6f9..427f280 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -20,7 +20,6 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/errno.h>
diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c
index 364f82b..40db9a9 100644
--- a/drivers/bluetooth/bcm203x.c
+++ b/drivers/bluetooth/bcm203x.c
@@ -26,7 +26,6 @@
 
 #include <linux/atomic.h>
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/errno.h>
diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c
index 3138699..48b71f0 100644
--- a/drivers/bluetooth/bfusb.c
+++ b/drivers/bluetooth/bfusb.c
@@ -24,7 +24,6 @@
 #include <linux/module.h>
 
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/errno.h>
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index 57427de..0aae563 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -23,7 +23,6 @@
 #include <linux/module.h>
 
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/sched.h>
diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c
index 8a31991..40281c0 100644
--- a/drivers/bluetooth/bpa10x.c
+++ b/drivers/bluetooth/bpa10x.c
@@ -23,7 +23,6 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/sched.h>
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 73d8799..f3508fe 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -24,7 +24,6 @@
 #include <linux/module.h>
 
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/delay.h>
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c
index a03ecc2..057104e 100644
--- a/drivers/bluetooth/btuart_cs.c
+++ b/drivers/bluetooth/btuart_cs.c
@@ -23,7 +23,6 @@
 #include <linux/module.h>
 
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/delay.h>
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index 52eed1f..5bb80e4 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -23,7 +23,6 @@
 #include <linux/module.h>
 
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/delay.h>
-- 
1.8.4.1

^ permalink raw reply related

* Re: [PATCH 60/73] drivers/bluetooth: delete non-required instances of include <linux/init.h>
From: Marcel Holtmann @ 2014-01-21 21:55 UTC (permalink / raw)
  To: Paul Gortmaker
  Cc: linux-kernel, linux-arch, Gustavo F. Padovan, Johan Hedberg,
	linux-bluetooth@vger.kernel.org development
In-Reply-To: <1390339396-3479-61-git-send-email-paul.gortmaker@windriver.com>

Hi Paul,

> None of these files are actually using any __init type directives
> and hence don't need to include <linux/init.h>.  Most are just a
> left over from __devinit and __cpuinit removal, or simply due to
> code getting copied from one driver to the next.
> 
> Cc: Marcel Holtmann <marcel@holtmann.org>
> Cc: Gustavo Padovan <gustavo@padovan.org>
> Cc: Johan Hedberg <johan.hedberg@gmail.com>
> Cc: linux-bluetooth@vger.kernel.org
> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
> ---
> drivers/bluetooth/ath3k.c       | 1 -
> drivers/bluetooth/bcm203x.c     | 1 -
> drivers/bluetooth/bfusb.c       | 1 -
> drivers/bluetooth/bluecard_cs.c | 1 -
> drivers/bluetooth/bpa10x.c      | 1 -
> drivers/bluetooth/bt3c_cs.c     | 1 -
> drivers/bluetooth/btuart_cs.c   | 1 -
> drivers/bluetooth/dtl1_cs.c     | 1 -
> 8 files changed, 8 deletions(-)

I can take this single patch via bluetooth-next tree or if Linus for example wants to take the whole series, then that is fine with me as well.

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel


^ permalink raw reply

* Re: [PATCH 60/73] drivers/bluetooth: delete non-required instances of include <linux/init.h>
From: Paul Gortmaker @ 2014-01-21 22:30 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: linux-kernel, linux-arch, Gustavo F. Padovan, Johan Hedberg,
	linux-bluetooth@vger.kernel.org development
In-Reply-To: <8861C0F9-FF68-47B8-B9EB-E52BF6A72A6F@holtmann.org>

On 14-01-21 04:55 PM, Marcel Holtmann wrote:
> Hi Paul,
> 
>> None of these files are actually using any __init type directives
>> and hence don't need to include <linux/init.h>.  Most are just a
>> left over from __devinit and __cpuinit removal, or simply due to
>> code getting copied from one driver to the next.
>>
>> Cc: Marcel Holtmann <marcel@holtmann.org>
>> Cc: Gustavo Padovan <gustavo@padovan.org>
>> Cc: Johan Hedberg <johan.hedberg@gmail.com>
>> Cc: linux-bluetooth@vger.kernel.org
>> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
>> ---
>> drivers/bluetooth/ath3k.c       | 1 -
>> drivers/bluetooth/bcm203x.c     | 1 -
>> drivers/bluetooth/bfusb.c       | 1 -
>> drivers/bluetooth/bluecard_cs.c | 1 -
>> drivers/bluetooth/bpa10x.c      | 1 -
>> drivers/bluetooth/bt3c_cs.c     | 1 -
>> drivers/bluetooth/btuart_cs.c   | 1 -
>> drivers/bluetooth/dtl1_cs.c     | 1 -
>> 8 files changed, 8 deletions(-)
> 
> I can take this single patch via bluetooth-next tree or if Linus for example wants to take the whole series, then that is fine with me as well.
> 
> Acked-by: Marcel Holtmann <marcel@holtmann.org>

Given that the merge window is open, and maintainers are likely to
have finalized their content, I might as well just keep it in this
series.  I've added your ack though -- thanks.

Paul.
--

> 
> Regards
> 
> Marcel
> 

^ permalink raw reply

* [PATCH] android: Refactor paths in Android.mk
From: Andrzej Kaczmarek @ 2014-01-21 23:45 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek

Using source paths relative to android/ directory created mess in
Android's obj directory since object files are created also relative
to bluetoothd_intermediates (thus can be created outside it).

To avoid this we set LOCAL_PATH to absolute path (in terms of Android
build root) of directory in which bluez/ is located and change and
update source paths accordingly.

This also allows us to build in future glib and sbc easily using
Android.mk in BlueZ.
---
 android/Android.mk | 224 ++++++++++++++++++++++++++---------------------------
 1 file changed, 112 insertions(+), 112 deletions(-)

diff --git a/android/Android.mk b/android/Android.mk
index 3b8d471..43e6036 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -1,7 +1,7 @@
-LOCAL_PATH := $(call my-dir)
+LOCAL_PATH := external/bluetooth
 
 # Retrieve BlueZ version from configure.ac file
-BLUEZ_VERSION := $(shell grep ^AC_INIT $(LOCAL_PATH)/../configure.ac | cpp -P -D'AC_INIT(_,v)=v')
+BLUEZ_VERSION := $(shell grep ^AC_INIT $(LOCAL_PATH)/bluez/configure.ac | cpp -P -D'AC_INIT(_,v)=v')
 
 # Specify pathmap for glib
 pathmap_INCL += glib:external/bluetooth/glib
@@ -20,41 +20,41 @@ BLUEZ_COMMON_CFLAGS += -Wno-pointer-arith -Wno-missing-field-initializers
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	main.c \
-	bluetooth.c \
-	hidhost.c \
-	socket.c \
-	ipc.c \
-	audio-ipc.c \
-	avdtp.c \
-	a2dp.c \
-	pan.c \
-	../src/log.c \
-	../src/shared/mgmt.c \
-	../src/shared/util.c \
-	../src/shared/queue.c \
-	../src/shared/io-glib.c \
-	../src/sdpd-database.c \
-	../src/sdpd-service.c \
-	../src/sdpd-request.c \
-	../src/sdpd-server.c \
-	../src/uuid-helper.c \
-	../src/eir.c \
-	../lib/sdp.c \
-	../lib/bluetooth.c \
-	../lib/hci.c \
-	../btio/btio.c \
-	../src/sdp-client.c \
-	../profiles/network/bnep.c \
+	bluez/android/main.c \
+	bluez/android/bluetooth.c \
+	bluez/android/hidhost.c \
+	bluez/android/socket.c \
+	bluez/android/ipc.c \
+	bluez/android/audio-ipc.c \
+	bluez/android/avdtp.c \
+	bluez/android/a2dp.c \
+	bluez/android/pan.c \
+	bluez/src/log.c \
+	bluez/src/shared/mgmt.c \
+	bluez/src/shared/util.c \
+	bluez/src/shared/queue.c \
+	bluez/src/shared/io-glib.c \
+	bluez/src/sdpd-database.c \
+	bluez/src/sdpd-service.c \
+	bluez/src/sdpd-request.c \
+	bluez/src/sdpd-server.c \
+	bluez/src/uuid-helper.c \
+	bluez/src/eir.c \
+	bluez/lib/sdp.c \
+	bluez/lib/bluetooth.c \
+	bluez/lib/hci.c \
+	bluez/btio/btio.c \
+	bluez/src/sdp-client.c \
+	bluez/profiles/network/bnep.c \
 
 LOCAL_C_INCLUDES := \
 	$(call include-path-for, glib) \
 	$(call include-path-for, glib)/glib \
 
 LOCAL_C_INCLUDES += \
-	$(LOCAL_PATH)/../ \
-	$(LOCAL_PATH)/../src \
-	$(LOCAL_PATH)/../lib \
+	$(LOCAL_PATH)/bluez \
+	$(LOCAL_PATH)/bluez/src \
+	$(LOCAL_PATH)/bluez/lib \
 
 LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
 
@@ -72,9 +72,9 @@ lib_headers := \
 	sco.h \
 	bnep.h \
 
-$(shell mkdir -p $(LOCAL_PATH)/../lib/bluetooth)
+$(shell mkdir -p $(LOCAL_PATH)/bluez/lib/bluetooth)
 
-$(foreach file,$(lib_headers), $(shell ln -sf ../$(file) $(LOCAL_PATH)/../lib/bluetooth/$(file)))
+$(foreach file,$(lib_headers), $(shell ln -sf ../$(file) $(LOCAL_PATH)/bluez/lib/bluetooth/$(file)))
 
 LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE := bluetoothd
@@ -88,13 +88,13 @@ include $(BUILD_EXECUTABLE)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	hal-ipc.c \
-	hal-bluetooth.c \
-	hal-sock.c \
-	hal-hidhost.c \
-	hal-pan.c \
-	hal-a2dp.c \
-	hal-utils.c \
+	bluez/android/hal-ipc.c \
+	bluez/android/hal-bluetooth.c \
+	bluez/android/hal-sock.c \
+	bluez/android/hal-hidhost.c \
+	bluez/android/hal-pan.c \
+	bluez/android/hal-a2dp.c \
+	bluez/android/hal-utils.c \
 
 LOCAL_C_INCLUDES += \
 	$(call include-path-for, system-core) \
@@ -120,20 +120,20 @@ include $(BUILD_SHARED_LIBRARY)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	client/haltest.c \
-	client/pollhandler.c \
-	client/terminal.c \
-	client/history.c \
-	client/tabcompletion.c \
-	client/if-audio.c \
-	client/if-av.c \
-	client/if-bt.c \
-	client/if-hf.c \
-	client/if-hh.c \
-	client/if-pan.c \
-	client/if-sock.c \
-	client/if-gatt.c \
-	hal-utils.c \
+	bluez/android/client/haltest.c \
+	bluez/android/client/pollhandler.c \
+	bluez/android/client/terminal.c \
+	bluez/android/client/history.c \
+	bluez/android/client/tabcompletion.c \
+	bluez/android/client/if-audio.c \
+	bluez/android/client/if-av.c \
+	bluez/android/client/if-bt.c \
+	bluez/android/client/if-hf.c \
+	bluez/android/client/if-hh.c \
+	bluez/android/client/if-pan.c \
+	bluez/android/client/if-sock.c \
+	bluez/android/client/if-gatt.c \
+	bluez/android/hal-utils.c \
 
 LOCAL_C_INCLUDES += \
 	$(call include-path-for, system-core) \
@@ -156,32 +156,32 @@ include $(BUILD_EXECUTABLE)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	../monitor/main.c \
-	../monitor/mainloop.c \
-	../monitor/display.c \
-	../monitor/hcidump.c \
-	../monitor/btsnoop.c \
-	../monitor/control.c \
-	../monitor/packet.c \
-	../monitor/l2cap.c \
-	../monitor/uuid.c \
-	../monitor/sdp.c \
-	../monitor/vendor.c \
-	../monitor/lmp.c \
-	../monitor/crc.c \
-	../monitor/ll.c \
-	../monitor/hwdb.c \
-	../monitor/ellisys.c \
-	../monitor/analyze.c \
-	../src/shared/util.c \
-	../src/shared/queue.c \
-	../lib/hci.c \
-	../lib/bluetooth.c \
+	bluez/monitor/main.c \
+	bluez/monitor/mainloop.c \
+	bluez/monitor/display.c \
+	bluez/monitor/hcidump.c \
+	bluez/monitor/btsnoop.c \
+	bluez/monitor/control.c \
+	bluez/monitor/packet.c \
+	bluez/monitor/l2cap.c \
+	bluez/monitor/uuid.c \
+	bluez/monitor/sdp.c \
+	bluez/monitor/vendor.c \
+	bluez/monitor/lmp.c \
+	bluez/monitor/crc.c \
+	bluez/monitor/ll.c \
+	bluez/monitor/hwdb.c \
+	bluez/monitor/ellisys.c \
+	bluez/monitor/analyze.c \
+	bluez/src/shared/util.c \
+	bluez/src/shared/queue.c \
+	bluez/lib/hci.c \
+	bluez/lib/bluetooth.c \
 
 LOCAL_C_INCLUDES := \
-	$(LOCAL_PATH)/.. \
-	$(LOCAL_PATH)/../lib \
-	$(LOCAL_PATH)/../src/shared \
+	$(LOCAL_PATH)/bluez \
+	$(LOCAL_PATH)/bluez/lib \
+	$(LOCAL_PATH)/bluez/src/shared \
 
 LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
 
@@ -198,13 +198,13 @@ include $(BUILD_EXECUTABLE)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	../tools/btproxy.c \
-	../monitor/mainloop.c \
-	../src/shared/util.c \
+	bluez/tools/btproxy.c \
+	bluez/monitor/mainloop.c \
+	bluez/src/shared/util.c \
 
 LOCAL_C_INCLUDES := \
-	$(LOCAL_PATH)/.. \
-	$(LOCAL_PATH)/../src/shared \
+	$(LOCAL_PATH)/bluez \
+	$(LOCAL_PATH)/bluez/src/shared \
 
 LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
 
@@ -220,7 +220,7 @@ include $(BUILD_EXECUTABLE)
 
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES := hal-audio.c
+LOCAL_SRC_FILES := bluez/android/hal-audio.c
 
 LOCAL_C_INCLUDES = \
 	$(call include-path-for, system-core) \
@@ -244,14 +244,14 @@ include $(BUILD_SHARED_LIBRARY)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	../tools/l2test.c \
-	../lib/bluetooth.c \
-	../lib/hci.c \
+	bluez/tools/l2test.c \
+	bluez/lib/bluetooth.c \
+	bluez/lib/hci.c \
 
 LOCAL_C_INCLUDES := \
-	$(LOCAL_PATH)/.. \
-	$(LOCAL_PATH)/../lib \
-	$(LOCAL_PATH)/../src/shared \
+	$(LOCAL_PATH)/bluez \
+	$(LOCAL_PATH)/bluez/lib \
+	$(LOCAL_PATH)/bluez/src/shared \
 
 LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
 
@@ -268,13 +268,13 @@ include $(BUILD_EXECUTABLE)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	bluetoothd-snoop.c \
-	../monitor/mainloop.c \
-	../src/shared/btsnoop.c \
+	bluez/android/bluetoothd-snoop.c \
+	bluez/monitor/mainloop.c \
+	bluez/src/shared/btsnoop.c \
 
 LOCAL_C_INCLUDES := \
-	$(LOCAL_PATH)/.. \
-	$(LOCAL_PATH)/../lib \
+	$(LOCAL_PATH)/bluez \
+	$(LOCAL_PATH)/bluez/lib \
 
 LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
 
@@ -291,7 +291,7 @@ include $(CLEAR_VARS)
 
 LOCAL_MODULE := init.bluetooth.rc
 LOCAL_MODULE_CLASS := ETC
-LOCAL_SRC_FILES := $(LOCAL_MODULE)
+LOCAL_SRC_FILES := bluez/android/$(LOCAL_MODULE)
 LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
 
@@ -304,20 +304,20 @@ include $(BUILD_PREBUILT)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	../tools/btmgmt.c \
-	../lib/bluetooth.c \
-	../lib/sdp.c \
-	../monitor/mainloop.c \
-	../src/shared/io-mainloop.c \
-	../src/shared/mgmt.c \
-	../src/shared/queue.c \
-	../src/shared/util.c \
-	../src/uuid-helper.c \
+	bluez/tools/btmgmt.c \
+	bluez/lib/bluetooth.c \
+	bluez/lib/sdp.c \
+	bluez/monitor/mainloop.c \
+	bluez/src/shared/io-mainloop.c \
+	bluez/src/shared/mgmt.c \
+	bluez/src/shared/queue.c \
+	bluez/src/shared/util.c \
+	bluez/src/uuid-helper.c \
 
 LOCAL_C_INCLUDES := \
-	$(LOCAL_PATH)/.. \
-	$(LOCAL_PATH)/../src \
-	$(LOCAL_PATH)/../lib \
+	$(LOCAL_PATH)/bluez \
+	$(LOCAL_PATH)/bluez/src \
+	$(LOCAL_PATH)/bluez/lib \
 
 LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
 
@@ -334,12 +334,12 @@ include $(BUILD_EXECUTABLE)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	../tools/l2ping.c \
-	../lib/bluetooth.c \
-	../lib/hci.c \
+	bluez/tools/l2ping.c \
+	bluez/lib/bluetooth.c \
+	bluez/lib/hci.c \
 
 LOCAL_C_INCLUDES := \
-	$(LOCAL_PATH)/../lib \
+	$(LOCAL_PATH)/bluez/lib \
 
 LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
 
-- 
1.8.5.2


^ permalink raw reply related

* Re: [PATCH v2 1/2] android: Add btmgmt to debug builds
From: Szymon Janc @ 2014-01-22  0:03 UTC (permalink / raw)
  To: Andrzej Kaczmarek; +Cc: linux-bluetooth
In-Reply-To: <1390333570-13196-1-git-send-email-andrzej.kaczmarek@tieto.com>

Hi Andrzej,

On Tuesday 21 January 2014 20:46:09 Andrzej Kaczmarek wrote:
> ---
>  android/Android.mk | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/android/Android.mk b/android/Android.mk
> index e66d70a..e3a31c1 100644
> --- a/android/Android.mk
> +++ b/android/Android.mk
> @@ -296,3 +296,33 @@ LOCAL_MODULE_TAGS := optional
>  LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
> 
>  include $(BUILD_PREBUILT)
> +
> +#
> +# btmgmt
> +#
> +
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> +	../tools/btmgmt.c \
> +	../lib/bluetooth.c \
> +	../lib/sdp.c \
> +	../monitor/mainloop.c \
> +	../src/shared/io-mainloop.c \
> +	../src/shared/mgmt.c \
> +	../src/shared/queue.c \
> +	../src/shared/util.c \
> +	../src/uuid-helper.c \
> +
> +LOCAL_C_INCLUDES := \
> +	$(LOCAL_PATH)/.. \
> +	$(LOCAL_PATH)/../src \
> +	$(LOCAL_PATH)/../lib \
> +
> +LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
> +
> +LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
> +LOCAL_MODULE_TAGS := debug
> +LOCAL_MODULE := btmgmt
> +
> +include $(BUILD_EXECUTABLE)

Both patches applied, thanks.

-- 
Szymon K. Janc
szymon.janc@gmail.com

^ permalink raw reply

* [PATCH v2 0/4] Remote device cache support
From: Szymon Janc @ 2014-01-22  0:30 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

V2:
 - keep cache in separate file
 - patch 3/5 and 4/5 from V1 squashed to 3/4

V1:
 - set cache limit to 300
 - update timestamp of cached device
 - rebased to master
 - other minor fixes

Szymon Janc (4):
  android/bluetooth: Split devices list to devices and bonded_devices
  android/bluetooth: Use defines for settings and devices files paths
  android/bluetooth: Add support for caching remote device info
  android/bluetooth: Add support for loading caches devices from storage

 android/bluetooth.c | 223 ++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 166 insertions(+), 57 deletions(-)

-- 
1.8.5.3


^ permalink raw reply

* [PATCH v2 1/4] android/bluetooth: Split devices list to devices and bonded_devices
From: Szymon Janc @ 2014-01-22  0:30 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1390350645-9725-1-git-send-email-szymon.janc@gmail.com>

Bonded devices are permament until unbondedn. Non-bonded devices will
be held in (size limited) cache based on timestamp property so split
list to ease separation.
---
 android/bluetooth.c | 48 ++++++++++++++++++++++++++++++++++++------------
 1 file changed, 36 insertions(+), 12 deletions(-)

diff --git a/android/bluetooth.c b/android/bluetooth.c
index 4849dab..5d222e1 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -132,6 +132,8 @@ static const uint16_t uuid_list[] = {
 
 static uint16_t option_index = MGMT_INDEX_NONE;
 static struct mgmt *mgmt_if = NULL;
+
+static GSList *bonded_devices = NULL;
 static GSList *devices = NULL;
 
 /* This list contains addresses which are asked for records */
@@ -283,6 +285,10 @@ static struct device *find_device(const bdaddr_t *bdaddr)
 {
 	GSList *l;
 
+	l = g_slist_find_custom(bonded_devices, bdaddr, device_match);
+	if (l)
+		return l->data;
+
 	l = g_slist_find_custom(devices, bdaddr, device_match);
 	if (l)
 		return l->data;
@@ -559,12 +565,30 @@ static void set_device_bond_state(const bdaddr_t *addr, uint8_t status,
 	if (!dev)
 		return;
 
-	if (dev->bond_state != state) {
-		dev->bond_state = state;
-		send_bond_state_change(&dev->bdaddr, status, state);
+	if (dev->bond_state == state)
+		return;
 
-		store_device_info(dev);
+	switch (state) {
+	case HAL_BOND_STATE_NONE:
+		if (dev->bond_state == HAL_BOND_STATE_BONDED) {
+			bonded_devices = g_slist_remove(bonded_devices, dev);
+			devices = g_slist_prepend(devices, dev);
+		}
+		break;
+	case HAL_BOND_STATE_BONDED:
+		devices = g_slist_remove(devices, dev);
+		bonded_devices = g_slist_prepend(bonded_devices, dev);
+		break;
+	case HAL_BOND_STATE_BONDING:
+	default:
+		break;
 	}
+
+	dev->bond_state = state;
+
+	store_device_info(dev);
+
+	send_bond_state_change(&dev->bdaddr, status, state);
 }
 
 static  void send_device_property(const bdaddr_t *bdaddr, uint8_t type,
@@ -935,6 +959,7 @@ static void mgmt_discovering_event(uint16_t index, uint16_t length,
 	if (adapter.discovering) {
 		cp.state = HAL_DISCOVERY_STATE_STARTED;
 	} else {
+		g_slist_foreach(bonded_devices, clear_device_found, NULL);
 		g_slist_foreach(devices, clear_device_found, NULL);
 		cp.state = HAL_DISCOVERY_STATE_STOPPED;
 	}
@@ -2128,18 +2153,15 @@ static uint8_t get_adapter_scan_mode(void)
 
 static uint8_t get_adapter_bonded_devices(void)
 {
-	uint8_t buf[sizeof(bdaddr_t) * g_slist_length(devices)];
+	uint8_t buf[sizeof(bdaddr_t) * g_slist_length(bonded_devices)];
 	int i = 0;
 	GSList *l;
 
 	DBG("");
 
-	for (l = devices; l; l = g_slist_next(l)) {
+	for (l = bonded_devices; l; l = g_slist_next(l)) {
 		struct device *dev = l->data;
 
-		if (dev->bond_state != HAL_BOND_STATE_BONDED)
-			continue;
-
 		bdaddr2android(&dev->bdaddr, buf + (i * sizeof(bdaddr_t)));
 		i++;
 	}
@@ -2691,11 +2713,10 @@ static void send_bonded_devices_props(void)
 {
 	GSList *l;
 
-	for (l = devices; l; l = g_slist_next(l)) {
+	for (l = bonded_devices; l; l = g_slist_next(l)) {
 		struct device *dev = l->data;
 
-		if (dev->bond_state == HAL_BOND_STATE_BONDED)
-			get_remote_device_props(dev);
+		get_remote_device_props(dev);
 	}
 }
 
@@ -3093,6 +3114,9 @@ void bt_bluetooth_unregister(void)
 {
 	DBG("");
 
+	g_slist_free_full(bonded_devices, (GDestroyNotify) free_device);
+	bonded_devices = NULL;
+
 	g_slist_free_full(devices, (GDestroyNotify) free_device);
 	devices = NULL;
 
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH v2 2/4] android/bluetooth: Use defines for settings and devices files paths
From: Szymon Janc @ 2014-01-22  0:30 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1390350645-9725-1-git-send-email-szymon.janc@gmail.com>

---
 android/bluetooth.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/android/bluetooth.c b/android/bluetooth.c
index 5d222e1..f5ac0e4 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -54,6 +54,9 @@
 
 #define DUT_MODE_FILE "/sys/kernel/debug/bluetooth/hci%u/dut_mode"
 
+#define SETTINGS_FILE ANDROID_STORAGEDIR"/settings"
+#define DEVICES_FILE ANDROID_STORAGEDIR"/devices"
+
 #define DEVICE_ID_SOURCE	0x0002	/* USB */
 #define DEVICE_ID_VENDOR	0x1d6b	/* Linux Foundation */
 #define DEVICE_ID_PRODUCT	0x0247	/* BlueZ for Android */
@@ -148,8 +151,7 @@ static void store_adapter_config(void)
 
 	key_file = g_key_file_new();
 
-	g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/settings", 0,
-									NULL);
+	g_key_file_load_from_file(key_file, SETTINGS_FILE, 0, NULL);
 
 	ba2str(&adapter.bdaddr, addr);
 
@@ -160,7 +162,7 @@ static void store_adapter_config(void)
 
 	data = g_key_file_to_data(key_file, &length, NULL);
 
-	g_file_set_contents(ANDROID_STORAGEDIR"/settings", data, length, NULL);
+	g_file_set_contents(SETTINGS_FILE, data, length, NULL);
 
 	g_free(data);
 	g_key_file_free(key_file);
@@ -173,8 +175,7 @@ static void load_adapter_config(void)
 	char *str;
 
 	key_file = g_key_file_new();
-	g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/settings", 0,
-									NULL);
+	g_key_file_load_from_file(key_file, SETTINGS_FILE, 0, NULL);
 
 	str = g_key_file_get_string(key_file, "General", "Address", NULL);
 	if (!str) {
@@ -216,8 +217,7 @@ static void store_device_info(struct device *dev)
 	ba2str(&dev->bdaddr, addr);
 
 	key_file = g_key_file_new();
-	g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/devices", 0,
-									NULL);
+	g_key_file_load_from_file(key_file, DEVICES_FILE, 0, NULL);
 
 	if (dev->bond_state == HAL_BOND_STATE_NONE) {
 		g_key_file_remove_group(key_file, addr, NULL);
@@ -266,7 +266,7 @@ static void store_device_info(struct device *dev)
 
 done:
 	str = g_key_file_to_data(key_file, &length, NULL);
-	g_file_set_contents(ANDROID_STORAGEDIR"/devices", str, length, NULL);
+	g_file_set_contents(DEVICES_FILE, str, length, NULL);
 	g_free(str);
 
 	g_key_file_free(key_file);
@@ -521,8 +521,7 @@ static void store_link_key(const bdaddr_t *dst, const uint8_t *key,
 
 	key_file = g_key_file_new();
 
-	if (!g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/devices",
-								0, NULL))
+	if (!g_key_file_load_from_file(key_file, DEVICES_FILE, 0, NULL))
 		return;
 
 	ba2str(dst, addr);
@@ -537,7 +536,7 @@ static void store_link_key(const bdaddr_t *dst, const uint8_t *key,
 	g_key_file_set_integer(key_file, addr, "LinkKeyPinLength", pin_length);
 
 	data = g_key_file_to_data(key_file, &length, NULL);
-	g_file_set_contents(ANDROID_STORAGEDIR"/devices", data, length, NULL);
+	g_file_set_contents(DEVICES_FILE, data, length, NULL);
 	g_free(data);
 
 	g_key_file_free(key_file);
@@ -1727,8 +1726,7 @@ static void load_devices_info(bt_bluetooth_ready cb)
 
 	key_file = g_key_file_new();
 
-	g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/devices", 0,
-									NULL);
+	g_key_file_load_from_file(key_file, DEVICES_FILE, 0, NULL);
 
 	devs = g_key_file_get_groups(key_file, &len);
 
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH v2 3/4] android/bluetooth: Add support for caching remote device info
From: Szymon Janc @ 2014-01-22  0:30 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1390350645-9725-1-git-send-email-szymon.janc@gmail.com>

From: Szymon Janc <szymon.janc@tieto.com>

Cache is limited to DEVICES_CACHE_MAX. Devices are sorted with
timestamp so if cache is full olderst device is removed.
---
 android/bluetooth.c | 102 +++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 70 insertions(+), 32 deletions(-)

diff --git a/android/bluetooth.c b/android/bluetooth.c
index f5ac0e4..1785fc7 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -56,6 +56,7 @@
 
 #define SETTINGS_FILE ANDROID_STORAGEDIR"/settings"
 #define DEVICES_FILE ANDROID_STORAGEDIR"/devices"
+#define CACHE_FILE ANDROID_STORAGEDIR"/cache"
 
 #define DEVICE_ID_SOURCE	0x0002	/* USB */
 #define DEVICE_ID_VENDOR	0x1d6b	/* Linux Foundation */
@@ -70,6 +71,8 @@
 /* Default discoverable timeout 120sec as in Android */
 #define DEFAULT_DISCOVERABLE_TIMEOUT 120
 
+#define DEVICES_CACHE_MAX 300
+
 #define BASELEN_PROP_CHANGED (sizeof(struct hal_ev_adapter_props_changed) \
 					+ (sizeof(struct hal_property)))
 
@@ -199,7 +202,7 @@ static void load_adapter_config(void)
 	g_key_file_free(key_file);
 }
 
-static void store_device_info(struct device *dev)
+static void store_device_info(struct device *dev, const char *path)
 {
 	GKeyFile *key_file;
 	char addr[18];
@@ -207,22 +210,10 @@ static void store_device_info(struct device *dev)
 	char **uuids = NULL;
 	char *str;
 
-	/* We only store bonded devices and need to modify the storage
-	 * if the state is either NONE or BONDED.
-	 */
-	if (dev->bond_state != HAL_BOND_STATE_BONDED &&
-					dev->bond_state != HAL_BOND_STATE_NONE)
-		return;
-
 	ba2str(&dev->bdaddr, addr);
 
 	key_file = g_key_file_new();
-	g_key_file_load_from_file(key_file, DEVICES_FILE, 0, NULL);
-
-	if (dev->bond_state == HAL_BOND_STATE_NONE) {
-		g_key_file_remove_group(key_file, addr, NULL);
-		goto done;
-	}
+	g_key_file_load_from_file(key_file, path, 0, NULL);
 
 	g_key_file_set_integer(key_file, addr, "Type", dev->bdaddr_type);
 
@@ -264,15 +255,35 @@ static void store_device_info(struct device *dev)
 		g_key_file_remove_key(key_file, addr, "Services", NULL);
 	}
 
-done:
 	str = g_key_file_to_data(key_file, &length, NULL);
-	g_file_set_contents(DEVICES_FILE, str, length, NULL);
+	g_file_set_contents(path, str, length, NULL);
 	g_free(str);
 
 	g_key_file_free(key_file);
 	g_strfreev(uuids);
 }
 
+static void remove_device_info(struct device *dev, const char *path)
+{
+	GKeyFile *key_file;
+	gsize length = 0;
+	char addr[18];
+	char *str;
+
+	ba2str(&dev->bdaddr, addr);
+
+	key_file = g_key_file_new();
+	g_key_file_load_from_file(key_file, path, 0, NULL);
+
+	g_key_file_remove_group(key_file, addr, NULL);
+
+	str = g_key_file_to_data(key_file, &length, NULL);
+	g_file_set_contents(path, str, length, NULL);
+	g_free(str);
+
+	g_key_file_free(key_file);
+}
+
 static int device_match(gconstpointer a, gconstpointer b)
 {
 	const struct device *dev = a;
@@ -296,6 +307,35 @@ static struct device *find_device(const bdaddr_t *bdaddr)
 	return NULL;
 }
 
+static void free_device(struct device *dev)
+{
+	g_free(dev->name);
+	g_free(dev->friendly_name);
+	g_slist_free_full(dev->uuids, g_free);
+	g_free(dev);
+}
+
+static void cache_device(struct device *new_dev)
+{
+	struct device *dev;
+	GSList *l;
+
+	if (g_slist_length(devices) < DEVICES_CACHE_MAX)
+		goto done;
+
+	l = g_slist_last(devices);
+	dev = l->data;
+
+	devices = g_slist_remove(devices, dev);
+	remove_device_info(dev, CACHE_FILE);
+	free_device(dev);
+
+done:
+	new_dev->timestamp = time(NULL);
+	devices = g_slist_prepend(devices, new_dev);
+	store_device_info(new_dev, CACHE_FILE);
+}
+
 static struct device *create_device(const bdaddr_t *bdaddr, uint8_t type)
 {
 	struct device *dev;
@@ -314,19 +354,10 @@ static struct device *create_device(const bdaddr_t *bdaddr, uint8_t type)
 	/* use address for name, will be change if one is present
 	 * eg. in EIR or set by set_property. */
 	dev->name = g_strdup(addr);
-	devices = g_slist_prepend(devices, dev);
 
 	return dev;
 }
 
-static void free_device(struct device *dev)
-{
-	g_free(dev->name);
-	g_free(dev->friendly_name);
-	g_slist_free_full(dev->uuids, g_free);
-	g_free(dev);
-}
-
 static struct device *get_device(const bdaddr_t *bdaddr, uint8_t type)
 {
 	struct device *dev;
@@ -571,12 +602,15 @@ static void set_device_bond_state(const bdaddr_t *addr, uint8_t status,
 	case HAL_BOND_STATE_NONE:
 		if (dev->bond_state == HAL_BOND_STATE_BONDED) {
 			bonded_devices = g_slist_remove(bonded_devices, dev);
-			devices = g_slist_prepend(devices, dev);
+			remove_device_info(dev, DEVICES_FILE);
+			cache_device(dev);
 		}
 		break;
 	case HAL_BOND_STATE_BONDED:
 		devices = g_slist_remove(devices, dev);
 		bonded_devices = g_slist_prepend(bonded_devices, dev);
+		remove_device_info(dev, CACHE_FILE);
+		store_device_info(dev, DEVICES_FILE);
 		break;
 	case HAL_BOND_STATE_BONDING:
 	default:
@@ -585,8 +619,6 @@ static void set_device_bond_state(const bdaddr_t *addr, uint8_t status,
 
 	dev->bond_state = state;
 
-	store_device_info(dev);
-
 	send_bond_state_change(&dev->bdaddr, status, state);
 }
 
@@ -627,7 +659,10 @@ static void set_device_uuids(struct device *dev, GSList *uuids)
 	g_slist_free_full(dev->uuids, g_free);
 	dev->uuids = uuids;
 
-	store_device_info(dev);
+	if (dev->bond_state == HAL_BOND_STATE_BONDED)
+		store_device_info(dev, DEVICES_FILE);
+	else
+		store_device_info(dev, CACHE_FILE);
 
 	send_device_uuids_notif(dev);
 }
@@ -1058,8 +1093,6 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
 
 		ev->status = HAL_STATUS_SUCCESS;
 		bdaddr2android(bdaddr, ev->bdaddr);
-
-		dev->timestamp = time(NULL);
 	}
 
 	if (eir.class) {
@@ -1087,6 +1120,8 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
 		(*num_prop)++;
 	}
 
+	cache_device(dev);
+
 	if (*num_prop)
 		ipc_send_notif(HAL_SERVICE_ID_BLUETOOTH, opcode, size, buf);
 
@@ -2860,7 +2895,10 @@ static uint8_t set_device_friendly_name(struct device *dev, const uint8_t *val,
 	g_free(dev->friendly_name);
 	dev->friendly_name = g_strndup((const char *) val, len);
 
-	store_device_info(dev);
+	if (dev->bond_state == HAL_BOND_STATE_BONDED)
+		store_device_info(dev, DEVICES_FILE);
+	else
+		store_device_info(dev, CACHE_FILE);
 
 	send_device_property(&dev->bdaddr, HAL_PROP_DEVICE_FRIENDLY_NAME,
 				strlen(dev->friendly_name), dev->friendly_name);
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH v2 4/4] android/bluetooth: Add support for loading caches devices from storage
From: Szymon Janc @ 2014-01-22  0:30 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1390350645-9725-1-git-send-email-szymon.janc@gmail.com>

From: Szymon Janc <szymon.janc@tieto.com>

Info is now stored for all devices and bond state depends on file.
Based on that devices loaded from storage are put either to cache
or to bonded_devices list.
---
 android/bluetooth.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 54 insertions(+), 5 deletions(-)

diff --git a/android/bluetooth.c b/android/bluetooth.c
index 1785fc7..80690ec 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -1668,7 +1668,8 @@ static void clear_uuids(void)
 					sizeof(cp), &cp, NULL, NULL, NULL);
 }
 
-static void create_device_from_info(GKeyFile *key_file, const char *peer)
+static struct device *create_device_from_info(GKeyFile *key_file,
+							const char *peer)
 {
 	struct device *dev;
 	uint8_t type;
@@ -1683,7 +1684,11 @@ static void create_device_from_info(GKeyFile *key_file, const char *peer)
 	str2ba(peer, &bdaddr);
 	dev = create_device(&bdaddr, type);
 
-	dev->bond_state = HAL_BOND_STATE_BONDED;
+	str = g_key_file_get_string(key_file, peer, "LinkKey", NULL);
+	if (str) {
+		g_free(str);
+		dev->bond_state = HAL_BOND_STATE_BONDED;
+	}
 
 	str = g_key_file_get_string(key_file, peer, "Name", NULL);
 	if (str) {
@@ -1719,6 +1724,8 @@ static void create_device_from_info(GKeyFile *key_file, const char *peer)
 
 		g_strfreev(uuids);
 	}
+
+	return dev;
 }
 
 static struct mgmt_link_key_info *get_key_info(GKeyFile *key_file, const char *peer)
@@ -1751,6 +1758,40 @@ failed:
 	return info;
 }
 
+static int device_timestamp_cmp(gconstpointer  a, gconstpointer  b)
+{
+	const struct device *deva = a;
+	const struct device *devb = b;
+
+	return deva->timestamp < devb->timestamp;
+}
+
+static void load_devices_cache(void)
+{
+	GKeyFile *key_file;
+	gchar **devs;
+	gsize len = 0;
+	unsigned int i;
+
+	key_file = g_key_file_new();
+
+	g_key_file_load_from_file(key_file, CACHE_FILE, 0, NULL);
+
+	devs = g_key_file_get_groups(key_file, &len);
+
+	for (i = 0; i < len; i++) {
+		struct device *dev;
+
+		dev = create_device_from_info(key_file, devs[i]);
+		devices = g_slist_prepend(devices, dev);
+	}
+
+	devices = g_slist_sort(devices, device_timestamp_cmp);
+
+	g_strfreev(devs);
+	g_key_file_free(key_file);
+}
+
 static void load_devices_info(bt_bluetooth_ready cb)
 {
 	GKeyFile *key_file;
@@ -1767,14 +1808,21 @@ static void load_devices_info(bt_bluetooth_ready cb)
 
 	for (i = 0; i < len; i++) {
 		struct mgmt_link_key_info *key_info;
+		struct device *dev;
 
-		create_device_from_info(key_file, devs[i]);
+		dev = create_device_from_info(key_file, devs[i]);
 
 		key_info = get_key_info(key_file, devs[i]);
-		if (key_info)
-			keys = g_slist_prepend(keys, key_info);
+		if (!key_info) {
+			error("Failed to load linkkey for %s, skipping",
+								devs[i]);
+			continue;
+		}
 
 		/* TODO ltk */
+
+		keys = g_slist_prepend(keys, key_info);
+		bonded_devices = g_slist_prepend(bonded_devices, dev);
 	}
 
 	load_link_keys(keys, cb);
@@ -1862,6 +1910,7 @@ static void read_info_complete(uint8_t status, uint16_t length,
 	clear_uuids();
 
 	load_devices_info(cb);
+	load_devices_cache();
 
 	set_io_capability();
 	set_device_id();
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH 1/9] android/ipc-tester: Add cases for SOCK msg size
From: Jakub Tyszkowski @ 2014-01-22  8:25 UTC (permalink / raw)
  To: linux-bluetooth

Add cases testing message size verification for SOCK opcodes.
---
 android/ipc-tester.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index ed0dd10..088c324 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -864,5 +864,23 @@ int main(int argc, char *argv[])
 			sizeof(struct hal_cmd_le_test_mode), -1,
 			HAL_SERVICE_ID_BLUETOOTH);
 
+	/* check for valid data size for SOCK */
+	test_datasize_valid("SOCK Listen+", HAL_SERVICE_ID_SOCK,
+			HAL_OP_SOCK_LISTEN,
+			sizeof(struct hal_cmd_sock_listen), 1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_SOCK);
+	test_datasize_valid("SOCK Listen-", HAL_SERVICE_ID_SOCK,
+			HAL_OP_SOCK_LISTEN,
+			sizeof(struct hal_cmd_sock_listen), -1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_SOCK);
+	test_datasize_valid("SOCK Connect+", HAL_SERVICE_ID_SOCK,
+			HAL_OP_SOCK_CONNECT,
+			sizeof(struct hal_cmd_sock_connect), 1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_SOCK);
+	test_datasize_valid("SOCK Connect-", HAL_SERVICE_ID_SOCK,
+			HAL_OP_SOCK_CONNECT,
+			sizeof(struct hal_cmd_sock_connect), -1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_SOCK);
+
 	return tester_run();
 }
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 2/9] android/ipc-tester: Add cases for HIDHOST msg size
From: Jakub Tyszkowski @ 2014-01-22  8:25 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1390379124-16426-1-git-send-email-jakub.tyszkowski@tieto.com>

Add cases testing message size verification for HIDHOST opcodes.
---
 android/ipc-tester.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)

diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index 088c324..2871587 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -882,5 +882,79 @@ int main(int argc, char *argv[])
 			sizeof(struct hal_cmd_sock_connect), -1,
 			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_SOCK);
 
+	/* check for valid data size for HID Host */
+	test_datasize_valid("HIDHOST Connect+", HAL_SERVICE_ID_HIDHOST,
+			HAL_OP_HIDHOST_CONNECT,
+			sizeof(struct hal_cmd_hidhost_connect), 1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+	test_datasize_valid("HIDHOST Connect-", HAL_SERVICE_ID_HIDHOST,
+			HAL_OP_HIDHOST_CONNECT,
+			sizeof(struct hal_cmd_hidhost_connect), -1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+	test_datasize_valid("HIDHOST Disconnect+", HAL_SERVICE_ID_HIDHOST,
+			HAL_OP_HIDHOST_DISCONNECT,
+			sizeof(struct hal_cmd_hidhost_disconnect), 1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+	test_datasize_valid("HIDHOST Disconnect-", HAL_SERVICE_ID_HIDHOST,
+			HAL_OP_HIDHOST_DISCONNECT,
+			sizeof(struct hal_cmd_hidhost_disconnect), -1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+	test_datasize_valid("HIDHOST Virt. Unplug+", HAL_SERVICE_ID_HIDHOST,
+			HAL_OP_HIDHOST_VIRTUAL_UNPLUG,
+			sizeof(struct hal_cmd_hidhost_virtual_unplug), 1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+	test_datasize_valid("HIDHOST Virt. Unplug-", HAL_SERVICE_ID_HIDHOST,
+			HAL_OP_HIDHOST_VIRTUAL_UNPLUG,
+			sizeof(struct hal_cmd_hidhost_virtual_unplug), -1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+	test_datasize_valid("HIDHOST Set Info+", HAL_SERVICE_ID_HIDHOST,
+			HAL_OP_HIDHOST_SET_INFO,
+			sizeof(struct hal_cmd_hidhost_set_info), 1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+	test_datasize_valid("HIDHOST Set Info-", HAL_SERVICE_ID_HIDHOST,
+			HAL_OP_HIDHOST_SET_INFO,
+			sizeof(struct hal_cmd_hidhost_set_info), -1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+	test_datasize_valid("HIDHOST Get Protocol+", HAL_SERVICE_ID_HIDHOST,
+			HAL_OP_HIDHOST_GET_PROTOCOL,
+			sizeof(struct hal_cmd_hidhost_get_protocol), 1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+	test_datasize_valid("HIDHOST Get Protocol-", HAL_SERVICE_ID_HIDHOST,
+			HAL_OP_HIDHOST_GET_PROTOCOL,
+			sizeof(struct hal_cmd_hidhost_get_protocol), -1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+	test_datasize_valid("HIDHOST Set Protocol+", HAL_SERVICE_ID_HIDHOST,
+			HAL_OP_HIDHOST_SET_PROTOCOL,
+			sizeof(struct hal_cmd_hidhost_set_protocol), 1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+	test_datasize_valid("HIDHOST Set Protocol-", HAL_SERVICE_ID_HIDHOST,
+			HAL_OP_HIDHOST_SET_PROTOCOL,
+			sizeof(struct hal_cmd_hidhost_set_protocol), -1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+	test_datasize_valid("HIDHOST Get Report+", HAL_SERVICE_ID_HIDHOST,
+			HAL_OP_HIDHOST_GET_REPORT,
+			sizeof(struct hal_cmd_hidhost_get_report), 1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+	test_datasize_valid("HIDHOST Get Report-", HAL_SERVICE_ID_HIDHOST,
+			HAL_OP_HIDHOST_GET_REPORT,
+			sizeof(struct hal_cmd_hidhost_get_report), -1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+	test_datasize_valid("HIDHOST Set Report+", HAL_SERVICE_ID_HIDHOST,
+			HAL_OP_HIDHOST_SET_REPORT,
+			sizeof(struct hal_cmd_hidhost_set_report), 1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+	test_datasize_valid("HIDHOST Set Report-", HAL_SERVICE_ID_HIDHOST,
+			HAL_OP_HIDHOST_SET_REPORT,
+			sizeof(struct hal_cmd_hidhost_set_report), -1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+	test_datasize_valid("HIDHOST Send Data+", HAL_SERVICE_ID_HIDHOST,
+			HAL_OP_HIDHOST_SEND_DATA,
+			sizeof(struct hal_cmd_hidhost_send_data), 1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+	test_datasize_valid("HIDHOST Send Data-", HAL_SERVICE_ID_HIDHOST,
+			HAL_OP_HIDHOST_SEND_DATA,
+			sizeof(struct hal_cmd_hidhost_send_data), -1,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+
 	return tester_run();
 }
-- 
1.8.5.2


^ permalink raw reply related


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