Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 2/4] android/map: Add support for MAP/MAS
From: Lukasz Rymanowski @ 2014-01-02 11:25 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: johan.hedberg, szymon.janc, luiz.dentz, Lukasz Rymanowski
In-Reply-To: <1388661934-25340-1-git-send-email-lukasz.rymanowski@tieto.com>

Theres no HAL API exposed to application which would allow to register
different MAS instances. Android 4.4 does support only MAS SMS.
All Instance ID, supported msg type and rfcomm channel are hardcoded
in the stack. Unfortunatelly we need to do the same way and wait for
new HAL API which is expected.

---
 android/socket.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 80 insertions(+), 2 deletions(-)

diff --git a/android/socket.c b/android/socket.c
index 15c1bb8..11d64f8 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -52,6 +52,14 @@
 
 #define SVC_HINT_OBEX 0x10
 
+/* Hardcoded MAP stuff needed for MAS SMS Instance.*/
+#define DEFAULT_MAS_INSTANCE	0x00
+
+#define MAP_MSG_TYPE_SMS_GSM	0x02
+#define MAP_MSG_TYPE_SMS_CDMA	0x04
+#define DEFAULT_MAS_MSG_TYPE	(MAP_MSG_TYPE_SMS_GSM | MAP_MSG_TYPE_SMS_CDMA)
+
+
 static bdaddr_t adapter_addr;
 
 /* Simple list of RFCOMM server sockets */
@@ -311,6 +319,76 @@ static sdp_record_t *create_pbap_record(uint8_t chan, const char *svc_name)
 	return record;
 }
 
+static sdp_record_t *create_mas_record(uint8_t chan, const char *svc_name)
+{
+	const char *service_name = "MAP MAS SMS";
+	sdp_list_t *svclass_id, *pfseq, *apseq, *root;
+	uuid_t root_uuid, mse_uuid, l2cap_uuid, rfcomm_uuid, obex_uuid;
+	sdp_profile_desc_t profile[1];
+	sdp_list_t *aproto, *proto[3];
+	sdp_data_t *channel;
+	uint8_t minst = DEFAULT_MAS_INSTANCE;
+	uint8_t mtype = DEFAULT_MAS_MSG_TYPE;
+	sdp_record_t *record;
+
+	record = sdp_record_alloc();
+	if (!record)
+		return NULL;
+
+	record->handle =  sdp_next_handle();
+
+	sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
+	root = sdp_list_append(NULL, &root_uuid);
+	sdp_set_browse_groups(record, root);
+
+	sdp_uuid16_create(&mse_uuid, MAP_MSE_SVCLASS_ID);
+	svclass_id = sdp_list_append(NULL, &mse_uuid);
+	sdp_set_service_classes(record, svclass_id);
+
+	sdp_uuid16_create(&profile[0].uuid, MAP_PROFILE_ID);
+	profile[0].version = 0x0101;
+	pfseq = sdp_list_append(NULL, profile);
+	sdp_set_profile_descs(record, pfseq);
+
+	sdp_attr_add_new(record, SDP_ATTR_MAS_INSTANCE_ID, SDP_UINT8, &minst);
+	sdp_attr_add_new(record, SDP_ATTR_SUPPORTED_MESSAGE_TYPES, SDP_UINT8,
+									&mtype);
+
+	sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
+	proto[0] = sdp_list_append(NULL, &l2cap_uuid);
+	apseq = sdp_list_append(NULL, proto[0]);
+
+	sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
+	proto[1] = sdp_list_append(NULL, &rfcomm_uuid);
+	channel = sdp_data_alloc(SDP_UINT8, &chan);
+	proto[1] = sdp_list_append(proto[1], channel);
+	apseq = sdp_list_append(apseq, proto[1]);
+
+	sdp_uuid16_create(&obex_uuid, OBEX_UUID);
+	proto[2] = sdp_list_append(NULL, &obex_uuid);
+	apseq = sdp_list_append(apseq, proto[2]);
+
+	aproto = sdp_list_append(NULL, apseq);
+	sdp_set_access_protos(record, aproto);
+
+	if (svc_name)
+		service_name = svc_name;
+
+	sdp_set_info_attr(record, service_name, NULL, NULL);
+
+	sdp_data_free(channel);
+	sdp_list_free(proto[0], NULL);
+	sdp_list_free(proto[1], NULL);
+	sdp_list_free(proto[2], NULL);
+	sdp_list_free(apseq, NULL);
+	sdp_list_free(pfseq, NULL);
+	sdp_list_free(aproto, NULL);
+	sdp_list_free(root, NULL);
+	sdp_list_free(svclass_id, NULL);
+
+	return record;
+}
+
 static sdp_record_t *create_spp_record(uint8_t chan, const char *svc_name)
 {
 	const char *service_name = "Serial Port";
@@ -411,9 +489,9 @@ static const struct profile_info {
 			0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
 		},
 		.channel = MAS_DEFAULT_CHANNEL,
-		.svc_hint = 0,
+		.svc_hint = SVC_HINT_OBEX,
 		.sec_level = BT_IO_SEC_MEDIUM,
-		.create_record = NULL
+		.create_record = create_mas_record
 	}, {
 		.uuid = {
 			0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x10, 0x00,
-- 
1.8.4


^ permalink raw reply related

* [PATCH 1/4] sdp: Add MAP_PROFILE_ID
From: Lukasz Rymanowski @ 2014-01-02 11:25 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: johan.hedberg, szymon.janc, luiz.dentz, Lukasz Rymanowski

---
 lib/sdp.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/sdp.h b/lib/sdp.h
index f2f2484..c6dfc27 100644
--- a/lib/sdp.h
+++ b/lib/sdp.h
@@ -207,6 +207,7 @@ extern "C" {
 #define PBAP_PCE_PROFILE_ID		PBAP_PCE_SVCLASS_ID
 #define PBAP_PSE_PROFILE_ID		PBAP_PSE_SVCLASS_ID
 #define PBAP_PROFILE_ID			PBAP_SVCLASS_ID
+#define MAP_PROFILE_ID			MAP_SVCLASS_ID
 #define PNP_INFO_PROFILE_ID		PNP_INFO_SVCLASS_ID
 #define GENERIC_NETWORKING_PROFILE_ID	GENERIC_NETWORKING_SVCLASS_ID
 #define GENERIC_FILETRANS_PROFILE_ID	GENERIC_FILETRANS_SVCLASS_ID
-- 
1.8.4


^ permalink raw reply related

* Re: [PATCH v2] Bluetooth: Add hci_h4p driver
From: Pavel Machek @ 2014-01-01 20:09 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Pali Rohár,
	Ивайло Димитров,
	Gustavo F. Padovan, Johan Hedberg, linux-kernel,
	linux-bluetooth@vger.kernel.org development, Ville Tervo,
	Sebastian Reichel
In-Reply-To: <E7C15C38-8E0E-4D49-9E93-5E3DAF77E252@holtmann.org>

Hi!

> >>> +static struct task_struct *h4p_thread;
> >> 
> >> Can’t this be done using a work queue. You are looking at a 3.14
> >> kernel the earliest. We have way better primitives these days.
> > 
> > I tried to convert it to work queue, but was not too
> > succesfull. Workqueue is not really good match for what this is trying
> > to do... Nokia code relies on sleeping, than timing those sleeps for
> > signaling. I'm still trying to wrap my head around it.
> > 
> > Ok, I guess I could convert it to one big workqueue task, and leave
> > the logic alone. Was that what you wanted?
> 
> the Bluetooth subsystem moved away from tasklets and uses workqueues for everything. So this should be just fine for this driver as well. I do not know about what timings are required, but they should only matter during initial device setup. The HCI traffic is actually driven by the Bluetooth core.
>

I actually tried to convert it to workqueue... result is below but I
was not successful.

h4p driver actually has one long-running, mostly sleeping, thread and
communicates with it by sending it wakeups; the thread toggles some
power management options based on activity. (No, I don't like that
design). That is not something that can be easily converted to
workqueue, AFAICT.

I don't think other Bluetooth drivers do anything similar.

								Pavel


diff --git a/drivers/bluetooth/hci_h4p.h b/drivers/bluetooth/hci_h4p.h
index a2174ea..5dcbaa1 100644
--- a/drivers/bluetooth/hci_h4p.h
+++ b/drivers/bluetooth/hci_h4p.h
@@ -19,12 +19,13 @@
  *
  */
 
+#ifndef __DRIVERS_BLUETOOTH_HCI_H4P_H
+#define __DRIVERS_BLUETOOTH_HCI_H4P_H
+
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
 #include <net/bluetooth/hci.h>
-
-#ifndef __DRIVERS_BLUETOOTH_HCI_H4P_H
-#define __DRIVERS_BLUETOOTH_HCI_H4P_H
+#include <linux/workqueue.h>
 
 #define FW_NAME_TI1271_PRELE	"ti1273_prele.bin"
 #define FW_NAME_TI1271_LE	"ti1273_le.bin"
@@ -103,6 +104,13 @@ struct hci_h4p_info {
 	u16 ier;
 	u16 mdr1;
 	u16 efr;
+
+#if 1
+	struct work_struct work;
+	struct workqueue_struct work_queue; /* FIXME: init me */
+	unsigned long last_transfer_jiffies;
+	unsigned long transfer_timeout;
+#endif
 };
 
 struct hci_h4p_radio_hdr {
diff --git a/drivers/bluetooth/nokia_core.c b/drivers/bluetooth/nokia_core.c
index 07761a3..6e37866 100644
--- a/drivers/bluetooth/nokia_core.c
+++ b/drivers/bluetooth/nokia_core.c
@@ -35,7 +35,6 @@
 #include <linux/interrupt.h>
 #include <linux/gpio.h>
 #include <linux/timer.h>
-#include <linux/kthread.h>
 
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
@@ -45,8 +44,6 @@
 
 #include "hci_h4p.h"
 
-static struct task_struct *h4p_thread;
-
 /* This should be used in function that cannot release clocks */
 static void hci_h4p_set_clk(struct hci_h4p_info *info, int *clock, int enable)
 {
@@ -103,13 +100,11 @@ void hci_h4p_smart_idle(struct hci_h4p_info *info, bool enable)
 
 static inline void h4p_schedule_pm(struct hci_h4p_info *info)
 {
-	if (unlikely(!h4p_thread))
-		return;
-
 	set_bit(H4P_SCHED_TRANSFER_MODE, &info->pm_flags);
 
 	if (unlikely(!test_bit(H4P_TRANSFER_MODE, &info->pm_flags)))
-		wake_up_process(h4p_thread);
+		/* FIXME */
+		/* wake_up_process(h4p_thread) */ ;
 }
 
 static void hci_h4p_disable_tx(struct hci_h4p_info *info)
@@ -723,18 +718,18 @@ static inline void hci_h4p_set_pm_limits(struct hci_h4p_info *info, bool set)
 	BT_DBG("pm constraints remains: %s", sset);
 }
 
-static int h4p_run(void *data)
+static int h4p_run(struct work_struct *work)
 {
 #define TIMEOUT_MIN msecs_to_jiffies(100)
 #define TIMEOUT_MAX msecs_to_jiffies(2000)
-	struct hci_h4p_info *info = data;
+	struct hci_h4p_info *info = container_of(work, struct hci_h4p_info, work);
 	unsigned long last_jiffies = jiffies;
 	unsigned long timeout = TIMEOUT_MIN;
 	unsigned long elapsed;
 	BT_DBG("");
 	set_user_nice(current, -10);
 
-	while (!kthread_should_stop()) {
+	while (1) {
 		set_current_state(TASK_INTERRUPTIBLE);
 		if (!test_bit(H4P_SCHED_TRANSFER_MODE, &info->pm_flags)) {
 			if (timeout != TIMEOUT_MIN) {
@@ -998,7 +993,8 @@ static int hci_h4p_hci_close(struct hci_dev *hdev)
 		return 0;
 
 	/* Wake up h4p_thread which removes pm constraints */
-	wake_up_process(h4p_thread);
+	/* FIXME */
+//	wake_up_process(h4p_thread);
 
 	hci_h4p_hci_flush(hdev);
 	hci_h4p_set_clk(info, &info->tx_clocks_en, 1);
@@ -1272,12 +1268,11 @@ static int hci_h4p_probe(struct platform_device *pdev)
 		goto cleanup_irq;
 	}
 
-	h4p_thread = kthread_run(h4p_run, info, "h4p_pm");
-	if (IS_ERR(h4p_thread)) {
-		err = PTR_ERR(h4p_thread);
-		goto cleanup_irq;
-	}
+	INIT_WORK(&info->work, h4p_run);
+//	schedule_work(&info->work);
 
+//	info->work_queue = init_work
+	queue_work(info->work_queue, &info->work);
 	return 0;
 
 cleanup_irq:
@@ -1300,7 +1295,7 @@ static int hci_h4p_remove(struct platform_device *pdev)
 
 	info = platform_get_drvdata(pdev);
 
-	kthread_stop(h4p_thread);
+	cancel_work_sync(&info->work);
 
 	hci_h4p_sysfs_remove_files(info->dev);
 	hci_h4p_hci_close(info->hdev);

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply related

* Re: [PATCH 1/5] android/tester: Add SCAN_MODE get prop success test case
From: Johan Hedberg @ 2014-01-01 16:32 UTC (permalink / raw)
  To: Grzegorz Kolodziejczyk; +Cc: linux-bluetooth
In-Reply-To: <1388501191-5377-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

Hi Grzegorz,

On Tue, Dec 31, 2013, Grzegorz Kolodziejczyk wrote:
> This adds SCAN_MODE get property success test case.
> ---
>  android/android-tester.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)

All patches in this set have been applied. Thanks.

However, I'm still expecting to see follow-up patches that add missing
checks for HCI-level behavior to the tests.

Johan

^ permalink raw reply

* Re: [PATCH 1/7] android: Add HCI snooping tool
From: Johan Hedberg @ 2014-01-01 16:30 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1388443421-6295-1-git-send-email-szymon.janc@gmail.com>

Hi Szymon,

On Mon, Dec 30, 2013, Szymon Janc wrote:
> This tool is intended to be run as Android service. It supports
> writing HCI snoop data in old btsnoop format only. By default traffic
> is stored in /sdcard/btsnoop_hci.log file (can be overridded with
> option - mainly for testing on Linux host). Only index 0 is sniffed.
> ---
>  .gitignore                 |   1 +
>  android/Android.mk         |  23 +++++
>  android/Makefile.am        |   6 ++
>  android/bluetoothd-snoop.c | 219 +++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 249 insertions(+)
>  create mode 100644 android/bluetoothd-snoop.c

All patches in this set have been applied. Thanks.

Johan

^ permalink raw reply

* Re: RFCOMM connection failing
From: Patrick Valsecchi @ 2014-01-01  8:34 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <52AF228D.1000608@thus.ch>

Hi,

Can somebody tell me if I should send this email on some other mailing list?

Thanks.

On 16. 12. 13 16:55, Patrick Valsecchi wrote:
> Hi,
>
> I'm trying to connect my PC:
>     Linux ... 3.11.0-14-generic #21-Ubuntu SMP ... x86_64 x86_64 
> x86_64 GNU/Linux
>     0a5c:2198 Broadcom Corp. Bluetooth 3.0 Device
>
> To connect with my bluetooth dive computer:
>     Shearwater Petrel
>
> It fails with a "Transport endpoint is not connected (107)" most of 
> the time or go further but seem to have corrupted RFCOMM payload.
>
> If I pass the USB device to a W7 VM (virtualbox) and try from them, 
> the communication works like charm.
>
> So I went ahead and sniffed the USB communication in both cases using 
> wireshark. The two dumps () can be found here (UsbDumpFrom*.pcapng, 
> can be open using wireshark):
> https://cloud.thus.ch/public.php?service=files&t=de2eabf30c82efa08cf546ff5045e585 
>
>
> Basically the Linux one is just stopping at frame 203 where it sends a 
> RFCOMM SABM, gets the answer and reports an error to the user. The 
> windows dump show the same RFCOMM SABM command in frame 191 and gets 
> the same answer but continues and everything works.
>
> On IRC aholler told me you guys would prefer to get a btmon dump with 
> bluez v5. So I went ahead, installed bluez 5.12 and generated a dump 
> (yes, the comm still fails the same way) that you can find in the same 
> location as the dumps.
>
> I'm stuck there. Can somebody help me go further?
>
> Thanks
> -- 
> 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: [PATCH v2] Bluetooth: Add hci_h4p driver
From: Marcel Holtmann @ 2013-12-31 23:23 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Pali Rohár,
	Ивайло Димитров,
	Gustavo F. Padovan, Johan Hedberg, linux-kernel,
	linux-bluetooth@vger.kernel.org development, Ville Tervo,
	Sebastian Reichel
In-Reply-To: <20131231221202.GB25336@amd.pavel.ucw.cz>

Hi Pavel,

>>> +static struct task_struct *h4p_thread;
>> 
>> Can’t this be done using a work queue. You are looking at a 3.14
>> kernel the earliest. We have way better primitives these days.
> 
> I tried to convert it to work queue, but was not too
> succesfull. Workqueue is not really good match for what this is trying
> to do... Nokia code relies on sleeping, than timing those sleeps for
> signaling. I'm still trying to wrap my head around it.
> 
> Ok, I guess I could convert it to one big workqueue task, and leave
> the logic alone. Was that what you wanted?

the Bluetooth subsystem moved away from tasklets and uses workqueues for everything. So this should be just fine for this driver as well. I do not know about what timings are required, but they should only matter during initial device setup. The HCI traffic is actually driven by the Bluetooth core.

Regards

Marcel


^ permalink raw reply

* Re: [PATCH v2] Bluetooth: Add hci_h4p driver
From: Pavel Machek @ 2013-12-31 22:12 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Pali Rohár,
	Ивайло Димитров,
	Gustavo F. Padovan, Johan Hedberg, linux-kernel,
	linux-bluetooth@vger.kernel.org development, Ville Tervo,
	Sebastian Reichel
In-Reply-To: <C8D1F470-7964-4EAC-82E0-D53CF54DE086@holtmann.org>

Hi!

> > +static struct task_struct *h4p_thread;
> 
> Can’t this be done using a work queue. You are looking at a 3.14
> kernel the earliest. We have way better primitives these days.

I tried to convert it to work queue, but was not too
succesfull. Workqueue is not really good match for what this is trying
to do... Nokia code relies on sleeping, than timing those sleeps for
signaling. I'm still trying to wrap my head around it.

Ok, I guess I could convert it to one big workqueue task, and leave
the logic alone. Was that what you wanted?

In the meantime, while trying to untangle it:

commit b02dc19d9269f22baa705d16d1019b86acf15758
Author: Pavel <pavel@ucw.cz>
Date:   Tue Dec 31 23:01:23 2013 +0100

    De-obfuscate power management code. Someone please carefully review
    this.
    
    Signed-off-by: Pavel Machek <pavel@ucw.cz>

diff --git a/drivers/bluetooth/nokia_core.c b/drivers/bluetooth/nokia_core.c
index 85dd106..07761a3 100644
--- a/drivers/bluetooth/nokia_core.c
+++ b/drivers/bluetooth/nokia_core.c
@@ -705,28 +705,22 @@ static irqreturn_t hci_h4p_wakeup_interrupt(int irq, void *dev_inst)
 static inline void hci_h4p_set_pm_limits(struct hci_h4p_info *info, bool set)
 {
 	struct hci_h4p_platform_data *bt_plat_data = info->dev->platform_data;
+	char *sset = set ? "set" : "clear";
 
 	if (unlikely(!bt_plat_data || !bt_plat_data->set_pm_limits))
 		return;
 
-	if (set && !test_bit(H4P_ACTIVE_MODE, &info->pm_flags)) {
+	if (set != !!test_bit(H4P_ACTIVE_MODE, &info->pm_flags)) {
 		bt_plat_data->set_pm_limits(info->dev, set);
-		set_bit(H4P_ACTIVE_MODE, &info->pm_flags);
-		BT_DBG("Change pm constraints to: %s", set ?
-				"set" : "clear");
+		if (set)
+			set_bit(H4P_ACTIVE_MODE, &info->pm_flags);
+		else
+			clear_bit(H4P_ACTIVE_MODE, &info->pm_flags);
+		BT_DBG("Change pm constraints to: %s", sset);
 		return;
 	}
 
-	if (!set && test_bit(H4P_ACTIVE_MODE, &info->pm_flags)) {
-		bt_plat_data->set_pm_limits(info->dev, set);
-		clear_bit(H4P_ACTIVE_MODE, &info->pm_flags);
-		BT_DBG("Change pm constraints to: %s",
-				set ? "set" : "clear");
-		return;
-	}
-
-	BT_DBG("pm constraints remains: %s",
-			set ? "set" : "clear");
+	BT_DBG("pm constraints remains: %s", sset);
 }
 
 static int h4p_run(void *data)
@@ -762,16 +756,17 @@ static int h4p_run(void *data)
 		BT_DBG("Timeout before calculation = %u",
 				jiffies_to_msecs(timeout));
 
-		/* Empiric analyzer  :-) */
 		if (elapsed < TIMEOUT_MIN) {
 			timeout <<= 1;
-			timeout = (timeout > TIMEOUT_MAX) ?
-				TIMEOUT_MAX : timeout;
 		} else {
-			timeout = (elapsed > timeout - TIMEOUT_MIN) ?
-				TIMEOUT_MIN : timeout - elapsed;
+			timeout -= elapsed;
 		}
 
+		if (timeout > TIMEOUT_MAX)
+			timeout = TIMEOUT_MAX;
+		if (timeout < TIMEOUT_MIN)
+			timeout = TIMEOUT_MIN;
+
 		BT_DBG("Timeout after calculation = %u",
 				jiffies_to_msecs(timeout));
 

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply related

* [PATCH 5/5] android/tester: Add SCAN_MODE=NONE set prop done test case
From: Grzegorz Kolodziejczyk @ 2013-12-31 14:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388501191-5377-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds SCAN_MODE property set to NONE - done test case.

SCAN_MODE at startup is set to NONE. Bluez return status - done when
requested status is the same as was.
---
 android/android-tester.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index 5467aff..04fa811 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -900,6 +900,17 @@ static const struct generic_data bluetooth_getprop_bondeddev_success_test = {
 	.expected_property.len = 0,
 };
 
+static bt_scan_mode_t setprop_scanmode_none = BT_SCAN_MODE_NONE;
+
+static const struct generic_data bluetooth_setprop_scanmode_none_done_test = {
+	.expected_hal_cb.adapter_properties_cb = getprop_success_cb,
+	.expected_cb_count = 1,
+	.expected_adapter_status = BT_STATUS_DONE,
+	.expected_property.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
+	.expected_property.val = &setprop_scanmode_none,
+	.expected_property.len = sizeof(setprop_scanmode_none),
+};
+
 static const struct generic_data bluetooth_discovery_start_success_test = {
 	.expected_hal_cb.discovery_state_changed_cb =
 						discovery_start_success_cb,
@@ -1353,6 +1364,19 @@ static void test_getprop_bondeddev_success(const void *test_data)
 	check_expected_status(adapter_status);
 }
 
+static void test_setprop_scanmode_none_done(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	const struct generic_data *test = data->test_data;
+	const bt_property_t *prop = &test->expected_property;
+	bt_status_t adapter_status;
+
+	init_test_conditions(data);
+
+	adapter_status = data->if_bluetooth->set_adapter_property(prop);
+	check_expected_status(adapter_status);
+}
+
 static void test_discovery_start_success(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
@@ -1957,6 +1981,11 @@ int main(int argc, char *argv[])
 				setup_enabled_adapter,
 				test_getprop_bondeddev_success, teardown);
 
+	test_bredrle("Bluetooth Set SCAN_MODE NONE - Done",
+				&bluetooth_setprop_scanmode_none_done_test,
+				setup_enabled_adapter,
+				test_setprop_scanmode_none_done, teardown);
+
 	test_bredrle("Bluetooth BREDR Discovery Start - Success",
 				&bluetooth_discovery_start_success_test,
 				setup_enabled_adapter,
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 4/5] android/tester: Add BONDED_DEVICES get prop success test case
From: Grzegorz Kolodziejczyk @ 2013-12-31 14:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388501191-5377-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds BONDED_DEVICES get property success test case.

At this time there are no bonded devices. Clear bonded devices list is
expected.
---
 android/android-tester.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index ae6959b..5467aff 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -891,6 +891,15 @@ static const struct generic_data bluetooth_getprop_uuids_success_test = {
 	.expected_property.len = sizeof(getprop_uuids),
 };
 
+static const struct generic_data bluetooth_getprop_bondeddev_success_test = {
+	.expected_hal_cb.adapter_properties_cb = getprop_success_cb,
+	.expected_cb_count = 1,
+	.expected_adapter_status = BT_STATUS_SUCCESS,
+	.expected_property.type = BT_PROPERTY_ADAPTER_BONDED_DEVICES,
+	.expected_property.val = NULL,
+	.expected_property.len = 0,
+};
+
 static const struct generic_data bluetooth_discovery_start_success_test = {
 	.expected_hal_cb.discovery_state_changed_cb =
 						discovery_start_success_cb,
@@ -1331,6 +1340,19 @@ static void test_getprop_uuids_success(const void *test_data)
 	check_expected_status(adapter_status);
 }
 
+static void test_getprop_bondeddev_success(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	const struct generic_data *test = data->test_data;
+	const bt_property_t prop = test->expected_property;
+	bt_status_t adapter_status;
+
+	init_test_conditions(data);
+
+	adapter_status = data->if_bluetooth->get_adapter_property(prop.type);
+	check_expected_status(adapter_status);
+}
+
 static void test_discovery_start_success(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
@@ -1930,6 +1952,11 @@ int main(int argc, char *argv[])
 					setup_enabled_adapter,
 					test_getprop_uuids_success, teardown);
 
+	test_bredrle("Bluetooth Get BONDED_DEVICES - Success",
+				&bluetooth_getprop_bondeddev_success_test,
+				setup_enabled_adapter,
+				test_getprop_bondeddev_success, teardown);
+
 	test_bredrle("Bluetooth BREDR Discovery Start - Success",
 				&bluetooth_discovery_start_success_test,
 				setup_enabled_adapter,
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 3/5] android/tester: Add UUIDS get prop success test case
From: Grzegorz Kolodziejczyk @ 2013-12-31 14:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388501191-5377-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds UUIDS get property success test case.
---
 android/android-tester.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index f02d4ac..ae6959b 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -877,6 +877,20 @@ static const struct generic_data bluetooth_getprop_disctimeout_success_test = {
 	.expected_property.len = sizeof(getprop_disctimeout_val),
 };
 
+static bt_uuid_t getprop_uuids = {
+	.uu = { 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00,
+					0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB },
+};
+
+static const struct generic_data bluetooth_getprop_uuids_success_test = {
+	.expected_hal_cb.adapter_properties_cb = getprop_success_cb,
+	.expected_cb_count = 1,
+	.expected_adapter_status = BT_STATUS_SUCCESS,
+	.expected_property.type = BT_PROPERTY_UUIDS,
+	.expected_property.val = &getprop_uuids,
+	.expected_property.len = sizeof(getprop_uuids),
+};
+
 static const struct generic_data bluetooth_discovery_start_success_test = {
 	.expected_hal_cb.discovery_state_changed_cb =
 						discovery_start_success_cb,
@@ -1304,6 +1318,19 @@ static void test_getprop_disctimeout_success(const void *test_data)
 	check_expected_status(adapter_status);
 }
 
+static void test_getprop_uuids_success(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	const struct generic_data *test = data->test_data;
+	const bt_property_t prop = test->expected_property;
+	bt_status_t adapter_status;
+
+	init_test_conditions(data);
+
+	adapter_status = data->if_bluetooth->get_adapter_property(prop.type);
+	check_expected_status(adapter_status);
+}
+
 static void test_discovery_start_success(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
@@ -1898,6 +1925,11 @@ int main(int argc, char *argv[])
 				setup_enabled_adapter,
 				test_getprop_disctimeout_success, teardown);
 
+	test_bredrle("Bluetooth Get UUIDS - Success",
+					&bluetooth_getprop_uuids_success_test,
+					setup_enabled_adapter,
+					test_getprop_uuids_success, teardown);
+
 	test_bredrle("Bluetooth BREDR Discovery Start - Success",
 				&bluetooth_discovery_start_success_test,
 				setup_enabled_adapter,
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 2/5] android/tester: Add DISCOVERY_TIMEOUT get prop success test case
From: Grzegorz Kolodziejczyk @ 2013-12-31 14:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388501191-5377-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds DISCOVERY_TIMEOUT get property success test case.
---
 android/android-tester.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index d831f74..f02d4ac 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -866,6 +866,17 @@ static const struct generic_data bluetooth_getprop_scanmode_success_test = {
 	.expected_property.len = sizeof(getprop_scanmode),
 };
 
+static uint32_t getprop_disctimeout_val = 120;
+
+static const struct generic_data bluetooth_getprop_disctimeout_success_test = {
+	.expected_hal_cb.adapter_properties_cb = getprop_success_cb,
+	.expected_cb_count = 1,
+	.expected_adapter_status = BT_STATUS_SUCCESS,
+	.expected_property.type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
+	.expected_property.val = &getprop_disctimeout_val,
+	.expected_property.len = sizeof(getprop_disctimeout_val),
+};
+
 static const struct generic_data bluetooth_discovery_start_success_test = {
 	.expected_hal_cb.discovery_state_changed_cb =
 						discovery_start_success_cb,
@@ -1280,6 +1291,19 @@ static void test_getprop_scanmode_success(const void *test_data)
 	check_expected_status(adapter_status);
 }
 
+static void test_getprop_disctimeout_success(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	const struct generic_data *test = data->test_data;
+	const bt_property_t prop = test->expected_property;
+	bt_status_t adapter_status;
+
+	init_test_conditions(data);
+
+	adapter_status = data->if_bluetooth->get_adapter_property(prop.type);
+	check_expected_status(adapter_status);
+}
+
 static void test_discovery_start_success(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
@@ -1869,6 +1893,11 @@ int main(int argc, char *argv[])
 				setup_enabled_adapter,
 				test_getprop_scanmode_success, teardown);
 
+	test_bredrle("Bluetooth Get DISCOVERY_TIMEOUT - Success",
+				&bluetooth_getprop_disctimeout_success_test,
+				setup_enabled_adapter,
+				test_getprop_disctimeout_success, teardown);
+
 	test_bredrle("Bluetooth BREDR Discovery Start - Success",
 				&bluetooth_discovery_start_success_test,
 				setup_enabled_adapter,
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 1/5] android/tester: Add SCAN_MODE get prop success test case
From: Grzegorz Kolodziejczyk @ 2013-12-31 14:46 UTC (permalink / raw)
  To: linux-bluetooth

This adds SCAN_MODE get property success test case.
---
 android/android-tester.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index c89b97a..d831f74 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -855,6 +855,17 @@ static const struct generic_data bluetooth_getprop_tod_success_test = {
 	.expected_property.len = sizeof(getprop_tod),
 };
 
+static bt_scan_mode_t getprop_scanmode = BT_SCAN_MODE_NONE;
+
+static const struct generic_data bluetooth_getprop_scanmode_success_test = {
+	.expected_hal_cb.adapter_properties_cb = getprop_success_cb,
+	.expected_cb_count = 1,
+	.expected_adapter_status = BT_STATUS_SUCCESS,
+	.expected_property.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
+	.expected_property.val = &getprop_scanmode,
+	.expected_property.len = sizeof(getprop_scanmode),
+};
+
 static const struct generic_data bluetooth_discovery_start_success_test = {
 	.expected_hal_cb.discovery_state_changed_cb =
 						discovery_start_success_cb,
@@ -1256,6 +1267,19 @@ static void test_getprop_tod_success(const void *test_data)
 	check_expected_status(adapter_status);
 }
 
+static void test_getprop_scanmode_success(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	const struct generic_data *test = data->test_data;
+	const bt_property_t prop = test->expected_property;
+	bt_status_t adapter_status;
+
+	init_test_conditions(data);
+
+	adapter_status = data->if_bluetooth->get_adapter_property(prop.type);
+	check_expected_status(adapter_status);
+}
+
 static void test_discovery_start_success(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
@@ -1840,6 +1864,11 @@ int main(int argc, char *argv[])
 					setup_enabled_adapter,
 					test_getprop_tod_success, teardown);
 
+	test_bredrle("Bluetooth Get SCAN_MODE - Success",
+				&bluetooth_getprop_scanmode_success_test,
+				setup_enabled_adapter,
+				test_getprop_scanmode_success, teardown);
+
 	test_bredrle("Bluetooth BREDR Discovery Start - Success",
 				&bluetooth_discovery_start_success_test,
 				setup_enabled_adapter,
-- 
1.8.5.2


^ permalink raw reply related

* Re: [PATCH_v3] android/pan: Add pan sdp record for NAP role
From: Johan Hedberg @ 2013-12-31 13:44 UTC (permalink / raw)
  To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1388494627-1449-1-git-send-email-ravikumar.veeramally@linux.intel.com>

Hi Ravi,

On Tue, Dec 31, 2013, Ravi kumar Veeramally wrote:
> ---
>  android/pan.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 95 insertions(+)

Applied. Thanks.

Johan

^ permalink raw reply

* [PATCH_v3] android/pan: Add pan sdp record for NAP role
From: Ravi kumar Veeramally @ 2013-12-31 12:57 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally

---
 android/pan.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)

diff --git a/android/pan.c b/android/pan.c
index 689c7ef..38e353d 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -44,9 +44,12 @@
 #include "utils.h"
 #include "bluetooth.h"
 
+#define SVC_HINT_NETWORKING 0x02
+
 static bdaddr_t adapter_addr;
 GSList *devices = NULL;
 uint8_t local_role = HAL_PAN_ROLE_NONE;
+static uint32_t record_id = 0;
 
 struct pan_device {
 	char		iface[16];
@@ -335,20 +338,110 @@ static const struct ipc_handler cmd_handlers[] = {
 	{ bt_pan_disconnect, false, sizeof(struct hal_cmd_pan_disconnect) },
 };
 
+static sdp_record_t *pan_record(void)
+{
+	sdp_list_t *svclass, *pfseq, *apseq, *root, *aproto;
+	uuid_t root_uuid, pan, l2cap, bnep;
+	sdp_profile_desc_t profile[1];
+	sdp_list_t *proto[2];
+	sdp_data_t *v, *p;
+	uint16_t psm = BNEP_PSM, version = 0x0100;
+	uint16_t security = 0x0001, type = 0xfffe;
+	uint32_t rate = 0;
+	const char *desc = "Network Access Point", *name = "Network Service";
+	sdp_record_t *record;
+	uint16_t ptype[] = { 0x0800, /* IPv4 */ 0x0806,  /* ARP */ };
+	sdp_data_t *head, *pseq, *data;
+
+	record = sdp_record_alloc();
+	if (!record)
+		return NULL;
+
+	record->attrlist = NULL;
+	record->pattern = NULL;
+
+	sdp_uuid16_create(&pan, NAP_SVCLASS_ID);
+	svclass = sdp_list_append(NULL, &pan);
+	sdp_set_service_classes(record, svclass);
+
+	sdp_uuid16_create(&profile[0].uuid, NAP_PROFILE_ID);
+	profile[0].version = 0x0100;
+	pfseq = sdp_list_append(NULL, &profile[0]);
+	sdp_set_profile_descs(record, pfseq);
+	sdp_set_info_attr(record, name, NULL, desc);
+	sdp_attr_add_new(record, SDP_ATTR_NET_ACCESS_TYPE, SDP_UINT16, &type);
+	sdp_attr_add_new(record, SDP_ATTR_MAX_NET_ACCESSRATE,
+							SDP_UINT32, &rate);
+
+	sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
+	root = sdp_list_append(NULL, &root_uuid);
+	sdp_set_browse_groups(record, root);
+
+	sdp_uuid16_create(&l2cap, L2CAP_UUID);
+	proto[0] = sdp_list_append(NULL, &l2cap);
+	p = sdp_data_alloc(SDP_UINT16, &psm);
+	proto[0] = sdp_list_append(proto[0], p);
+	apseq = sdp_list_append(NULL, proto[0]);
+
+	sdp_uuid16_create(&bnep, BNEP_UUID);
+	proto[1] = sdp_list_append(NULL, &bnep);
+	v = sdp_data_alloc(SDP_UINT16, &version);
+	proto[1] = sdp_list_append(proto[1], v);
+
+	head = sdp_data_alloc(SDP_UINT16, &ptype[0]);
+	data = sdp_data_alloc(SDP_UINT16, &ptype[1]);
+	sdp_seq_append(head, data);
+
+	pseq = sdp_data_alloc(SDP_SEQ16, head);
+	proto[1] = sdp_list_append(proto[1], pseq);
+	apseq = sdp_list_append(apseq, proto[1]);
+	aproto = sdp_list_append(NULL, apseq);
+	sdp_set_access_protos(record, aproto);
+	sdp_add_lang_attr(record);
+	sdp_attr_add_new(record, SDP_ATTR_SECURITY_DESC, SDP_UINT16, &security);
+
+	sdp_data_free(p);
+	sdp_data_free(v);
+	sdp_list_free(apseq, NULL);
+	sdp_list_free(root, NULL);
+	sdp_list_free(aproto, NULL);
+	sdp_list_free(proto[0], NULL);
+	sdp_list_free(proto[1], NULL);
+	sdp_list_free(svclass, NULL);
+	sdp_list_free(pfseq, NULL);
+
+	return record;
+}
+
 bool bt_pan_register(const bdaddr_t *addr)
 {
+	sdp_record_t *rec;
 	int err;
 
 	DBG("");
 
 	bacpy(&adapter_addr, addr);
 
+	rec = pan_record();
+	if (!rec) {
+		error("Failed to allocate PAN record");
+		return false;
+	}
+
+	if (bt_adapter_add_record(rec, SVC_HINT_NETWORKING) < 0) {
+		error("Failed to register PAN record");
+		sdp_record_free(rec);
+		return false;
+	}
+
 	err = bnep_init();
 	if (err) {
 		error("bnep init failed");
+		sdp_record_free(rec);
 		return false;
 	}
 
+	record_id = rec->handle;
 	ipc_register(HAL_SERVICE_ID_PAN, cmd_handlers,
 						G_N_ELEMENTS(cmd_handlers));
 
@@ -362,4 +455,6 @@ void bt_pan_unregister(void)
 	bnep_cleanup();
 
 	ipc_unregister(HAL_SERVICE_ID_PAN);
+	bt_adapter_remove_record(record_id);
+	record_id = 0;
 }
-- 
1.8.3.2


^ permalink raw reply related

* Re: BLE for Android
From: Luiz Augusto von Dentz @ 2013-12-31 12:02 UTC (permalink / raw)
  To: bill dr; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CAHTi60GvSMT54WbHC_aw=qja8ApFKZ4ouUYMDVi7RPuFZf-Urw@mail.gmail.com>

Hi,

On Tue, Dec 31, 2013 at 1:47 PM, bill dr <bilel.dr@gmail.com> wrote:
> Hi,
>
> I am trying to port BLE into a 4.1.1 android device.
> I found that bluez git repository contains an android directory.
> Could you explain me or point me to any link or document that explain
> how to use this directory. Is there any HAL implementation already
> done. Or this directory contains only "bluedroid" code ?
>
> Thank you !

Checkout the README:
https://git.kernel.org/cgit/bluetooth/bluez.git/tree/android/README

It is a clean implementation of bluetooth HAL, so no bluedroid code
bellow the HAL interface, above HAL is considered Android itself even
though it may actually contain bluetooth specific bits here and there.
Btw, we are almost ready to start looking at the BLE HAL.



-- 
Luiz Augusto von Dentz

^ permalink raw reply

* Re: [PATCH] tools/bluetooth-player: Formatting commands
From: Luiz Augusto von Dentz @ 2013-12-31 11:55 UTC (permalink / raw)
  To: Sebastian Chlad; +Cc: linux-bluetooth@vger.kernel.org, Sebastian Chlad
In-Reply-To: <1388413892-10018-1-git-send-email-sebastianx.chlad@intel.com>

Hi Sebastian,

On Mon, Dec 30, 2013 at 4:31 PM, Sebastian Chlad
<sebastianchlad@gmail.com> wrote:
> Formatting commands passed to bluetooth player.
> Whitespace character trimmed.
> ---
>  tools/bluetooth-player.c |    1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/tools/bluetooth-player.c b/tools/bluetooth-player.c
> index 622d391..2afdd17 100644
> --- a/tools/bluetooth-player.c
> +++ b/tools/bluetooth-player.c
> @@ -1080,6 +1080,7 @@ static void rl_handler(char *input)
>         if (!strlen(input))
>                 goto done;
>
> +       g_strstrip(input);
>         add_history(input);
>
>         argv = g_strsplit(input, " ", -1);
> --
> 1.7.9.5

Pushed, I went ahead and pushed a similar fix to obexctl and it seems
bluetoothctl could use the same logic but it doesn't use g_strsplit
and it does in fact check trailing whitespaces:

if (arg) {
    int len = strlen(arg);
    if (len > 0 && arg[len - 1] == ' ')
        arg[len - 1] = '\0';
}

We might be better off with g_strstrip + g_strsplit since we depend on
glib anyway.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* BLE for Android
From: bill dr @ 2013-12-31 11:47 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

I am trying to port BLE into a 4.1.1 android device.
I found that bluez git repository contains an android directory.
Could you explain me or point me to any link or document that explain
how to use this directory. Is there any HAL implementation already
done. Or this directory contains only "bluedroid" code ?

Thank you !

^ permalink raw reply

* [PATCH BlueZ 10/10] android/A2DP: Add stream suspend command/response struct
From: Luiz Augusto von Dentz @ 2013-12-31 11:30 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388489402-8919-1-git-send-email-luiz.dentz@gmail.com>

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

This adds the definitions to stream suspend command and response.
---
 android/a2dp.c    | 10 ++++++++++
 android/hal-msg.h |  5 +++++
 2 files changed, 15 insertions(+)

diff --git a/android/a2dp.c b/android/a2dp.c
index d3c02d6..dc2890c 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -392,6 +392,14 @@ static void bt_stream_resume(const void *buf, uint16_t len)
 							HAL_STATUS_FAILED);
 }
 
+static void bt_stream_suspend(const void *buf, uint16_t len)
+{
+	DBG("Not Implemented");
+
+	audio_ipc_send_rsp(AUDIO_SERVICE_ID_CORE, AUDIO_OP_SUSPEND_STREAM,
+							HAL_STATUS_FAILED);
+}
+
 static const struct ipc_handler audio_handlers[] = {
 	/* AUDIO_OP_OPEN */
 	{ bt_audio_open, true, sizeof(struct audio_cmd_open) },
@@ -403,6 +411,8 @@ static const struct ipc_handler audio_handlers[] = {
 	{ bt_stream_close, false, sizeof(struct audio_cmd_close_stream) },
 	/* AUDIO_OP_RESUME_STREAM */
 	{ bt_stream_resume, false, sizeof(struct audio_cmd_resume_stream) },
+	/* AUDIO_OP_SUSPEND_STREAM */
+	{ bt_stream_suspend, false, sizeof(struct audio_cmd_suspend_stream) },
 };
 
 bool bt_a2dp_register(const bdaddr_t *addr)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 259b687..6b2ec88 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -613,3 +613,8 @@ struct audio_cmd_close_stream {
 struct audio_cmd_resume_stream {
 	uint8_t id;
 } __attribute__((packed));
+
+#define AUDIO_OP_SUSPEND_STREAM			0x06
+struct audio_cmd_suspend_stream {
+	uint8_t id;
+} __attribute__((packed));
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH BlueZ 09/10] android/A2DP: Add stream resume command/response struct
From: Luiz Augusto von Dentz @ 2013-12-31 11:30 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388489402-8919-1-git-send-email-luiz.dentz@gmail.com>

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

This adds the definitions to stream resume command and response.
---
 android/a2dp.c    | 10 ++++++++++
 android/hal-msg.h |  5 +++++
 2 files changed, 15 insertions(+)

diff --git a/android/a2dp.c b/android/a2dp.c
index eac427d..d3c02d6 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -384,6 +384,14 @@ static void bt_stream_close(const void *buf, uint16_t len)
 							HAL_STATUS_FAILED);
 }
 
+static void bt_stream_resume(const void *buf, uint16_t len)
+{
+	DBG("Not Implemented");
+
+	audio_ipc_send_rsp(AUDIO_SERVICE_ID_CORE, AUDIO_OP_RESUME_STREAM,
+							HAL_STATUS_FAILED);
+}
+
 static const struct ipc_handler audio_handlers[] = {
 	/* AUDIO_OP_OPEN */
 	{ bt_audio_open, true, sizeof(struct audio_cmd_open) },
@@ -393,6 +401,8 @@ static const struct ipc_handler audio_handlers[] = {
 	{ bt_stream_open, false, sizeof(struct audio_cmd_open_stream) },
 	/* AUDIO_OP_CLOSE_STREAM */
 	{ bt_stream_close, false, sizeof(struct audio_cmd_close_stream) },
+	/* AUDIO_OP_RESUME_STREAM */
+	{ bt_stream_resume, false, sizeof(struct audio_cmd_resume_stream) },
 };
 
 bool bt_a2dp_register(const bdaddr_t *addr)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index a708157..259b687 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -608,3 +608,8 @@ struct audio_rsp_open_stream {
 struct audio_cmd_close_stream {
 	uint8_t id;
 } __attribute__((packed));
+
+#define AUDIO_OP_RESUME_STREAM			0x05
+struct audio_cmd_resume_stream {
+	uint8_t id;
+} __attribute__((packed));
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH BlueZ 08/10] android/A2DP: Add stream close command/response struct
From: Luiz Augusto von Dentz @ 2013-12-31 11:30 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388489402-8919-1-git-send-email-luiz.dentz@gmail.com>

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

This adds the definitions to stream close command and response.
---
 android/a2dp.c    | 10 ++++++++++
 android/hal-msg.h |  5 +++++
 2 files changed, 15 insertions(+)

diff --git a/android/a2dp.c b/android/a2dp.c
index 7709b15..eac427d 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -376,6 +376,14 @@ static void bt_stream_open(const void *buf, uint16_t len)
 							HAL_STATUS_FAILED);
 }
 
+static void bt_stream_close(const void *buf, uint16_t len)
+{
+	DBG("Not Implemented");
+
+	audio_ipc_send_rsp(AUDIO_SERVICE_ID_CORE, AUDIO_OP_CLOSE_STREAM,
+							HAL_STATUS_FAILED);
+}
+
 static const struct ipc_handler audio_handlers[] = {
 	/* AUDIO_OP_OPEN */
 	{ bt_audio_open, true, sizeof(struct audio_cmd_open) },
@@ -383,6 +391,8 @@ static const struct ipc_handler audio_handlers[] = {
 	{ bt_audio_close, false, sizeof(struct audio_cmd_close) },
 	/* AUDIO_OP_OPEN_STREAM */
 	{ bt_stream_open, false, sizeof(struct audio_cmd_open_stream) },
+	/* AUDIO_OP_CLOSE_STREAM */
+	{ bt_stream_close, false, sizeof(struct audio_cmd_close_stream) },
 };
 
 bool bt_a2dp_register(const bdaddr_t *addr)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index ff62de0..a708157 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -603,3 +603,8 @@ struct audio_rsp_open_stream {
 	uint8_t len;
 	uint8_t data[0];
 } __attribute__((packed));
+
+#define AUDIO_OP_CLOSE_STREAM			0x04
+struct audio_cmd_close_stream {
+	uint8_t id;
+} __attribute__((packed));
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH BlueZ 07/10] android/A2DP: Add stream open command/response struct
From: Luiz Augusto von Dentz @ 2013-12-31 11:29 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388489402-8919-1-git-send-email-luiz.dentz@gmail.com>

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

This adds the definitions to stream open command and response.
---
 android/a2dp.c    | 10 ++++++++++
 android/hal-msg.h | 10 ++++++++++
 2 files changed, 20 insertions(+)

diff --git a/android/a2dp.c b/android/a2dp.c
index e3d58ca..7709b15 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -368,11 +368,21 @@ static void bt_audio_close(const void *buf, uint16_t len)
 							HAL_STATUS_FAILED);
 }
 
+static void bt_stream_open(const void *buf, uint16_t len)
+{
+	DBG("Not Implemented");
+
+	audio_ipc_send_rsp(AUDIO_SERVICE_ID_CORE, AUDIO_OP_OPEN_STREAM,
+							HAL_STATUS_FAILED);
+}
+
 static const struct ipc_handler audio_handlers[] = {
 	/* AUDIO_OP_OPEN */
 	{ bt_audio_open, true, sizeof(struct audio_cmd_open) },
 	/* AUDIO_OP_CLOSE */
 	{ bt_audio_close, false, sizeof(struct audio_cmd_close) },
+	/* AUDIO_OP_OPEN_STREAM */
+	{ bt_stream_open, false, sizeof(struct audio_cmd_open_stream) },
 };
 
 bool bt_a2dp_register(const bdaddr_t *addr)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index d1135df..ff62de0 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -593,3 +593,13 @@ struct audio_rsp_open {
 struct audio_cmd_close {
 	uint8_t id;
 } __attribute__((packed));
+
+#define AUDIO_OP_OPEN_STREAM			0x03
+struct audio_cmd_open_stream {
+	uint8_t id;
+} __attribute__((packed));
+
+struct audio_rsp_open_stream {
+	uint8_t len;
+	uint8_t data[0];
+} __attribute__((packed));
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH BlueZ 06/10] android/A2DP: Add audio close command/response struct
From: Luiz Augusto von Dentz @ 2013-12-31 11:29 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388489402-8919-1-git-send-email-luiz.dentz@gmail.com>

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

This adds the definitions to audio close command and response.
---
 android/a2dp.c    | 10 ++++++++++
 android/hal-msg.h |  5 +++++
 2 files changed, 15 insertions(+)

diff --git a/android/a2dp.c b/android/a2dp.c
index 325c282..e3d58ca 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -360,9 +360,19 @@ static void bt_audio_open(const void *buf, uint16_t len)
 							HAL_STATUS_FAILED);
 }
 
+static void bt_audio_close(const void *buf, uint16_t len)
+{
+	DBG("Not Implemented");
+
+	audio_ipc_send_rsp(AUDIO_SERVICE_ID_CORE, AUDIO_OP_CLOSE,
+							HAL_STATUS_FAILED);
+}
+
 static const struct ipc_handler audio_handlers[] = {
 	/* AUDIO_OP_OPEN */
 	{ bt_audio_open, true, sizeof(struct audio_cmd_open) },
+	/* AUDIO_OP_CLOSE */
+	{ bt_audio_close, false, sizeof(struct audio_cmd_close) },
 };
 
 bool bt_a2dp_register(const bdaddr_t *addr)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 1036988..d1135df 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -588,3 +588,8 @@ struct audio_cmd_open {
 struct audio_rsp_open {
 	uint8_t id;
 } __attribute__((packed));
+
+#define AUDIO_OP_CLOSE				0x02
+struct audio_cmd_close {
+	uint8_t id;
+} __attribute__((packed));
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH BlueZ 05/10] android/A2DP: Add audio open command/response struct
From: Luiz Augusto von Dentz @ 2013-12-31 11:29 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388489402-8919-1-git-send-email-luiz.dentz@gmail.com>

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

This adds the definitions to audio open command and response.
---
 android/a2dp.c            | 10 ++++++++++
 android/audio-ipc-api.txt |  2 +-
 android/hal-msg.h         | 18 ++++++++++++++++++
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/android/a2dp.c b/android/a2dp.c
index 7550644..325c282 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -352,7 +352,17 @@ static sdp_record_t *a2dp_record(void)
 	return record;
 }
 
+static void bt_audio_open(const void *buf, uint16_t len)
+{
+	DBG("Not Implemented");
+
+	audio_ipc_send_rsp(AUDIO_SERVICE_ID_CORE, AUDIO_OP_OPEN,
+							HAL_STATUS_FAILED);
+}
+
 static const struct ipc_handler audio_handlers[] = {
+	/* AUDIO_OP_OPEN */
+	{ bt_audio_open, true, sizeof(struct audio_cmd_open) },
 };
 
 bool bt_a2dp_register(const bdaddr_t *addr)
diff --git a/android/audio-ipc-api.txt b/android/audio-ipc-api.txt
index 1c42800..37a1569 100644
--- a/android/audio-ipc-api.txt
+++ b/android/audio-ipc-api.txt
@@ -49,9 +49,9 @@ Identifier: "audio" (BT_AUDIO_ID)
 
 		Command parameters: Service UUID (16 octets)
 				    Codec ID (1 octet)
+				    Number of codec presets (1 octet)
 				    Codec capabilities length (1 octet)
 				    Codec capabilities (variable)
-				    Number of codec presets (1 octet)
 				    Codec preset # length (1 octet)
 				    Codec preset # configuration (variable)
 				    ...
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 267f9b2..1036988 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -570,3 +570,21 @@ struct hal_ev_a2dp_audio_state {
 	uint8_t state;
 	uint8_t bdaddr[6];
 } __attribute__((packed));
+
+#define AUDIO_OP_OPEN				0x01
+struct audio_preset {
+	uint8_t len;
+	uint8_t data[0];
+} __attribute__((packed));
+
+struct audio_cmd_open {
+	uint16_t uuid;
+	uint8_t codec;
+	uint8_t presets;
+	uint8_t len;
+	struct audio_preset preset[0];
+} __attribute__((packed));
+
+struct audio_rsp_open {
+	uint8_t id;
+} __attribute__((packed));
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH BlueZ 04/10] android/A2DP: Add initial code to handle audio IPC commands
From: Luiz Augusto von Dentz @ 2013-12-31 11:29 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388489402-8919-1-git-send-email-luiz.dentz@gmail.com>

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

This adds initial code to handle audio IPC commands.
---
 android/a2dp.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/android/a2dp.c b/android/a2dp.c
index 581d094..7550644 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -352,6 +352,9 @@ static sdp_record_t *a2dp_record(void)
 	return record;
 }
 
+static const struct ipc_handler audio_handlers[] = {
+};
+
 bool bt_a2dp_register(const bdaddr_t *addr)
 {
 	GError *err = NULL;
@@ -359,6 +362,8 @@ bool bt_a2dp_register(const bdaddr_t *addr)
 
 	DBG("");
 
+	audio_ipc_init();
+
 	bacpy(&adapter_addr, addr);
 
 	server = bt_io_listen(connect_cb, NULL, NULL, NULL, &err,
@@ -388,6 +393,9 @@ bool bt_a2dp_register(const bdaddr_t *addr)
 	ipc_register(HAL_SERVICE_ID_A2DP, cmd_handlers,
 						G_N_ELEMENTS(cmd_handlers));
 
+	audio_ipc_register(AUDIO_SERVICE_ID_CORE, audio_handlers,
+						G_N_ELEMENTS(audio_handlers));
+
 	return true;
 
 fail:
@@ -411,8 +419,9 @@ void bt_a2dp_unregister(void)
 	g_slist_foreach(devices, a2dp_device_disconnected, NULL);
 	devices = NULL;
 
-
 	ipc_unregister(HAL_SERVICE_ID_A2DP);
+	audio_ipc_unregister(AUDIO_SERVICE_ID_CORE);
+
 	bt_adapter_remove_record(record_id);
 	record_id = 0;
 
@@ -421,4 +430,6 @@ void bt_a2dp_unregister(void)
 		g_io_channel_unref(server);
 		server = NULL;
 	}
+
+	audio_ipc_cleanup();
 }
-- 
1.8.4.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