* Re: [RFC 07/11] android/tester: Execute hh connection state cbacks in main loop
From: Tyszkowski Jakub @ 2014-02-19 11:54 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: BlueZ development
In-Reply-To: <CAJdJm_Mh-vZ2ieKJq_CWao43ticSu++JTdvDwraHODFB_U76dA@mail.gmail.com>
Hi Anderson,
On 02/19/2014 12:25 PM, Anderson Lizardo wrote:
> Hi Jakub,
>
> On Wed, Feb 19, 2014 at 6:25 AM, Jakub Tyszkowski
> <jakub.tyszkowski@tieto.com> wrote:
>> Execute generic HIDHost connection_state_cb in tester's main loop.
>> ---
>> android/android-tester.c | 23 +++++++++++++++++++----
>> 1 file changed, 19 insertions(+), 4 deletions(-)
>>
>> diff --git a/android/android-tester.c b/android/android-tester.c
>> index 0115943..664f381 100644
>> --- a/android/android-tester.c
>> +++ b/android/android-tester.c
>> @@ -3212,19 +3212,34 @@ clean:
>> close(sock_fd);
>> }
>>
>> -static void hidhost_connection_state_cb(bt_bdaddr_t *bd_addr,
>> - bthh_connection_state_t state)
>> +static gboolean hidhost_connection_state(gpointer user_data)
>> {
>> struct test_data *data = tester_get_data();
>> const struct hidhost_generic_data *test = data->test_data;
>> + struct generic_cb_data *cb_data = user_data;
>>
>> data->cb_count++;
>>
>> - if (state == BTHH_CONN_STATE_CONNECTED)
>> + if ((int) cb_data->state == BTHH_CONN_STATE_CONNECTED)
>
> You are reusing a variable of different type (bt_state_t vs.
> bthh_connection_state_t), so I believe it's why you are casting above.
>
> My suggestion (if that works) is to declare the state field in
> generic_cb_data as int, so it should work without any casting.
>
> Best Regards,
>
Yeap, we could probably use int or add more fields to this struct. But
it would probably be better to replace single generic_cb_data with per
HAL struct like bt_cb_data and hh_cb_data. It would be more elegant.
Best regards,
Jakub Tyszkowski
^ permalink raw reply
* Re: [RFC 10/11] android/tester: Execute hh report cbacks in main loop
From: Anderson Lizardo @ 2014-02-19 11:50 UTC (permalink / raw)
To: Jakub Tyszkowski; +Cc: BlueZ development
In-Reply-To: <1392805549-28152-11-git-send-email-jakub.tyszkowski@tieto.com>
Hi Jakub,
On Wed, Feb 19, 2014 at 6:25 AM, Jakub Tyszkowski
<jakub.tyszkowski@tieto.com> wrote:
> Execute HIDHost generic get_report_cb in tester's main loop.
> ---
> android/android-tester.c | 25 +++++++++++++++++++++----
> 1 file changed, 21 insertions(+), 4 deletions(-)
>
> diff --git a/android/android-tester.c b/android/android-tester.c
> index 1e1d9aa..2bf897d 100644
> --- a/android/android-tester.c
> +++ b/android/android-tester.c
> @@ -129,6 +129,7 @@ struct generic_cb_data {
>
> bthh_hid_info_t hid_info;
> bthh_protocol_mode_t mode;
> + uint8_t report;
> };
>
> static char exec_dir[PATH_MAX + 1];
> @@ -3311,17 +3312,33 @@ static void hidhost_protocol_mode_cb(bt_bdaddr_t *bd_addr,
> g_idle_add(hidhost_protocol_mode, cb_data);
> }
>
> -static void hidhost_get_report_cb(bt_bdaddr_t *bd_addr, bthh_status_t status,
> - uint8_t *report, int size)
> +static gboolean hidhost_get_report(gpointer user_data)
> {
> struct test_data *data = tester_get_data();
> const struct hidhost_generic_data *test = data->test_data;
> + struct generic_cb_data *cb_data = user_data;
>
> data->cb_count++;
>
> if (test && test->expected_hal_cb.get_report_cb)
> - test->expected_hal_cb.get_report_cb(bd_addr, status, report,
> - size);
> + test->expected_hal_cb.get_report_cb(&cb_data->bdaddr,
> + cb_data->status, &cb_data->report, cb_data->num);
> +
> + g_free(cb_data);
> + return FALSE;
> +}
> +
> +static void hidhost_get_report_cb(bt_bdaddr_t *bd_addr, bthh_status_t status,
> + uint8_t *report, int size)
> +{
> + struct generic_cb_data *cb_data = g_new0(struct generic_cb_data, 1);
> +
> + cb_data->bdaddr = *bd_addr;
> + cb_data->status = status;
> + cb_data->report = *report;
> + cb_data->num = size;
Shouldn't cb_data->report be an array allocated with g_memdup()?
> +
> + g_idle_add(hidhost_get_report, cb_data);
> }
Best Regards,
--
Anderson Lizardo
http://www.indt.org/?lang=en
INdT - Manaus - Brazil
^ permalink raw reply
* Re: [RFC 07/11] android/tester: Execute hh connection state cbacks in main loop
From: Anderson Lizardo @ 2014-02-19 11:25 UTC (permalink / raw)
To: Jakub Tyszkowski; +Cc: BlueZ development
In-Reply-To: <1392805549-28152-8-git-send-email-jakub.tyszkowski@tieto.com>
Hi Jakub,
On Wed, Feb 19, 2014 at 6:25 AM, Jakub Tyszkowski
<jakub.tyszkowski@tieto.com> wrote:
> Execute generic HIDHost connection_state_cb in tester's main loop.
> ---
> android/android-tester.c | 23 +++++++++++++++++++----
> 1 file changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/android/android-tester.c b/android/android-tester.c
> index 0115943..664f381 100644
> --- a/android/android-tester.c
> +++ b/android/android-tester.c
> @@ -3212,19 +3212,34 @@ clean:
> close(sock_fd);
> }
>
> -static void hidhost_connection_state_cb(bt_bdaddr_t *bd_addr,
> - bthh_connection_state_t state)
> +static gboolean hidhost_connection_state(gpointer user_data)
> {
> struct test_data *data = tester_get_data();
> const struct hidhost_generic_data *test = data->test_data;
> + struct generic_cb_data *cb_data = user_data;
>
> data->cb_count++;
>
> - if (state == BTHH_CONN_STATE_CONNECTED)
> + if ((int) cb_data->state == BTHH_CONN_STATE_CONNECTED)
You are reusing a variable of different type (bt_state_t vs.
bthh_connection_state_t), so I believe it's why you are casting above.
My suggestion (if that works) is to declare the state field in
generic_cb_data as int, so it should work without any casting.
Best Regards,
--
Anderson Lizardo
http://www.indt.org/?lang=en
INdT - Manaus - Brazil
^ permalink raw reply
* [PATCH] emulator/bthost: Fix command queue
From: Marcin Kraglak @ 2014-02-19 10:26 UTC (permalink / raw)
To: linux-bluetooth
Now new commands will be pushed to tail. Queue will be consumed
from head, firstly added commands will be sent. In previous solution
some queued commands were not freed. It repairs this warning
from android-tester:
==20561== 1,904 bytes in 7 blocks are definitely
lost in loss record 30 of 31
==20561== at 0x4006AB1: malloc (in /usr/lib/valgrind/
vgpreload_memcheck-x86-linux.so)
==20561== by 0x8050293: send_command (bthost.c:389)
==20561== by 0x80543E1: start_stack (hciemu.c:299)
==20561== by 0x41043D00: ??? (in /usr/lib/libglib-2.0.so.0.3600.4)
==20561== by 0x410470E5: g_main_context_dispatch (in
/usr/lib/libglib-2.0.so.0.3600.4)
==20561== by 0x41047497: ??? (in
/usr/lib/libglib-2.0.so.0.3600.4)
==20561== by 0x41047912: g_main_loop_run (in
/usr/lib/libglib-2.0.so.0.3600.4)
==20561== by 0x8055870: tester_run (tester.c:798)
==20561== by 0x804B980: main (android-tester.c:3984)
---
emulator/bthost.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/emulator/bthost.c b/emulator/bthost.c
index 6fbabe8..aa8cc79 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -331,7 +331,7 @@ void bthost_destroy(struct bthost *bthost)
while (bthost->cmd_q.tail) {
struct cmd *cmd = bthost->cmd_q.tail;
- bthost->cmd_q.tail = cmd->next;
+ bthost->cmd_q.tail = cmd->prev;
free(cmd);
}
@@ -397,6 +397,8 @@ static void queue_command(struct bthost *bthost, const void *data,
if (cmd_q->tail)
cmd_q->tail->next = cmd;
+ else
+ cmd_q->head = cmd;
cmd->prev = cmd_q->tail;
cmd_q->tail = cmd;
@@ -598,7 +600,7 @@ static void send_command(struct bthost *bthost, uint16_t opcode,
static void next_cmd(struct bthost *bthost)
{
struct cmd_queue *cmd_q = &bthost->cmd_q;
- struct cmd *cmd = cmd_q->tail;
+ struct cmd *cmd = cmd_q->head;
struct cmd *next;
if (!cmd)
@@ -614,8 +616,10 @@ static void next_cmd(struct bthost *bthost)
if (next)
next->prev = NULL;
+ else
+ cmd_q->tail = NULL;
- cmd_q->tail = next;
+ cmd_q->head = next;
free(cmd);
}
--
1.8.3.1
^ permalink raw reply related
* [RFC 11/11] android/tester: Execute hh virtual unpluged cbacks in main loop
From: Jakub Tyszkowski @ 2014-02-19 10:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1392805549-28152-1-git-send-email-jakub.tyszkowski@tieto.com>
Execute generic HIDHost virtual_unplug_cb in tester's main loop.
---
android/android-tester.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index 2bf897d..945af4b 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -3246,15 +3246,30 @@ static void hidhost_connection_state_cb(bt_bdaddr_t *bd_addr,
g_idle_add(hidhost_connection_state, cb_data);
}
-static void hidhost_virual_unplug_cb(bt_bdaddr_t *bd_addr, bthh_status_t status)
+static gboolean hidhost_virual_unplug(gpointer user_data)
{
struct test_data *data = tester_get_data();
const struct hidhost_generic_data *test = data->test_data;
+ struct generic_cb_data *cb_data = user_data;
data->cb_count++;
if (test && test->expected_hal_cb.virtual_unplug_cb)
- test->expected_hal_cb.virtual_unplug_cb(bd_addr, status);
+ test->expected_hal_cb.virtual_unplug_cb(&cb_data->bdaddr,
+ cb_data->status);
+
+ g_free(cb_data);
+ return FALSE;
+}
+
+static void hidhost_virual_unplug_cb(bt_bdaddr_t *bd_addr, bthh_status_t status)
+{
+ struct generic_cb_data *cb_data = g_new0(struct generic_cb_data, 1);
+
+ cb_data->bdaddr = *bd_addr;
+ cb_data->status = status;
+
+ g_idle_add(hidhost_virual_unplug, cb_data);
}
static gboolean hidhost_hid_info(gpointer user_data)
--
1.8.5.2
^ permalink raw reply related
* [RFC 10/11] android/tester: Execute hh report cbacks in main loop
From: Jakub Tyszkowski @ 2014-02-19 10:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1392805549-28152-1-git-send-email-jakub.tyszkowski@tieto.com>
Execute HIDHost generic get_report_cb in tester's main loop.
---
android/android-tester.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index 1e1d9aa..2bf897d 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -129,6 +129,7 @@ struct generic_cb_data {
bthh_hid_info_t hid_info;
bthh_protocol_mode_t mode;
+ uint8_t report;
};
static char exec_dir[PATH_MAX + 1];
@@ -3311,17 +3312,33 @@ static void hidhost_protocol_mode_cb(bt_bdaddr_t *bd_addr,
g_idle_add(hidhost_protocol_mode, cb_data);
}
-static void hidhost_get_report_cb(bt_bdaddr_t *bd_addr, bthh_status_t status,
- uint8_t *report, int size)
+static gboolean hidhost_get_report(gpointer user_data)
{
struct test_data *data = tester_get_data();
const struct hidhost_generic_data *test = data->test_data;
+ struct generic_cb_data *cb_data = user_data;
data->cb_count++;
if (test && test->expected_hal_cb.get_report_cb)
- test->expected_hal_cb.get_report_cb(bd_addr, status, report,
- size);
+ test->expected_hal_cb.get_report_cb(&cb_data->bdaddr,
+ cb_data->status, &cb_data->report, cb_data->num);
+
+ g_free(cb_data);
+ return FALSE;
+}
+
+static void hidhost_get_report_cb(bt_bdaddr_t *bd_addr, bthh_status_t status,
+ uint8_t *report, int size)
+{
+ struct generic_cb_data *cb_data = g_new0(struct generic_cb_data, 1);
+
+ cb_data->bdaddr = *bd_addr;
+ cb_data->status = status;
+ cb_data->report = *report;
+ cb_data->num = size;
+
+ g_idle_add(hidhost_get_report, cb_data);
}
static bthh_callbacks_t bthh_callbacks = {
--
1.8.5.2
^ permalink raw reply related
* [RFC 09/11] android/tester: Execute hh protocol mode cbacks in main loop
From: Jakub Tyszkowski @ 2014-02-19 10:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1392805549-28152-1-git-send-email-jakub.tyszkowski@tieto.com>
Execute generic HIDHost protocol_mode_cb in tester's main loop.
---
android/android-tester.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index 77fa437..1e1d9aa 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -128,6 +128,7 @@ struct generic_cb_data {
bt_property_t *props;
bthh_hid_info_t hid_info;
+ bthh_protocol_mode_t mode;
};
static char exec_dir[PATH_MAX + 1];
@@ -3281,17 +3282,33 @@ static void hidhost_hid_info_cb(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid)
g_idle_add(hidhost_hid_info, cb_data);
}
-static void hidhost_protocol_mode_cb(bt_bdaddr_t *bd_addr,
- bthh_status_t status,
- bthh_protocol_mode_t mode)
+static gboolean hidhost_protocol_mode(gpointer user_data)
{
struct test_data *data = tester_get_data();
const struct hidhost_generic_data *test = data->test_data;
+ struct generic_cb_data *cb_data = user_data;
data->cb_count++;
if (test && test->expected_hal_cb.protocol_mode_cb)
- test->expected_hal_cb.protocol_mode_cb(bd_addr, status, mode);
+ test->expected_hal_cb.protocol_mode_cb(&cb_data->bdaddr,
+ cb_data->status, cb_data->mode);
+
+ g_free(cb_data);
+ return FALSE;
+}
+
+static void hidhost_protocol_mode_cb(bt_bdaddr_t *bd_addr,
+ bthh_status_t status,
+ bthh_protocol_mode_t mode)
+{
+ struct generic_cb_data *cb_data = g_new0(struct generic_cb_data, 1);
+
+ cb_data->bdaddr = *bd_addr;
+ cb_data->status = status;
+ cb_data->mode = mode;
+
+ g_idle_add(hidhost_protocol_mode, cb_data);
}
static void hidhost_get_report_cb(bt_bdaddr_t *bd_addr, bthh_status_t status,
--
1.8.5.2
^ permalink raw reply related
* [RFC 08/11] android/tester: Execute hh info cbacks in main loop
From: Jakub Tyszkowski @ 2014-02-19 10:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1392805549-28152-1-git-send-email-jakub.tyszkowski@tieto.com>
Execute generic HIDHost hid_info_cb in tester's main loop.
---
android/android-tester.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index 664f381..77fa437 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -126,6 +126,8 @@ struct generic_cb_data {
int num;
bt_property_t *props;
+
+ bthh_hid_info_t hid_info;
};
static char exec_dir[PATH_MAX + 1];
@@ -3253,15 +3255,30 @@ static void hidhost_virual_unplug_cb(bt_bdaddr_t *bd_addr, bthh_status_t status)
test->expected_hal_cb.virtual_unplug_cb(bd_addr, status);
}
-static void hidhost_hid_info_cb(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid)
+static gboolean hidhost_hid_info(gpointer user_data)
{
struct test_data *data = tester_get_data();
const struct hidhost_generic_data *test = data->test_data;
+ struct generic_cb_data *cb_data = user_data;
data->cb_count++;
if (test && test->expected_hal_cb.hid_info_cb)
- test->expected_hal_cb.hid_info_cb(bd_addr, hid);
+ test->expected_hal_cb.hid_info_cb(&cb_data->bdaddr,
+ cb_data->hid_info);
+
+ g_free(cb_data);
+ return FALSE;
+}
+
+static void hidhost_hid_info_cb(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid)
+{
+ struct generic_cb_data *cb_data = g_new0(struct generic_cb_data, 1);
+
+ cb_data->bdaddr = *bd_addr;
+ cb_data->hid_info = hid;
+
+ g_idle_add(hidhost_hid_info, cb_data);
}
static void hidhost_protocol_mode_cb(bt_bdaddr_t *bd_addr,
--
1.8.5.2
^ permalink raw reply related
* [RFC 07/11] android/tester: Execute hh connection state cbacks in main loop
From: Jakub Tyszkowski @ 2014-02-19 10:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1392805549-28152-1-git-send-email-jakub.tyszkowski@tieto.com>
Execute generic HIDHost connection_state_cb in tester's main loop.
---
android/android-tester.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index 0115943..664f381 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -3212,19 +3212,34 @@ clean:
close(sock_fd);
}
-static void hidhost_connection_state_cb(bt_bdaddr_t *bd_addr,
- bthh_connection_state_t state)
+static gboolean hidhost_connection_state(gpointer user_data)
{
struct test_data *data = tester_get_data();
const struct hidhost_generic_data *test = data->test_data;
+ struct generic_cb_data *cb_data = user_data;
data->cb_count++;
- if (state == BTHH_CONN_STATE_CONNECTED)
+ if ((int) cb_data->state == BTHH_CONN_STATE_CONNECTED)
tester_setup_complete();
if (test && test->expected_hal_cb.connection_state_cb)
- test->expected_hal_cb.connection_state_cb(bd_addr, state);
+ test->expected_hal_cb.connection_state_cb(&cb_data->bdaddr,
+ cb_data->state);
+
+ g_free(cb_data);
+ return FALSE;
+}
+
+static void hidhost_connection_state_cb(bt_bdaddr_t *bd_addr,
+ bthh_connection_state_t state)
+{
+ struct generic_cb_data *cb_data = g_new0(struct generic_cb_data, 1);
+
+ cb_data->state = state;
+ cb_data->bdaddr = *bd_addr;
+
+ g_idle_add(hidhost_connection_state, cb_data);
}
static void hidhost_virual_unplug_cb(bt_bdaddr_t *bd_addr, bthh_status_t status)
--
1.8.5.2
^ permalink raw reply related
* [RFC 06/11] android/tester: Execute socket cbacks in main loop
From: Jakub Tyszkowski @ 2014-02-19 10:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1392805549-28152-1-git-send-email-jakub.tyszkowski@tieto.com>
Execute socket test's callbacks in tester's main loop.
---
android/android-tester.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index 50de998..0115943 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -2780,9 +2780,11 @@ static void test_dev_setprop_disctimeout_fail(const void *test_data)
}
/* Test Socket HAL */
-static void adapter_socket_state_changed_cb(bt_state_t state)
+static gboolean adapter_socket_state_changed(gpointer user_data)
{
- switch (state) {
+ struct generic_cb_data *cb_data = user_data;
+
+ switch (cb_data->state) {
case BT_STATE_ON:
setup_powered_emulated_remote();
break;
@@ -2792,6 +2794,19 @@ static void adapter_socket_state_changed_cb(bt_state_t state)
default:
break;
}
+
+ g_free(cb_data);
+
+ return FALSE;
+}
+
+static void adapter_socket_state_changed_cb(bt_state_t state)
+{
+ struct generic_cb_data *cb_data = g_new0(struct generic_cb_data, 1);
+
+ cb_data->state = state;
+
+ g_idle_add(adapter_socket_state_changed, cb_data);
}
const bt_bdaddr_t bdaddr_dummy = {
--
1.8.5.2
^ permalink raw reply related
* [RFC 05/11] android/tester: Execute adapter state changed cbacks in main loop
From: Jakub Tyszkowski @ 2014-02-19 10:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1392805549-28152-1-git-send-email-jakub.tyszkowski@tieto.com>
Execute generic adapter_state_changed_cb in tester's main loop.
---
android/android-tester.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index 334e7f3..50de998 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -600,19 +600,33 @@ static void disable_success_cb(bt_state_t state)
}
}
-static void adapter_state_changed_cb(bt_state_t state)
+static gboolean adapter_state_changed(gpointer user_data)
{
struct test_data *data = tester_get_data();
const struct generic_data *test = data->test_data;
+ struct generic_cb_data *cb_data = user_data;
if (data->test_init_done &&
test->expected_hal_cb.adapter_state_changed_cb) {
- test->expected_hal_cb.adapter_state_changed_cb(state);
- return;
+ test->expected_hal_cb.adapter_state_changed_cb(cb_data->state);
+ goto cleanup;
}
- if (!data->test_init_done && state == BT_STATE_ON)
+ if (!data->test_init_done && cb_data->state == BT_STATE_ON)
setup_powered_emulated_remote();
+
+cleanup:
+ g_free(cb_data);
+ return FALSE;
+}
+
+static void adapter_state_changed_cb(bt_state_t state)
+{
+ struct generic_cb_data *cb_data = g_new0(struct generic_cb_data, 1);
+
+ cb_data->state = state;
+
+ g_idle_add(adapter_state_changed, cb_data);
}
static void discovery_start_success_cb(bt_discovery_state_t state)
--
1.8.5.2
^ permalink raw reply related
* [RFC 04/11] android/tester: Execute adapter props cbacks in main loop
From: Jakub Tyszkowski @ 2014-02-19 10:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1392805549-28152-1-git-send-email-jakub.tyszkowski@tieto.com>
Execute generic adapter_properties_cb in tester's main loop.
---
android/android-tester.c | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index beeaef4..334e7f3 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -916,19 +916,32 @@ static void check_count_properties_cb(bt_status_t status, int num_properties,
check_expected_property(properties[i]);
}
+static gboolean adapter_properties(gpointer user_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ struct generic_cb_data *cb_data = user_data;
+
+ if (data->test_init_done && test->expected_hal_cb.adapter_properties_cb)
+ test->expected_hal_cb.adapter_properties_cb(cb_data->status,
+ cb_data->num, cb_data->props);
+
+ free_properties(cb_data->num, cb_data->props);
+ g_free(cb_data);
+
+ return FALSE;
+}
static void adapter_properties_cb(bt_status_t status, int num_properties,
bt_property_t *properties)
{
- struct test_data *data = tester_get_data();
- const struct generic_data *test = data->test_data;
+ struct generic_cb_data *cb_data = g_new0(struct generic_cb_data, 1);
- if (data->test_init_done &&
- test->expected_hal_cb.adapter_properties_cb) {
- test->expected_hal_cb.adapter_properties_cb(
- status, num_properties,
- properties);
- }
+ cb_data->status = status;
+ cb_data->num = num_properties;
+ cb_data->props = copy_properties(num_properties, properties);
+
+ g_idle_add(adapter_properties, cb_data);
}
static void remote_test_device_properties_cb(bt_status_t status,
--
1.8.5.2
^ permalink raw reply related
* [RFC 03/11] android/tester: Execute device properties cbacks in main loop
From: Jakub Tyszkowski @ 2014-02-19 10:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1392805549-28152-1-git-send-email-jakub.tyszkowski@tieto.com>
Execute generic remote_device_properties_cb in tester's main loop.
---
android/android-tester.c | 32 +++++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 7 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index 3693ec5..beeaef4 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -964,18 +964,36 @@ static void remote_setprop_device_properties_cb(bt_status_t status,
}
}
-static void remote_device_properties_cb(bt_status_t status,
- bt_bdaddr_t *bd_addr, int num_properties,
- bt_property_t *properties)
+static gboolean remote_device_properties(gpointer user_data)
{
struct test_data *data = tester_get_data();
const struct generic_data *test = data->test_data;
+ struct generic_cb_data *cb_data = user_data;
if (data->test_init_done &&
- test->expected_hal_cb.remote_device_properties_cb) {
- test->expected_hal_cb.remote_device_properties_cb(status,
- bd_addr, num_properties, properties);
- }
+ test->expected_hal_cb.remote_device_properties_cb)
+ test->expected_hal_cb.remote_device_properties_cb(
+ cb_data->status, &cb_data->bdaddr,
+ cb_data->num, cb_data->props);
+
+ free_properties(cb_data->num, cb_data->props);
+ g_free(cb_data);
+
+ return FALSE;
+}
+
+static void remote_device_properties_cb(bt_status_t status,
+ bt_bdaddr_t *bd_addr, int num_properties,
+ bt_property_t *properties)
+{
+ struct generic_cb_data *cb_data = g_new0(struct generic_cb_data, 1);
+
+ cb_data->status = status;
+ cb_data->bdaddr = *bd_addr;
+ cb_data->num = num_properties;
+ cb_data->props = copy_properties(num_properties, properties);
+
+ g_idle_add(remote_device_properties, cb_data);
}
static bt_bdaddr_t enable_done_bdaddr_val = { {0x00} };
--
1.8.5.2
^ permalink raw reply related
* [RFC 02/11] android/tester: Execute discovery state cbacks in main loop
From: Jakub Tyszkowski @ 2014-02-19 10:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1392805549-28152-1-git-send-email-jakub.tyszkowski@tieto.com>
Execute generic discovery_state_changed_cb in tester's main loop.
---
android/android-tester.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index adde5ea..3693ec5 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -696,14 +696,27 @@ static void remote_setprop_disc_state_changed_cb(bt_discovery_state_t state)
}
}
-static void discovery_state_changed_cb(bt_discovery_state_t state)
+static gboolean discovery_state_changed(gpointer user_data)
{
struct test_data *data = tester_get_data();
const struct generic_data *test = data->test_data;
+ struct generic_cb_data *cb_data = user_data;
- if (test && test->expected_hal_cb.discovery_state_changed_cb) {
- test->expected_hal_cb.discovery_state_changed_cb(state);
- }
+ if (test && test->expected_hal_cb.discovery_state_changed_cb)
+ test->expected_hal_cb.discovery_state_changed_cb(
+ cb_data->state);
+
+ g_free(cb_data);
+
+ return FALSE;
+}
+
+static void discovery_state_changed_cb(bt_discovery_state_t state)
+{
+ struct generic_cb_data *cb_data = g_new0(struct generic_cb_data, 1);
+
+ cb_data->state = state;
+ g_idle_add(discovery_state_changed, cb_data);
}
static bt_property_t *copy_properties(int num_properties,
--
1.8.5.2
^ permalink raw reply related
* [RFC 01/11] android/tester: Execute device found cbacks in main loop
From: Jakub Tyszkowski @ 2014-02-19 10:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1392805549-28152-1-git-send-email-jakub.tyszkowski@tieto.com>
Execute generic device_found_cb in tester's main loop.
---
android/android-tester.c | 61 ++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 56 insertions(+), 5 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index 9605c4d..adde5ea 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -117,6 +117,17 @@ struct test_data {
uint16_t intr_cid;
};
+struct generic_cb_data {
+ bt_state_t state;
+ bt_status_t status;
+
+ bt_bdaddr_t bdaddr;
+ bt_bdname_t bdname;
+
+ int num;
+ bt_property_t *props;
+};
+
static char exec_dir[PATH_MAX + 1];
static void mgmt_debug(const char *str, void *user_data)
@@ -695,6 +706,31 @@ static void discovery_state_changed_cb(bt_discovery_state_t state)
}
}
+static bt_property_t *copy_properties(int num_properties,
+ bt_property_t *properties)
+{
+ int i;
+ bt_property_t *props = g_new0(bt_property_t, num_properties);
+
+ for (i = 0; i < num_properties; i++) {
+ props[i].type = properties[i].type;
+ props[i].len = properties[i].len;
+ props[i].val = g_memdup(properties[i].val, properties[i].len);
+ }
+
+ return props;
+}
+
+static void free_properties(int num_properties, bt_property_t *properties)
+{
+ int i;
+
+ for (i = 0; i < num_properties; i++)
+ g_free(properties[i].val);
+
+ g_free(properties);
+}
+
static void discovery_device_found_cb(int num_properties,
bt_property_t *properties)
{
@@ -832,15 +868,30 @@ static void remote_setprop_fail_device_found_cb(int num_properties,
check_expected_status(status);
}
-static void device_found_cb(int num_properties, bt_property_t *properties)
+static gboolean device_found(gpointer user_data)
{
struct test_data *data = tester_get_data();
const struct generic_data *test = data->test_data;
+ struct generic_cb_data *cb_data = user_data;
- if (data->test_init_done && test->expected_hal_cb.device_found_cb) {
- test->expected_hal_cb.device_found_cb(num_properties,
- properties);
- }
+ if (data->test_init_done && test->expected_hal_cb.device_found_cb)
+ test->expected_hal_cb.device_found_cb(cb_data->num,
+ cb_data->props);
+
+ free_properties(cb_data->num, cb_data->props);
+ g_free(cb_data);
+
+ return FALSE;
+}
+
+static void device_found_cb(int num_properties, bt_property_t *properties)
+{
+ struct generic_cb_data *cb_data = g_new0(struct generic_cb_data, 1);
+
+ cb_data->num = num_properties;
+ cb_data->props = copy_properties(num_properties, properties);
+
+ g_idle_add(device_found, cb_data);
}
static void check_count_properties_cb(bt_status_t status, int num_properties,
--
1.8.5.2
^ permalink raw reply related
* [RFC 00/11] Make android-tester callback thread safe
From: Jakub Tyszkowski @ 2014-02-19 10:25 UTC (permalink / raw)
To: linux-bluetooth
This patch set makes all callbacks executions in HAL's notification thread being
transfered to tester's context. As test-specific callbacks are called by generic
callbacks, making the later executed in tester's main loop makes all custom
callbacks (and newly added) automatically executed in the right contex.
Forking out the emulator to be controlled over IPC makes finer controll harder
and requires IPC extensions when new functionality is required. It also adds
extra complexity.
Our initial 'IPC' solution creates additional ~800 lines of code to maintain in
comparison to ~250 added by this simplier 'main loop' solution.
Please state your's opinions on these options.
Best regards,
Jakub Tyszkowski (11):
android/tester: Execute device found cbacks in main loop
android/tester: Execute discovery state cbacks in main loop
android/tester: Execute device properties cbacks in main loop
android/tester: Execute adapter props cbacks in main loop
android/tester: Execute adapter state changed cbacks in main loop
android/tester: Execute socket cbacks in main loop
android/tester: Execute hh connection state cbacks in main loop
android/tester: Execute hh info cbacks in main loop
android/tester: Execute hh protocol mode cbacks in main loop
android/tester: Execute hh report cbacks in main loop
android/tester: Execute hh virtual unpluged cbacks in main loop
android/android-tester.c | 295 +++++++++++++++++++++++++++++++++++++++--------
1 file changed, 250 insertions(+), 45 deletions(-)
--
1.8.5.2
^ permalink raw reply
* [PATCHv5] hog: Use HoG device name as uHID input device name
From: Petri Gynther @ 2014-02-19 7:40 UTC (permalink / raw)
To: linux-bluetooth
---
profiles/input/hog.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/profiles/input/hog.c b/profiles/input/hog.c
index ded6303..b9a14b9 100644
--- a/profiles/input/hog.c
+++ b/profiles/input/hog.c
@@ -91,6 +91,7 @@ struct hog_device {
uint16_t proto_mode_handle;
uint16_t ctrlpt_handle;
uint8_t flags;
+ char *name;
};
struct report {
@@ -392,7 +393,9 @@ static void report_map_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
/* create uHID device */
memset(&ev, 0, sizeof(ev));
ev.type = UHID_CREATE;
- strcpy((char *) ev.u.create.name, "bluez-hog-device");
+ strncpy((char *) ev.u.create.name, hogdev->name ?
+ hogdev->name : "bluez-hog-device",
+ sizeof(ev.u.create.name) - 1);
ev.u.create.vendor = vendor;
ev.u.create.product = product;
ev.u.create.version = version;
@@ -722,6 +725,7 @@ static struct hog_device *hog_new_device(struct btd_device *device,
uint16_t id)
{
struct hog_device *hogdev;
+ char name[HCI_MAX_NAME_LENGTH + 1];
hogdev = g_try_new0(struct hog_device, 1);
if (!hogdev)
@@ -729,6 +733,9 @@ static struct hog_device *hog_new_device(struct btd_device *device,
hogdev->id = id;
hogdev->device = btd_device_ref(device);
+ device_get_name(device, name, sizeof(name));
+ if (strlen(name) > 0)
+ hogdev->name = g_strdup(name);
return hogdev;
}
@@ -751,6 +758,7 @@ static void hog_free_device(struct hog_device *hogdev)
g_slist_free_full(hogdev->reports, report_free);
g_attrib_unref(hogdev->attrib);
g_free(hogdev->hog_primary);
+ g_free(hogdev->name);
g_free(hogdev);
}
--
1.9.0.rc1.175.g0b1dcb5
^ permalink raw reply related
* Reg: simple-player issue
From: Pradeep Vivekanandan @ 2014-02-19 7:37 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth@vger.kernel.org
Hi,
I need to get bluetooth metadata information from phone.
I have used RegisterPlayer method in the interface org.bluez.Media1.
But I did not find any signal in the org.bluez.MeidaPlayer1 to get the track information.
Please help me how to get the metadata.
I am using iphone 5 and bluez 5.7 to get the metadata.
Is there any specail package to be install in the iphone to make it work.
Thanks and Regards,
Pradeep V
end
::DISCLAIMER::
----------------------------------------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted,
lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents
(with or without referred errors) shall therefore not attach any liability on the originator or HCL or its affiliates.
Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the
views or opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification,
distribution and / or publication of this message without the prior written consent of authorized representative of
HCL is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately.
Before opening any email and/or attachments, please check them for viruses and other defects.
----------------------------------------------------------------------------------------------------------------------------------------------------
^ permalink raw reply
* Re: [PATCH] Bluetooth: Use same LE min/max connection event length during update
From: Johan Hedberg @ 2014-02-19 6:55 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1392791234-43343-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Tue, Feb 18, 2014, Marcel Holtmann wrote:
> During LE connection establishment the value 0x0000 is used for min/max
> connection event length. So use the same value when the peripheral is
> requesting an update of the the connection paramters.
>
> For some reason the value 0x0001 got used in the connection update and
> 0x0000 in the connection creation. Using the same value for both just
> makes sense.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/hci_conn.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Expose current list of identity resolving keys via debugfs
From: Johan Hedberg @ 2014-02-19 6:55 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1392789289-40436-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Tue, Feb 18, 2014, Marcel Holtmann wrote:
> For debugging purposes expose the current list of identity resolving
> keys via debugfs. This file is read-only and limited to root access.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/hci_core.c | 33 +++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* [PATCH] Bluetooth: Use same LE min/max connection event length during update
From: Marcel Holtmann @ 2014-02-19 6:27 UTC (permalink / raw)
To: linux-bluetooth
During LE connection establishment the value 0x0000 is used for min/max
connection event length. So use the same value when the peripheral is
requesting an update of the the connection paramters.
For some reason the value 0x0001 got used in the connection update and
0x0000 in the connection creation. Using the same value for both just
makes sense.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/hci_conn.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index a027951d0da5..bd66c52eff95 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -225,8 +225,8 @@ void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max,
cp.conn_interval_max = cpu_to_le16(max);
cp.conn_latency = cpu_to_le16(latency);
cp.supervision_timeout = cpu_to_le16(to_multiplier);
- cp.min_ce_len = __constant_cpu_to_le16(0x0001);
- cp.max_ce_len = __constant_cpu_to_le16(0x0001);
+ cp.min_ce_len = __constant_cpu_to_le16(0x0000);
+ cp.max_ce_len = __constant_cpu_to_le16(0x0000);
hci_send_cmd(hdev, HCI_OP_LE_CONN_UPDATE, sizeof(cp), &cp);
}
--
1.8.5.3
^ permalink raw reply related
* [PATCH] Bluetooth: Expose current list of identity resolving keys via debugfs
From: Marcel Holtmann @ 2014-02-19 5:54 UTC (permalink / raw)
To: linux-bluetooth
For debugging purposes expose the current list of identity resolving
keys via debugfs. This file is read-only and limited to root access.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/hci_core.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index e4c5b9d6083c..e8f61b3fe87c 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -599,6 +599,36 @@ static int own_address_type_get(void *data, u64 *val)
DEFINE_SIMPLE_ATTRIBUTE(own_address_type_fops, own_address_type_get,
own_address_type_set, "%llu\n");
+static int identity_resolving_keys_show(struct seq_file *f, void *ptr)
+{
+ struct hci_dev *hdev = f->private;
+ struct list_head *p, *n;
+
+ hci_dev_lock(hdev);
+ list_for_each_safe(p, n, &hdev->identity_resolving_keys) {
+ struct smp_irk *irk = list_entry(p, struct smp_irk, list);
+ seq_printf(f, "%pMR (type %u) %*phN %pMR\n",
+ &irk->bdaddr, irk->addr_type,
+ 16, irk->val, &irk->rpa);
+ }
+ hci_dev_unlock(hdev);
+
+ return 0;
+}
+
+static int identity_resolving_keys_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, identity_resolving_keys_show,
+ inode->i_private);
+}
+
+static const struct file_operations identity_resolving_keys_fops = {
+ .open = identity_resolving_keys_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
static int long_term_keys_show(struct seq_file *f, void *ptr)
{
struct hci_dev *hdev = f->private;
@@ -1512,6 +1542,9 @@ static int __hci_init(struct hci_dev *hdev)
hdev, &static_address_fops);
debugfs_create_file("own_address_type", 0644, hdev->debugfs,
hdev, &own_address_type_fops);
+ debugfs_create_file("identity_resolving_keys", 0400,
+ hdev->debugfs, hdev,
+ &identity_resolving_keys_fops);
debugfs_create_file("long_term_keys", 0400, hdev->debugfs,
hdev, &long_term_keys_fops);
debugfs_create_file("conn_min_interval", 0644, hdev->debugfs,
--
1.8.5.3
^ permalink raw reply related
* Re: [PATCH] core: Fix device_get_name()
From: Johan Hedberg @ 2014-02-19 4:15 UTC (permalink / raw)
To: Petri Gynther; +Cc: linux-bluetooth
In-Reply-To: <20140219004413.4361A1005F0@puck.mtv.corp.google.com>
Hi Petri,
On Tue, Feb 18, 2014, Petri Gynther wrote:
> Fix device_get_name() to null-terminate the name string it returns.
> Modify all callers as needed.
> ---
> plugins/wiimote.c | 1 -
> profiles/input/device.c | 2 +-
> src/device.c | 5 ++++-
> 3 files changed, 5 insertions(+), 3 deletions(-)
Applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Fix wrong identity address during connection failures
From: Johan Hedberg @ 2014-02-19 4:10 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1392765223-21880-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Tue, Feb 18, 2014, Marcel Holtmann wrote:
> When the connection attempt fails, the address information are not
> provided in the HCI_LE_Connection_Complete event. So use the original
> information from the connection to reconstruct the identity address.
>
> This is important when a connection attempt has been made using the
> identity address, but the cached resolvable random address has changed
> in the meantime. The failure event needs to use the identity address
> and not the resolvable random address.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/hci_conn.c | 13 +++++++++++++
> net/bluetooth/hci_event.c | 12 ++++++++++--
> 2 files changed, 23 insertions(+), 2 deletions(-)
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH 1/2] Bluetooth: Report identity address when remote device connects
From: Johan Hedberg @ 2014-02-19 4:09 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1392762140-18655-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Tue, Feb 18, 2014, Marcel Holtmann wrote:
> When the remote device has been successfully connected, report the
> identity address (public address or static random address).
>
> Currently the address from the HCI_LE_Connection_Complete event is
> used. This was no problem so far, but since now known resolvable
> random addresses are converted into identities, it is important to
> use the identity of the connection and not the address report by
> HCI event.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/hci_event.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Both patches have been applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox