* Re: [PATCH BlueZ 03/16] android/avrcp-lib: Rework handler callback parameters
From: Andrei Emeltchenko @ 2014-03-03 9:52 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1393786109-6554-3-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Sun, Mar 02, 2014 at 08:48:18PM +0200, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This rework handler callback parameters to make it able to return
> proper error such as -EAGAIN to implement asynchronous responses.
> ---
> android/avrcp-lib.c | 12 +++++++++---
> android/avrcp-lib.h | 5 +++--
> unit/test-avrcp.c | 42 +++++++++++++++++++++---------------------
> 3 files changed, 33 insertions(+), 26 deletions(-)
>
> diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
> index cdad6ac..339be16 100644
> --- a/android/avrcp-lib.c
> +++ b/android/avrcp-lib.c
> @@ -125,6 +125,7 @@ static ssize_t handle_vendordep_pdu(struct avctp *conn, uint8_t transaction,
> struct avrcp_header *pdu = (void *) operands;
> uint32_t company_id = ntoh24(pdu->company_id);
> uint16_t params_len = ntohs(pdu->params_len);
> + ssize_t ret;
>
> if (company_id != IEEEID_BTSIG) {
> *code = AVC_CTYPE_NOT_IMPLEMENTED;
> @@ -159,12 +160,17 @@ static ssize_t handle_vendordep_pdu(struct avctp *conn, uint8_t transaction,
> goto reject;
> }
>
> - *code = handler->func(session, transaction, ¶ms_len,
> + ret = handler->func(session, transaction, code, params_len,
> pdu->params, session->control_data);
> + if (ret < 0) {
> + if (ret == -EAGAIN)
> + return ret;
> + goto reject;
> + }
>
> - pdu->params_len = htons(params_len);
> + pdu->params_len = htons(ret);
>
> - return AVRCP_HEADER_LENGTH + params_len;
> + return AVRCP_HEADER_LENGTH + ret;
>
> reject:
> pdu->params_len = htons(1);
> diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
> index a33bdfe..d7a805b 100644
> --- a/android/avrcp-lib.h
> +++ b/android/avrcp-lib.h
> @@ -79,8 +79,9 @@ struct avrcp;
> struct avrcp_control_handler {
> uint8_t id;
> uint8_t code;
> - uint8_t (*func) (struct avrcp *session, uint8_t transaction,
> - uint16_t *params_len, uint8_t *params, void *user_data);
> + ssize_t (*func) (struct avrcp *session, uint8_t transaction,
> + uint8_t *code, uint16_t params_len, uint8_t *params,
> + void *user_data);
> };
>
> struct avrcp_passthrough_handler {
> diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
> index 302c331..2d5711b 100644
> --- a/unit/test-avrcp.c
> +++ b/unit/test-avrcp.c
> @@ -292,54 +292,54 @@ static const struct avrcp_passthrough_handler passthrough_handlers[] = {
> { },
> };
>
> -static uint8_t avrcp_handle_get_capabilities(struct avrcp *session,
> - uint8_t transaction, uint16_t *params_len,
> - uint8_t *params, void *user_data)
> +static ssize_t avrcp_handle_get_capabilities(struct avrcp *session,
> + uint8_t transaction, uint8_t *code,
> + uint16_t params_len, uint8_t *params,
> + void *user_data)
> {
> uint32_t id = 0x001958;
>
> - DBG("params[0] %d params_len %d", params[0], *params_len);
> -
> - if (*params_len != 1)
> + if (params_len != 1)
> goto fail;
>
> switch (params[0]) {
> case CAP_COMPANY_ID:
> - *params_len = 5;
> params[1] = 1;
> hton24(¶ms[2], id);
> - return AVC_CTYPE_STABLE;
> + *code = AVC_CTYPE_STABLE;
> + return 5;
What is 5? Shall we define constants or use formulas?
Best regards
Andrei Emeltchenko
^ permalink raw reply
* Re: [PATCH BlueZ 10/16] android/avrcp: Add handler for GetCapabilities command
From: Andrei Emeltchenko @ 2014-03-03 10:10 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1393786109-6554-10-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Sun, Mar 02, 2014 at 08:48:25PM +0200, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> ---
> android/avrcp-lib.h | 1 +
> android/avrcp.c | 42 ++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 43 insertions(+)
>
> diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
> index 8625425..dda1d28 100644
> --- a/android/avrcp-lib.h
> +++ b/android/avrcp-lib.h
> @@ -51,6 +51,7 @@
> #define AVRCP_EVENT_TRACK_CHANGED 0x02
> #define AVRCP_EVENT_TRACK_REACHED_END 0x03
> #define AVRCP_EVENT_TRACK_REACHED_START 0x04
> +#define AVRCP_EVENT_PLAYBACK_POS_CHANGED 0x05
> #define AVRCP_EVENT_SETTINGS_CHANGED 0x08
> #define AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED 0x0a
> #define AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED 0x0b
> diff --git a/android/avrcp.c b/android/avrcp.c
> index 9d86803..bcaa66c 100644
> --- a/android/avrcp.c
> +++ b/android/avrcp.c
> @@ -26,6 +26,7 @@
> #endif
>
> #include <stdbool.h>
> +#include <errno.h>
> #include <glib.h>
>
> #include "btio/btio.h"
> @@ -339,6 +340,46 @@ static const struct avrcp_passthrough_handler passthrough_handlers[] = {
> { },
> };
>
> +static ssize_t handle_get_capabilities(struct avrcp *session,
> + uint8_t transaction,
> + uint16_t params_len,
> + uint8_t *params,
> + void *user_data)
> +{
> + uint32_t id = 0x001958;
Don't we have it defined?
Best regards
Andrei Emeltchenko
> +
> + if (params_len != 1)
> + return -EINVAL;
> +
> + switch (params[0]) {
> + case CAP_COMPANY_ID:
> + params[params_len++] = 1;
> + hton24(¶ms[params_len], id);
> + return params_len + 3;
> + case CAP_EVENTS_SUPPORTED:
> + /* Android do not provide this info via HAL so the list most
> + * be hardcoded according to what RegisterNotification can
> + * actually handle */
> + params[params_len++] = 6;
> + params[params_len++] = AVRCP_EVENT_STATUS_CHANGED;
> + params[params_len++] = AVRCP_EVENT_TRACK_CHANGED;
> + params[params_len++] = AVRCP_EVENT_TRACK_REACHED_END;
> + params[params_len++] = AVRCP_EVENT_TRACK_REACHED_START;
> + params[params_len++] = AVRCP_EVENT_PLAYBACK_POS_CHANGED;
> + params[params_len++] = AVRCP_EVENT_SETTINGS_CHANGED;
> + return params_len;
> + }
> +
> + return -EINVAL;
> +}
> +
> +static const struct avrcp_control_handler control_handlers[] = {
> + { AVRCP_GET_CAPABILITIES,
> + AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
> + handle_get_capabilities },
> + { },
> +};
> +
> static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
> {
> struct avrcp_device *dev;
> @@ -390,6 +431,7 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
> avrcp_set_destroy_cb(dev->session, disconnect_cb, dev);
> avrcp_set_passthrough_handlers(dev->session, passthrough_handlers,
> dev);
> + avrcp_set_control_handlers(dev->session, control_handlers, dev);
>
> /* FIXME: get the real name of the device */
> avrcp_init_uinput(dev->session, "bluetooth", address);
> --
> 1.8.5.3
>
> --
> 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
* [PATCH v2] android/avrcp-lib: Fix destroy callback handling
From: Szymon Janc @ 2014-03-03 10:35 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
AVRCP destroy callback was directly passed as AVCTP destroy callback
resulting in struct avrcp not being freed on remote disconnect.
This fix following Valgrind report:
931 (36 direct, 895 indirect) bytes in 1 blocks are definitely lost in
loss record 53 of 55
at 0x4896DC8: calloc (in /system/lib/valgrind/
vgpreload_memcheck-arm-linux.so)
by 0x48C5DB7: g_malloc0 (gmem.c:189)
by 0x118671: avrcp_new (avrcp-lib.c:219)
by 0x117D4F: connect_cb (avrcp.c:346)
by 0x12068B: connect_cb (btio.c:232)
by 0x48BD9C7: g_io_unix_dispatch (giounix.c:166)
by 0x48C2CCB: g_main_context_dispatch (gmain.c:2539)
by 0x48C2ED9: g_main_context_iterate.isra.19 (gmain.c:3146)
by 0x48C3167: g_main_loop_run (gmain.c:3340)
by 0x10BA03: main (main.c:490)
---
v2: fix crash on local shutdown due to double call to avrcp_shutdown,
now avctp destroy callback is cleared when shuting down localy.
android/avrcp-lib.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
index 26bcce1..c5cfa12 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -98,6 +98,9 @@ struct avrcp {
const struct avrcp_passthrough_handler *passthrough_handlers;
void *passthrough_data;
unsigned int passthrough_id;
+
+ avrcp_destroy_cb_t destroy;
+ void *destroy_data;
};
void avrcp_shutdown(struct avrcp *session)
@@ -109,9 +112,15 @@ void avrcp_shutdown(struct avrcp *session)
if (session->passthrough_id > 0)
avctp_unregister_passthrough_handler(session->conn,
session->passthrough_id);
+
+ /* clear destroy callback that would call shutdown again */
+ avctp_set_destroy_cb(session->conn, NULL, NULL);
avctp_shutdown(session->conn);
}
+ if (session->destroy)
+ session->destroy(session->destroy_data);
+
g_free(session->tx_buf);
g_free(session);
}
@@ -199,6 +208,15 @@ static bool handle_passthrough_pdu(struct avctp *conn, uint8_t op,
return handler->func(session);
}
+static void disconnect_cb(void *data)
+{
+ struct avrcp *session = data;
+
+ session->conn = NULL;
+
+ avrcp_shutdown(session);
+}
+
struct avrcp *avrcp_new(int fd, size_t imtu, size_t omtu, uint16_t version)
{
struct avrcp *session;
@@ -223,13 +241,16 @@ struct avrcp *avrcp_new(int fd, size_t imtu, size_t omtu, uint16_t version)
handle_vendordep_pdu,
session);
+ avctp_set_destroy_cb(session->conn, disconnect_cb, session);
+
return session;
}
void avrcp_set_destroy_cb(struct avrcp *session, avrcp_destroy_cb_t cb,
void *user_data)
{
- avctp_set_destroy_cb(session->conn, cb, user_data);
+ session->destroy = cb;
+ session->destroy_data = user_data;
}
void avrcp_set_control_handlers(struct avrcp *session,
--
1.8.5.3
^ permalink raw reply related
* [PATCH v2 1/8] android/tester: Add create bond with PIN success test case
From: Grzegorz Kolodziejczyk @ 2014-03-03 10:44 UTC (permalink / raw)
To: linux-bluetooth
This adds create bond with PIN success test case.
---
android/android-tester.c | 138 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 136 insertions(+), 2 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index a94c536..df89d82 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -124,6 +124,8 @@ struct bt_cb_data {
bt_status_t status;
bt_bdaddr_t bdaddr;
+ bt_bdname_t bdname;
+ uint32_t cod;
int num;
bt_property_t *props;
@@ -1019,6 +1021,22 @@ static void remote_setprop_fail_device_found_cb(int num_properties,
check_expected_status(status);
}
+static void bond_device_found_cb(int num_properties, bt_property_t *properties)
+{
+ struct test_data *data = tester_get_data();
+ uint8_t *bdaddr = (uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
+ bt_bdaddr_t remote_addr;
+ bt_status_t status;
+
+ bdaddr2android((const bdaddr_t *)bdaddr, &remote_addr.address);
+
+ if (data->cb_count == 4) {
+ data->cb_count--;
+ status = data->if_bluetooth->create_bond(&remote_addr);
+ check_expected_status(status);
+ }
+}
+
static gboolean device_found(gpointer user_data)
{
struct test_data *data = tester_get_data();
@@ -1153,6 +1171,92 @@ static void remote_device_properties_cb(bt_status_t status,
g_idle_add(remote_device_properties, cb_data);
}
+static void bond_test_bonded_state_changed_cb(bt_status_t status,
+ bt_bdaddr_t *remote_bd_addr, bt_bond_state_t state)
+{
+ struct test_data *data = tester_get_data();
+
+ switch (state) {
+ case BT_BOND_STATE_BONDING:
+ data->cb_count--;
+ break;
+ case BT_BOND_STATE_BONDED:
+ data->cb_count--;
+ check_cb_count();
+ break;
+ default:
+ tester_test_failed();
+ break;
+ }
+}
+
+static gboolean bond_state_changed(gpointer user_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ struct bt_cb_data *cb_data = user_data;
+
+ if (data->test_init_done && test->expected_hal_cb.bond_state_changed_cb)
+ test->expected_hal_cb.bond_state_changed_cb(cb_data->status,
+ &cb_data->bdaddr, cb_data->state);
+
+ g_free(cb_data);
+ return FALSE;
+}
+
+static void bond_state_changed_cb(bt_status_t status,
+ bt_bdaddr_t *remote_bd_addr, bt_bond_state_t state)
+{
+ struct bt_cb_data *cb_data = g_new0(struct bt_cb_data, 1);
+
+ cb_data->status = status;
+ cb_data->bdaddr = *remote_bd_addr;
+ cb_data->state = state;
+
+ g_idle_add(bond_state_changed, cb_data);
+}
+
+static void bond_create_pin_success_request_cb(bt_bdaddr_t *remote_bd_addr,
+ bt_bdname_t *bd_name, uint32_t cod)
+{
+ struct test_data *data = tester_get_data();
+ const bt_bdaddr_t *bdaddr = remote_bd_addr;
+ bt_pin_code_t pin_code = {
+ .pin = { 0x30, 0x30, 0x30, 0x30 },
+ };
+ uint8_t pin_len = 4;
+
+ data->cb_count--;
+
+ data->if_bluetooth->pin_reply(bdaddr, TRUE, pin_len, &pin_code);
+}
+
+static gboolean pin_request(gpointer user_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ struct bt_cb_data *cb_data = user_data;
+
+ if (data->test_init_done && test->expected_hal_cb.pin_request_cb)
+ test->expected_hal_cb.pin_request_cb(&cb_data->bdaddr,
+ &cb_data->bdname, cb_data->cod);
+
+ g_free(cb_data);
+ return FALSE;
+}
+
+static void pin_request_cb(bt_bdaddr_t *remote_bd_addr,
+ bt_bdname_t *bd_name, uint32_t cod)
+{
+ struct bt_cb_data *cb_data = g_new0(struct bt_cb_data, 1);
+
+ cb_data->bdaddr = *remote_bd_addr;
+ cb_data->bdname = *bd_name;
+ cb_data->cod = cod;
+
+ g_idle_add(pin_request, cb_data);
+}
+
static bt_bdaddr_t enable_done_bdaddr_val = { {0x00} };
static const char enable_done_bdname_val[] = "BlueZ for Android";
static bt_uuid_t enable_done_uuids_val = {
@@ -2175,6 +2279,15 @@ static const struct generic_data bt_dev_setprop_disctimeout_fail_test = {
.expected_adapter_status = BT_STATUS_FAIL,
};
+static const struct generic_data bt_bond_create_pin_success_test = {
+ .expected_hal_cb.device_found_cb = bond_device_found_cb,
+ .expected_hal_cb.bond_state_changed_cb =
+ bond_test_bonded_state_changed_cb,
+ .expected_hal_cb.pin_request_cb = bond_create_pin_success_request_cb,
+ .expected_cb_count = 4,
+ .expected_adapter_status = BT_STATUS_SUCCESS,
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -2182,9 +2295,9 @@ static bt_callbacks_t bt_callbacks = {
.remote_device_properties_cb = remote_device_properties_cb,
.device_found_cb = device_found_cb,
.discovery_state_changed_cb = discovery_state_changed_cb,
- .pin_request_cb = NULL,
+ .pin_request_cb = pin_request_cb,
.ssp_request_cb = NULL,
- .bond_state_changed_cb = NULL,
+ .bond_state_changed_cb = bond_state_changed_cb,
.acl_state_changed_cb = NULL,
.thread_evt_cb = NULL,
.dut_mode_recv_cb = NULL,
@@ -2913,6 +3026,22 @@ static void test_dev_setprop_disctimeout_fail(const void *test_data)
data->if_bluetooth->start_discovery();
}
+static void test_bond_create_pin_success(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct bthost *bthost = hciemu_client_get_host(data->hciemu);
+
+ static uint8_t pair_device_pin[] = { 0x30, 0x30, 0x30, 0x30 };
+ const void *pin = pair_device_pin;
+ uint8_t pin_len = 4;
+
+ init_test_conditions(data);
+
+ bthost_set_pin_code(bthost, pin, pin_len);
+
+ data->if_bluetooth->start_discovery();
+}
+
/* Test Socket HAL */
static gboolean adapter_socket_state_changed(gpointer user_data)
@@ -4251,6 +4380,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_dev_setprop_disctimeout_fail, teardown);
+ test_bredrle("Bluetooth Create Bond PIN - Success",
+ &bt_bond_create_pin_success_test,
+ setup_enabled_adapter,
+ test_bond_create_pin_success, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.5.2
^ permalink raw reply related
* [PATCH v2 2/8] android/tester: Add create bond with PIN fail test case
From: Grzegorz Kolodziejczyk @ 2014-03-03 10:44 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1393843458-5237-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds create bond with PIN fail test case.
---
android/android-tester.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 93 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index df89d82..a7f5f2d 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1037,6 +1037,21 @@ static void bond_device_found_cb(int num_properties, bt_property_t *properties)
}
}
+static void bond_nostatus_device_found_cb(int num_properties,
+ bt_property_t *properties)
+{
+ struct test_data *data = tester_get_data();
+ uint8_t *bdaddr = (uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
+ bt_bdaddr_t remote_addr;
+
+ bdaddr2android((const bdaddr_t *)bdaddr, &remote_addr.address);
+
+ if (data->cb_count == 4) {
+ data->cb_count--;
+ data->if_bluetooth->create_bond(&remote_addr);
+ }
+}
+
static gboolean device_found(gpointer user_data)
{
struct test_data *data = tester_get_data();
@@ -1190,6 +1205,25 @@ static void bond_test_bonded_state_changed_cb(bt_status_t status,
}
}
+static void bond_test_none_state_changed_cb(bt_status_t status,
+ bt_bdaddr_t *remote_bd_addr, bt_bond_state_t state)
+{
+ struct test_data *data = tester_get_data();
+
+ switch (state) {
+ case BT_BOND_STATE_BONDING:
+ data->cb_count--;
+ break;
+ case BT_BOND_STATE_NONE:
+ data->cb_count--;
+ check_cb_count();
+ break;
+ default:
+ tester_test_failed();
+ break;
+ }
+}
+
static gboolean bond_state_changed(gpointer user_data)
{
struct test_data *data = tester_get_data();
@@ -1231,6 +1265,21 @@ static void bond_create_pin_success_request_cb(bt_bdaddr_t *remote_bd_addr,
data->if_bluetooth->pin_reply(bdaddr, TRUE, pin_len, &pin_code);
}
+static void bond_create_pin_fail_request_cb(bt_bdaddr_t *remote_bd_addr,
+ bt_bdname_t *bd_name, uint32_t cod)
+{
+ struct test_data *data = tester_get_data();
+ const bt_bdaddr_t *bdaddr = remote_bd_addr;
+ bt_pin_code_t pin_code = {
+ .pin = { 0x31, 0x31, 0x31, 0x31 },
+ };
+ uint8_t pin_len = 4;
+
+ data->cb_count--;
+
+ data->if_bluetooth->pin_reply(bdaddr, TRUE, pin_len, &pin_code);
+}
+
static gboolean pin_request(gpointer user_data)
{
struct test_data *data = tester_get_data();
@@ -2288,6 +2337,15 @@ static const struct generic_data bt_bond_create_pin_success_test = {
.expected_adapter_status = BT_STATUS_SUCCESS,
};
+static const struct generic_data bt_bond_create_pin_fail_test = {
+ .expected_hal_cb.device_found_cb = bond_nostatus_device_found_cb,
+ .expected_hal_cb.bond_state_changed_cb =
+ bond_test_none_state_changed_cb,
+ .expected_hal_cb.pin_request_cb = bond_create_pin_fail_request_cb,
+ .expected_cb_count = 4,
+ .expected_adapter_status = MGMT_STATUS_AUTH_FAILED,
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -3026,6 +3084,16 @@ static void test_dev_setprop_disctimeout_fail(const void *test_data)
data->if_bluetooth->start_discovery();
}
+
+static void bond_device_auth_fail_callback(uint16_t index, uint16_t length,
+ const void *param,
+ void *user_data)
+{
+ const struct mgmt_ev_auth_failed *ev = param;
+
+ check_expected_status(ev->status);
+}
+
static void test_bond_create_pin_success(const void *test_data)
{
struct test_data *data = tester_get_data();
@@ -3042,6 +3110,26 @@ static void test_bond_create_pin_success(const void *test_data)
data->if_bluetooth->start_discovery();
}
+static void test_bond_create_pin_fail(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct bthost *bthost = hciemu_client_get_host(data->hciemu);
+
+ static uint8_t pair_device_pin[] = { 0x30, 0x30, 0x30, 0x30 };
+ const void *pin = pair_device_pin;
+ uint8_t pin_len = 4;
+
+ init_test_conditions(data);
+
+ mgmt_register(data->mgmt, MGMT_EV_AUTH_FAILED, data->mgmt_index,
+ bond_device_auth_fail_callback, data,
+ NULL);
+
+ bthost_set_pin_code(bthost, pin, pin_len);
+
+ data->if_bluetooth->start_discovery();
+}
+
/* Test Socket HAL */
static gboolean adapter_socket_state_changed(gpointer user_data)
@@ -4385,6 +4473,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_bond_create_pin_success, teardown);
+ test_bredrle("Bluetooth Create Bond PIN - Bad PIN",
+ &bt_bond_create_pin_fail_test,
+ setup_enabled_adapter,
+ test_bond_create_pin_fail, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.5.2
^ permalink raw reply related
* [PATCH v2 3/8] android/tester: Add create bond with SSP sucess test case
From: Grzegorz Kolodziejczyk @ 2014-03-03 10:44 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1393843458-5237-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds create bond with SSP succes test case. Confirm is set as SSP
pairing mode.
---
android/android-tester.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 85 insertions(+), 1 deletion(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index a7f5f2d..054f73e 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -127,6 +127,9 @@ struct bt_cb_data {
bt_bdname_t bdname;
uint32_t cod;
+ bt_ssp_variant_t ssp_variant;
+ uint32_t passkey;
+
int num;
bt_property_t *props;
};
@@ -1306,6 +1309,61 @@ static void pin_request_cb(bt_bdaddr_t *remote_bd_addr,
g_idle_add(pin_request, cb_data);
}
+static void bond_create_ssp_request_cb(const bt_bdaddr_t *remote_bd_addr,
+ bt_ssp_variant_t pairing_variant,
+ bool accept, uint32_t pass_key)
+{
+ struct test_data *data = tester_get_data();
+
+ data->if_bluetooth->ssp_reply(remote_bd_addr,
+ BT_SSP_VARIANT_PASSKEY_CONFIRMATION,
+ accept, pass_key);
+
+ data->cb_count--;
+}
+
+static void bond_create_ssp_success_request_cb(bt_bdaddr_t *remote_bd_addr,
+ bt_bdname_t *bd_name, uint32_t cod,
+ bt_ssp_variant_t pairing_variant,
+ uint32_t pass_key)
+{
+ bool accept = true;
+
+ bond_create_ssp_request_cb(remote_bd_addr, pairing_variant, accept,
+ pass_key);
+}
+
+static gboolean ssp_request(gpointer user_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ struct bt_cb_data *cb_data = user_data;
+
+ if (data->test_init_done &&
+ test->expected_hal_cb.ssp_request_cb)
+ test->expected_hal_cb.ssp_request_cb(&cb_data->bdaddr,
+ &cb_data->bdname, cb_data->cod,
+ cb_data->ssp_variant, cb_data->passkey);
+
+ g_free(cb_data);
+ return FALSE;
+}
+
+static void ssp_request_cb(bt_bdaddr_t *remote_bd_addr, bt_bdname_t *bd_name,
+ uint32_t cod, bt_ssp_variant_t pairing_variant,
+ uint32_t pass_key)
+{
+ struct bt_cb_data *cb_data = g_new0(struct bt_cb_data, 1);
+
+ cb_data->bdaddr = *remote_bd_addr;
+ cb_data->bdname = *bd_name;
+ cb_data->cod = cod;
+ cb_data->ssp_variant = pairing_variant;
+ cb_data->passkey = pass_key;
+
+ g_idle_add(ssp_request, cb_data);
+}
+
static bt_bdaddr_t enable_done_bdaddr_val = { {0x00} };
static const char enable_done_bdname_val[] = "BlueZ for Android";
static bt_uuid_t enable_done_uuids_val = {
@@ -2346,6 +2404,15 @@ static const struct generic_data bt_bond_create_pin_fail_test = {
.expected_adapter_status = MGMT_STATUS_AUTH_FAILED,
};
+static const struct generic_data bt_bond_create_ssp_success_test = {
+ .expected_hal_cb.device_found_cb = bond_device_found_cb,
+ .expected_hal_cb.bond_state_changed_cb =
+ bond_test_bonded_state_changed_cb,
+ .expected_hal_cb.ssp_request_cb = bond_create_ssp_success_request_cb,
+ .expected_cb_count = 4,
+ .expected_adapter_status = BT_STATUS_SUCCESS,
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -2354,7 +2421,7 @@ static bt_callbacks_t bt_callbacks = {
.device_found_cb = device_found_cb,
.discovery_state_changed_cb = discovery_state_changed_cb,
.pin_request_cb = pin_request_cb,
- .ssp_request_cb = NULL,
+ .ssp_request_cb = ssp_request_cb,
.bond_state_changed_cb = bond_state_changed_cb,
.acl_state_changed_cb = NULL,
.thread_evt_cb = NULL,
@@ -3130,6 +3197,18 @@ static void test_bond_create_pin_fail(const void *test_data)
data->if_bluetooth->start_discovery();
}
+static void test_bond_create_ssp_success(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct bthost *bthost = hciemu_client_get_host(data->hciemu);
+
+ init_test_conditions(data);
+
+ bthost_write_ssp_mode(bthost, 0x01);
+
+ data->if_bluetooth->start_discovery();
+}
+
/* Test Socket HAL */
static gboolean adapter_socket_state_changed(gpointer user_data)
@@ -4478,6 +4557,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_bond_create_pin_fail, teardown);
+ test_bredrle("Bluetooth Create Bond SSP - Success",
+ &bt_bond_create_ssp_success_test,
+ setup_enabled_adapter,
+ test_bond_create_ssp_success, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.5.2
^ permalink raw reply related
* [PATCH v2 4/8] android/tester: Add create bond with SSP fail test case
From: Grzegorz Kolodziejczyk @ 2014-03-03 10:44 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1393843458-5237-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds create bond with SSP fail test case. Confirm is set as SSP
pairing mode.
---
android/android-tester.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 054f73e..bfaffba 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1333,6 +1333,17 @@ static void bond_create_ssp_success_request_cb(bt_bdaddr_t *remote_bd_addr,
pass_key);
}
+static void bond_create_ssp_fail_request_cb(bt_bdaddr_t *remote_bd_addr,
+ bt_bdname_t *bd_name, uint32_t cod,
+ bt_ssp_variant_t pairing_variant,
+ uint32_t pass_key)
+{
+ bool accept = false;
+
+ bond_create_ssp_request_cb(remote_bd_addr, pairing_variant, accept,
+ pass_key);
+}
+
static gboolean ssp_request(gpointer user_data)
{
struct test_data *data = tester_get_data();
@@ -2413,6 +2424,15 @@ static const struct generic_data bt_bond_create_ssp_success_test = {
.expected_adapter_status = BT_STATUS_SUCCESS,
};
+static const struct generic_data bt_bond_create_ssp_fail_test = {
+ .expected_hal_cb.device_found_cb = bond_nostatus_device_found_cb,
+ .expected_hal_cb.bond_state_changed_cb =
+ bond_test_none_state_changed_cb,
+ .expected_hal_cb.ssp_request_cb = bond_create_ssp_fail_request_cb,
+ .expected_cb_count = 4,
+ .expected_adapter_status = MGMT_STATUS_AUTH_FAILED,
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -3209,6 +3229,22 @@ static void test_bond_create_ssp_success(const void *test_data)
data->if_bluetooth->start_discovery();
}
+static void test_bond_create_ssp_fail(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct bthost *bthost = hciemu_client_get_host(data->hciemu);
+
+ init_test_conditions(data);
+
+ mgmt_register(data->mgmt, MGMT_EV_AUTH_FAILED, data->mgmt_index,
+ bond_device_auth_fail_callback, data,
+ NULL);
+
+ bthost_write_ssp_mode(bthost, 0x01);
+
+ data->if_bluetooth->start_discovery();
+}
+
/* Test Socket HAL */
static gboolean adapter_socket_state_changed(gpointer user_data)
@@ -4562,6 +4598,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_bond_create_ssp_success, teardown);
+ test_bredrle("Bluetooth Create Bond SSP - Negative reply",
+ &bt_bond_create_ssp_fail_test,
+ setup_enabled_adapter,
+ test_bond_create_ssp_fail, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.5.2
^ permalink raw reply related
* [PATCH v2 5/8] android/tester: Add create bond with no discovery test case
From: Grzegorz Kolodziejczyk @ 2014-03-03 10:44 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1393843458-5237-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds create bond with no discovery before create bond as NFC does.
SSP with confirm as authentication mode.
---
android/android-tester.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index bfaffba..3de79f4 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -2433,6 +2433,14 @@ static const struct generic_data bt_bond_create_ssp_fail_test = {
.expected_adapter_status = MGMT_STATUS_AUTH_FAILED,
};
+static const struct generic_data bt_bond_create_no_disc_success_test = {
+ .expected_hal_cb.bond_state_changed_cb =
+ bond_test_bonded_state_changed_cb,
+ .expected_hal_cb.ssp_request_cb = bond_create_ssp_success_request_cb,
+ .expected_cb_count = 3,
+ .expected_adapter_status = BT_STATUS_SUCCESS,
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -3245,6 +3253,25 @@ static void test_bond_create_ssp_fail(const void *test_data)
data->if_bluetooth->start_discovery();
}
+static void test_bond_create_no_disc_success(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct bthost *bthost = hciemu_client_get_host(data->hciemu);
+
+ uint8_t *bdaddr = (uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
+ bt_bdaddr_t remote_addr;
+ bt_status_t status;
+
+ init_test_conditions(data);
+
+ bdaddr2android((const bdaddr_t *)bdaddr, &remote_addr.address);
+
+ bthost_write_ssp_mode(bthost, 0x01);
+
+ status = data->if_bluetooth->create_bond(&remote_addr);
+ check_expected_status(status);
+}
+
/* Test Socket HAL */
static gboolean adapter_socket_state_changed(gpointer user_data)
@@ -4603,6 +4630,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_bond_create_ssp_fail, teardown);
+ test_bredrle("Bluetooth Create Bond - No Discovery",
+ &bt_bond_create_no_disc_success_test,
+ setup_enabled_adapter,
+ test_bond_create_no_disc_success, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.5.2
^ permalink raw reply related
* [PATCH v2 6/8] android/tester: Add create bond with bad addr fail test case
From: Grzegorz Kolodziejczyk @ 2014-03-03 10:44 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1393843458-5237-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds create bond with bad addr fail test case.
---
android/android-tester.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 3de79f4..8baaecd 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -2441,6 +2441,10 @@ static const struct generic_data bt_bond_create_no_disc_success_test = {
.expected_adapter_status = BT_STATUS_SUCCESS,
};
+static const struct generic_data bt_bond_create_bad_addr_success_test = {
+ .expected_adapter_status = MGMT_STATUS_CONNECT_FAILED,
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -3272,6 +3276,22 @@ static void test_bond_create_no_disc_success(const void *test_data)
check_expected_status(status);
}
+static void test_bond_create_bad_addr_success(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ bt_bdaddr_t bad_addr = {
+ .address = { 0x12, 0x34, 0x56, 0x78, 0x90, 0x12 }
+ };
+
+ init_test_conditions(data);
+
+ mgmt_register(data->mgmt, MGMT_EV_CONNECT_FAILED, data->mgmt_index,
+ bond_device_auth_fail_callback, data,
+ NULL);
+
+ data->if_bluetooth->create_bond(&bad_addr);
+}
+
/* Test Socket HAL */
static gboolean adapter_socket_state_changed(gpointer user_data)
@@ -4635,6 +4655,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_bond_create_no_disc_success, teardown);
+ test_bredrle("Bluetooth Create Bond - Bad Address",
+ &bt_bond_create_bad_addr_success_test,
+ setup_enabled_adapter,
+ test_bond_create_bad_addr_success, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.5.2
^ permalink raw reply related
* [PATCH v2 7/8] android/tester: Add cancel bond success test case
From: Grzegorz Kolodziejczyk @ 2014-03-03 10:44 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1393843458-5237-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds cancel bond success test case. SSP as pairing mode.
---
android/android-tester.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 8baaecd..5c7130e 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1344,6 +1344,24 @@ static void bond_create_ssp_fail_request_cb(bt_bdaddr_t *remote_bd_addr,
pass_key);
}
+static void bond_cancel_success_ssp_request_cb(bt_bdaddr_t *remote_bd_addr,
+ bt_bdname_t *bd_name, uint32_t cod,
+ bt_ssp_variant_t pairing_variant,
+ uint32_t pass_key)
+{
+ struct test_data *data = tester_get_data();
+ uint8_t *bdaddr = (uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
+ bt_bdaddr_t remote_addr;
+ bt_status_t status;
+
+ bdaddr2android((const bdaddr_t *)bdaddr, &remote_addr.address);
+
+ data->cb_count--;
+
+ status = data->if_bluetooth->cancel_bond(&remote_addr);
+ check_expected_status(status);
+}
+
static gboolean ssp_request(gpointer user_data)
{
struct test_data *data = tester_get_data();
@@ -2445,6 +2463,15 @@ static const struct generic_data bt_bond_create_bad_addr_success_test = {
.expected_adapter_status = MGMT_STATUS_CONNECT_FAILED,
};
+static const struct generic_data bt_bond_cancel_success_test = {
+ .expected_hal_cb.device_found_cb = bond_nostatus_device_found_cb,
+ .expected_hal_cb.bond_state_changed_cb =
+ bond_test_none_state_changed_cb,
+ .expected_hal_cb.ssp_request_cb = bond_cancel_success_ssp_request_cb,
+ .expected_cb_count = 4,
+ .expected_adapter_status = BT_STATUS_SUCCESS,
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -3292,6 +3319,18 @@ static void test_bond_create_bad_addr_success(const void *test_data)
data->if_bluetooth->create_bond(&bad_addr);
}
+static void test_bond_cancel_success(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct bthost *bthost = hciemu_client_get_host(data->hciemu);
+
+ init_test_conditions(data);
+
+ bthost_write_ssp_mode(bthost, 0x01);
+
+ data->if_bluetooth->start_discovery();
+}
+
/* Test Socket HAL */
static gboolean adapter_socket_state_changed(gpointer user_data)
@@ -4660,6 +4699,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_bond_create_bad_addr_success, teardown);
+ test_bredrle("Bluetooth Cancel Bonding - Success",
+ &bt_bond_cancel_success_test,
+ setup_enabled_adapter,
+ test_bond_cancel_success, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.5.2
^ permalink raw reply related
* [PATCH v2 8/8] android/tester: Add remove bond success test case
From: Grzegorz Kolodziejczyk @ 2014-03-03 10:44 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1393843458-5237-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds remove bond success test case. SSP as pairing mode.
---
android/android-tester.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 5c7130e..b762a2d 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1227,6 +1227,29 @@ static void bond_test_none_state_changed_cb(bt_status_t status,
}
}
+static void bond_remove_success_state_changed_cb(bt_status_t status,
+ bt_bdaddr_t *remote_bd_addr, bt_bond_state_t state)
+{
+ struct test_data *data = tester_get_data();
+ bt_status_t remove_status;
+ uint8_t *bdaddr = (uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
+ bt_bdaddr_t remote_addr;
+
+ bdaddr2android((const bdaddr_t *)bdaddr, &remote_addr.address);
+
+ if (state == BT_BOND_STATE_BONDED) {
+ data->cb_count--;
+ remove_status = data->if_bluetooth->remove_bond(&remote_addr);
+ check_expected_status(remove_status);
+ return;
+ }
+
+ if (state == BT_BOND_STATE_NONE) {
+ data->cb_count--;
+ check_cb_count();
+ }
+}
+
static gboolean bond_state_changed(gpointer user_data)
{
struct test_data *data = tester_get_data();
@@ -2472,6 +2495,15 @@ static const struct generic_data bt_bond_cancel_success_test = {
.expected_adapter_status = BT_STATUS_SUCCESS,
};
+static const struct generic_data bt_bond_remove_success_test = {
+ .expected_hal_cb.device_found_cb = bond_nostatus_device_found_cb,
+ .expected_hal_cb.bond_state_changed_cb =
+ bond_remove_success_state_changed_cb,
+ .expected_hal_cb.ssp_request_cb = bond_create_ssp_success_request_cb,
+ .expected_cb_count = 4,
+ .expected_adapter_status = BT_STATUS_SUCCESS,
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -3331,6 +3363,18 @@ static void test_bond_cancel_success(const void *test_data)
data->if_bluetooth->start_discovery();
}
+static void test_bond_remove_success(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct bthost *bthost = hciemu_client_get_host(data->hciemu);
+
+ init_test_conditions(data);
+
+ bthost_write_ssp_mode(bthost, 0x01);
+
+ data->if_bluetooth->start_discovery();
+}
+
/* Test Socket HAL */
static gboolean adapter_socket_state_changed(gpointer user_data)
@@ -4704,6 +4748,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_bond_cancel_success, teardown);
+ test_bredrle("Bluetooth Remove Bond - Success",
+ &bt_bond_remove_success_test,
+ setup_enabled_adapter,
+ test_bond_remove_success, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.5.2
^ permalink raw reply related
* [PATCH] android/hal-gatt: Add skeleton for GATT HAL
From: Jakub Tyszkowski @ 2014-03-03 10:56 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jakub Tyszkowski
This adds skeleton with stubs and proper build system entries.
---
android/Android.mk | 1 +
android/Makefile.am | 1 +
android/hal-bluetooth.c | 3 +
android/hal-gatt.c | 563 ++++++++++++++++++++++++++++++++++++++++++++++++
android/hal.h | 4 +
5 files changed, 572 insertions(+)
create mode 100644 android/hal-gatt.c
diff --git a/android/Android.mk b/android/Android.mk
index 56b86ba..6fd0f94 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -118,6 +118,7 @@ LOCAL_SRC_FILES := \
bluez/android/hal-a2dp.c \
bluez/android/hal-avrcp.c \
bluez/android/hal-handsfree.c \
+ bluez/android/hal-gatt.c \
bluez/android/hal-utils.c \
LOCAL_C_INCLUDES += \
diff --git a/android/Makefile.am b/android/Makefile.am
index 31f905c..8abfff4 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -55,6 +55,7 @@ android_bluetooth_default_la_SOURCES = android/hal.h android/hal-bluetooth.c \
android/hal-a2dp.c \
android/hal-avrcp.c \
android/hal-handsfree.c \
+ android/hal-gatt.c \
android/hardware/bluetooth.h \
android/hardware/bt_av.h \
android/hardware/bt_gatt.h \
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 6871f5d..f58f72c 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -773,6 +773,9 @@ static const void *get_profile_interface(const char *profile_id)
if (!strcmp(profile_id, BT_PROFILE_HANDSFREE_ID))
return bt_get_handsfree_interface();
+ if (!strcmp(profile_id, BT_PROFILE_GATT_ID))
+ return bt_get_gatt_interface();
+
return NULL;
}
diff --git a/android/hal-gatt.c b/android/hal-gatt.c
new file mode 100644
index 0000000..00cf888
--- /dev/null
+++ b/android/hal-gatt.c
@@ -0,0 +1,563 @@
+/*
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdbool.h>
+
+#include "hal-log.h"
+#include "hal.h"
+#include "hal-msg.h"
+#include "hal-ipc.h"
+
+static const btgatt_callbacks_t *cbs = NULL;
+
+static bool interface_ready(void)
+{
+ return cbs != NULL;
+}
+
+/* Client Event Handlers */
+
+static void handle_register_client(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_scan_result(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_connect(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_disconnect(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_search_complete(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_search_result(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_get_characteristic(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_get_descriptor(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_get_included_service(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_register_for_notification(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_notify(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_read_characteristic(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_write_characteristic(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_read_descriptor(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_write_descriptor(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_execute_write(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_read_remote_rssi(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_listen(void *buf, uint16_t len)
+{
+
+}
+
+/* Server Event Handlers */
+
+static void handle_register_server(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_connection(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_service_added(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_included_service_added(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_characteristic_added(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_descriptor_added(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_service_started(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_service_stopped(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_service_deleted(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_request_read(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_request_write(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_request_exec_write(void *buf, uint16_t len)
+{
+
+}
+
+static void handle_response_confirmation(void *buf, uint16_t len)
+{
+
+}
+
+/* handlers will be called from notification thread context,
+ * index in table equals to 'opcode - HAL_MINIMUM_EVENT' */
+static const struct hal_ipc_handler ev_handlers[] = {
+ /* Client Event Handlers */
+ {handle_register_client, false,
+ sizeof(struct hal_ev_gatt_client_register_client)},
+ {handle_scan_result, true,
+ sizeof(struct hal_ev_gatt_client_scan_result)},
+ {handle_connect, false, sizeof(struct hal_ev_gatt_client_connect)},
+ {handle_disconnect, false,
+ sizeof(struct hal_ev_gatt_client_disconnect)},
+ {handle_search_complete, false,
+ sizeof(struct hal_ev_gatt_client_search_complete)},
+ {handle_search_result, false,
+ sizeof(struct hal_ev_gatt_client_search_result)},
+ {handle_get_characteristic, false,
+ sizeof(struct hal_ev_gatt_client_get_characteristic)},
+ {handle_get_descriptor, false,
+ sizeof(struct hal_ev_gatt_client_get_descriptor)},
+ {handle_get_included_service, false,
+ sizeof(struct hal_ev_gatt_client_get_inc_service)},
+ {handle_register_for_notification, false,
+ sizeof(struct hal_ev_gatt_client_reg_for_notif)},
+ {handle_notify, true, sizeof(struct hal_ev_gatt_client_notify)},
+ {handle_read_characteristic, true,
+ sizeof(struct hal_ev_gatt_client_read_characteristic)},
+ {handle_write_characteristic, false,
+ sizeof(struct hal_ev_gatt_client_write_characteristic)},
+ {handle_read_descriptor, false,
+ sizeof(struct hal_ev_gatt_client_read_descriptor)},
+ {handle_write_descriptor, false,
+ sizeof(struct hal_ev_gatt_client_write_descriptor)},
+ {handle_execute_write, false,
+ sizeof(struct hal_ev_gatt_client_exec_write)},
+ {handle_read_remote_rssi, false,
+ sizeof(struct hal_ev_gatt_client_read_remote_rssi)},
+ {handle_listen, false, sizeof(struct hal_ev_gatt_client_listen)},
+
+ /* Server Event Handlers */
+ {handle_register_server, false,
+ sizeof(struct hal_ev_gatt_server_register)},
+ {handle_connection, false,
+ sizeof(struct hal_ev_gatt_server_connection)},
+ {handle_service_added, false,
+ sizeof(struct hal_ev_gatt_server_service_added)},
+ {handle_included_service_added, false,
+ sizeof(struct hal_ev_gatt_server_service_added)},
+ {handle_characteristic_added, false,
+ sizeof(struct hal_ev_gatt_server_characteristic_added)},
+ {handle_descriptor_added, false,
+ sizeof(struct hal_ev_gatt_server_descriptor_added)},
+ {handle_service_started, false,
+ sizeof(struct hal_ev_gatt_server_service_started)},
+ {handle_service_stopped, false,
+ sizeof(struct hal_ev_gatt_server_service_stopped)},
+ {handle_service_deleted, false,
+ sizeof(struct hal_ev_gatt_server_service_deleted)},
+ {handle_request_read, false,
+ sizeof(struct hal_ev_gatt_server_request_read)},
+ {handle_request_write, true,
+ sizeof(struct hal_ev_gatt_server_request_write)},
+ {handle_request_exec_write, false,
+ sizeof(struct hal_ev_gatt_server_request_exec_write)},
+ {handle_response_confirmation, false,
+ sizeof(struct hal_ev_gatt_server_rsp_confirmation)},
+};
+
+static bt_status_t init(const btgatt_callbacks_t *callbacks)
+{
+ struct hal_cmd_register_module cmd;
+ int ret;
+
+ DBG("");
+
+ if (interface_ready())
+ return BT_STATUS_DONE;
+
+ cbs = callbacks;
+
+ hal_ipc_register(HAL_SERVICE_ID_GATT, ev_handlers,
+ sizeof(ev_handlers)/sizeof(ev_handlers[0]));
+
+ cmd.service_id = HAL_SERVICE_ID_GATT;
+
+ ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
+ sizeof(cmd), &cmd, 0, NULL, NULL);
+
+ if (ret != BT_STATUS_SUCCESS) {
+ cbs = NULL;
+ hal_ipc_unregister(HAL_SERVICE_ID_GATT);
+ }
+
+ return ret;
+}
+
+/* Client API */
+
+static bt_status_t register_client(bt_uuid_t *uuid)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t unregister_client(int client_if)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t scan(int client_if, bool start)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t connect(int client_if, const bt_bdaddr_t *bd_addr,
+ bool is_direct)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t disconnect(int client_if, const bt_bdaddr_t *bd_addr,
+ int conn_id)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t listen(int client_if, bool start)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t refresh(int client_if, const bt_bdaddr_t *bd_addr)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t search_service(int conn_id, bt_uuid_t *filter_uuid)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t get_included_service(int conn_id, btgatt_srvc_id_t *srvc_id,
+ btgatt_srvc_id_t *start_incl_srvc_id)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t get_characteristic(int conn_id, btgatt_srvc_id_t *srvc_id,
+ btgatt_gatt_id_t *start_char_id)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t get_descriptor(int conn_id, btgatt_srvc_id_t *srvc_id,
+ btgatt_gatt_id_t *char_id,
+ btgatt_gatt_id_t *start_descr_id)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t read_characteristic(int conn_id, btgatt_srvc_id_t *srvc_id,
+ btgatt_gatt_id_t *char_id,
+ int auth_req)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t write_characteristic(int conn_id, btgatt_srvc_id_t *srvc_id,
+ btgatt_gatt_id_t *char_id, int write_type,
+ int len, int auth_req, char *p_value)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t read_descriptor(int conn_id, btgatt_srvc_id_t *srvc_id,
+ btgatt_gatt_id_t *char_id,
+ btgatt_gatt_id_t *descr_id, int auth_req)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t write_descriptor(int conn_id, btgatt_srvc_id_t *srvc_id,
+ btgatt_gatt_id_t *char_id,
+ btgatt_gatt_id_t *descr_id, int write_type,
+ int len, int auth_req, char *p_value)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t execute_write(int conn_id, int execute)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t register_for_notification(int client_if,
+ const bt_bdaddr_t *bd_addr,
+ btgatt_srvc_id_t *srvc_id,
+ btgatt_gatt_id_t *char_id)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t deregister_for_notification(int client_if,
+ const bt_bdaddr_t *bd_addr, btgatt_srvc_id_t *srvc_id,
+ btgatt_gatt_id_t *char_id)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t read_remote_rssi(int client_if, const bt_bdaddr_t *bd_addr)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static int get_device_type(const bt_bdaddr_t *bd_addr)
+{
+ return 0;
+}
+
+static bt_status_t set_adv_data(int server_if, bool set_scan_rsp,
+ bool include_name, bool include_txpower,
+ int min_interval, int max_interval, int appearance,
+ uint16_t manufacturer_len, char *manufacturer_data)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t test_command(int command, btgatt_test_params_t *params)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+/* Server API */
+
+static bt_status_t register_server(bt_uuid_t *uuid)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t unregister_server(int server_if)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t server_connect(int server_if, const bt_bdaddr_t *bd_addr,
+ bool is_direct)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t add_service(int server_if, btgatt_srvc_id_t *srvc_id,
+ int num_handles)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t add_included_service(int server_if, int service_handle,
+ int included_handle)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t add_characteristic(int server_if, int service_handle,
+ bt_uuid_t *uuid, int properties,
+ int permissions)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t add_descriptor(int server_if, int service_handle,
+ bt_uuid_t *uuid, int permissions)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t start_service(int server_if, int service_handle,
+ int transport)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t stop_service(int server_if, int service_handle)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t delete_service(int server_if, int service_handle)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t send_indication(int server_if, int attribute_handle,
+ int conn_id, int len, int confirm,
+ char *p_value)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t send_response(int conn_id, int trans_id, int status,
+ btgatt_response_t *response)
+{
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static void cleanup(void)
+{
+ struct hal_cmd_unregister_module cmd;
+
+ DBG("");
+
+ if (!interface_ready())
+ return;
+
+ cbs = NULL;
+
+ cmd.service_id = HAL_SERVICE_ID_GATT;
+
+ hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_UNREGISTER_MODULE,
+ sizeof(cmd), &cmd, 0, NULL, NULL);
+
+ hal_ipc_unregister(HAL_SERVICE_ID_GATT);
+}
+
+static btgatt_client_interface_t client_iface = {
+ .register_client = register_client,
+ .unregister_client = unregister_client,
+ .scan = scan,
+ .connect = connect,
+ .disconnect = disconnect,
+ .listen = listen,
+ .refresh = refresh,
+ .search_service = search_service,
+ .get_included_service = get_included_service,
+ .get_characteristic = get_characteristic,
+ .get_descriptor = get_descriptor,
+ .read_characteristic = read_characteristic,
+ .write_characteristic = write_characteristic,
+ .read_descriptor = read_descriptor,
+ .write_descriptor = write_descriptor,
+ .execute_write = execute_write,
+ .register_for_notification = register_for_notification,
+ .deregister_for_notification = deregister_for_notification,
+ .read_remote_rssi = read_remote_rssi,
+ .get_device_type = get_device_type,
+ .set_adv_data = set_adv_data,
+ .test_command = test_command,
+};
+
+static btgatt_server_interface_t server_iface = {
+ .register_server = register_server,
+ .unregister_server = unregister_server,
+ .connect = server_connect,
+ .add_service = add_service,
+ .add_included_service = add_included_service,
+ .add_characteristic = add_characteristic,
+ .add_descriptor = add_descriptor,
+ .start_service = start_service,
+ .stop_service = stop_service,
+ .delete_service = delete_service,
+ .send_indication = send_indication,
+ .send_response = send_response,
+};
+
+static btgatt_interface_t iface = {
+ .size = sizeof(iface),
+ .init = init,
+ .cleanup = cleanup,
+ .client = &client_iface,
+ .server = &server_iface,
+};
+
+btgatt_interface_t *bt_get_gatt_interface(void)
+{
+ return &iface;
+}
diff --git a/android/hal.h b/android/hal.h
index 6fd2559..b1c0216 100644
--- a/android/hal.h
+++ b/android/hal.h
@@ -22,6 +22,9 @@
#include <hardware/bt_av.h>
#include <hardware/bt_rc.h>
#include <hardware/bt_hf.h>
+#include <hardware/bt_gatt.h>
+#include <hardware/bt_gatt_client.h>
+#include <hardware/bt_gatt_server.h>
btsock_interface_t *bt_get_socket_interface(void);
bthh_interface_t *bt_get_hidhost_interface(void);
@@ -29,6 +32,7 @@ btpan_interface_t *bt_get_pan_interface(void);
btav_interface_t *bt_get_a2dp_interface(void);
btrc_interface_t *bt_get_avrcp_interface(void);
bthf_interface_t *bt_get_handsfree_interface(void);
+btgatt_interface_t *bt_get_gatt_interface(void);
void bt_thread_associate(void);
void bt_thread_disassociate(void);
--
1.9.0
^ permalink raw reply related
* Re: [PATCH BlueZ 03/16] android/avrcp-lib: Rework handler callback parameters
From: Luiz Augusto von Dentz @ 2014-03-03 12:41 UTC (permalink / raw)
To: Andrei Emeltchenko, Luiz Augusto von Dentz,
linux-bluetooth@vger.kernel.org
In-Reply-To: <20140303095237.GB4999@aemeltch-MOBL1>
Hi Andrei,
On Mon, Mar 3, 2014 at 11:52 AM, Andrei Emeltchenko
<andrei.emeltchenko.news@gmail.com> wrote:
> Hi Luiz,
>
> On Sun, Mar 02, 2014 at 08:48:18PM +0200, Luiz Augusto von Dentz wrote:
>> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>>
>> This rework handler callback parameters to make it able to return
>> proper error such as -EAGAIN to implement asynchronous responses.
>> ---
>> android/avrcp-lib.c | 12 +++++++++---
>> android/avrcp-lib.h | 5 +++--
>> unit/test-avrcp.c | 42 +++++++++++++++++++++---------------------
>> 3 files changed, 33 insertions(+), 26 deletions(-)
>>
>> diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
>> index cdad6ac..339be16 100644
>> --- a/android/avrcp-lib.c
>> +++ b/android/avrcp-lib.c
>> @@ -125,6 +125,7 @@ static ssize_t handle_vendordep_pdu(struct avctp *conn, uint8_t transaction,
>> struct avrcp_header *pdu = (void *) operands;
>> uint32_t company_id = ntoh24(pdu->company_id);
>> uint16_t params_len = ntohs(pdu->params_len);
>> + ssize_t ret;
>>
>> if (company_id != IEEEID_BTSIG) {
>> *code = AVC_CTYPE_NOT_IMPLEMENTED;
>> @@ -159,12 +160,17 @@ static ssize_t handle_vendordep_pdu(struct avctp *conn, uint8_t transaction,
>> goto reject;
>> }
>>
>> - *code = handler->func(session, transaction, ¶ms_len,
>> + ret = handler->func(session, transaction, code, params_len,
>> pdu->params, session->control_data);
>> + if (ret < 0) {
>> + if (ret == -EAGAIN)
>> + return ret;
>> + goto reject;
>> + }
>>
>> - pdu->params_len = htons(params_len);
>> + pdu->params_len = htons(ret);
>>
>> - return AVRCP_HEADER_LENGTH + params_len;
>> + return AVRCP_HEADER_LENGTH + ret;
>>
>> reject:
>> pdu->params_len = htons(1);
>> diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
>> index a33bdfe..d7a805b 100644
>> --- a/android/avrcp-lib.h
>> +++ b/android/avrcp-lib.h
>> @@ -79,8 +79,9 @@ struct avrcp;
>> struct avrcp_control_handler {
>> uint8_t id;
>> uint8_t code;
>> - uint8_t (*func) (struct avrcp *session, uint8_t transaction,
>> - uint16_t *params_len, uint8_t *params, void *user_data);
>> + ssize_t (*func) (struct avrcp *session, uint8_t transaction,
>> + uint8_t *code, uint16_t params_len, uint8_t *params,
>> + void *user_data);
>> };
>>
>> struct avrcp_passthrough_handler {
>> diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
>> index 302c331..2d5711b 100644
>> --- a/unit/test-avrcp.c
>> +++ b/unit/test-avrcp.c
>> @@ -292,54 +292,54 @@ static const struct avrcp_passthrough_handler passthrough_handlers[] = {
>> { },
>> };
>>
>> -static uint8_t avrcp_handle_get_capabilities(struct avrcp *session,
>> - uint8_t transaction, uint16_t *params_len,
>> - uint8_t *params, void *user_data)
>> +static ssize_t avrcp_handle_get_capabilities(struct avrcp *session,
>> + uint8_t transaction, uint8_t *code,
>> + uint16_t params_len, uint8_t *params,
>> + void *user_data)
>> {
>> uint32_t id = 0x001958;
>>
>> - DBG("params[0] %d params_len %d", params[0], *params_len);
>> -
>> - if (*params_len != 1)
>> + if (params_len != 1)
>> goto fail;
>>
>> switch (params[0]) {
>> case CAP_COMPANY_ID:
>> - *params_len = 5;
>> params[1] = 1;
>> hton24(¶ms[2], id);
>> - return AVC_CTYPE_STABLE;
>> + *code = AVC_CTYPE_STABLE;
>> + return 5;
>
> What is 5? Shall we define constants or use formulas?
This is the param length, ideally we should define structs for all the PDUs.
--
Luiz Augusto von Dentz
^ permalink raw reply
* [PATCH 1/9] unit/avrcp: Add /TP/PAS/BV-06-C test
From: Andrei Emeltchenko @ 2014-03-03 12:53 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Test verifies that the list player application setting values response
issued from the Target.
---
unit/test-avrcp.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 302c331..44dc2f2 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -342,6 +342,26 @@ static uint8_t avrcp_handle_get_player_attr_text(struct avrcp *session,
return AVC_CTYPE_STABLE;
}
+static uint8_t avrcp_handle_list_player_values(struct avrcp *session,
+ uint8_t transaction, uint16_t *params_len,
+ uint8_t *params, void *user_data)
+{
+ DBG("params[0] %d params_len %d", params[0], *params_len);
+
+ if (*params_len != 1)
+ goto fail;
+
+ *params_len = 1;
+ params[0] = 0;
+ return AVC_CTYPE_STABLE;
+
+fail:
+ *params_len = 1;
+ params[0] = AVRCP_STATUS_INVALID_PARAM;
+
+ return AVC_CTYPE_REJECTED;
+}
+
static const struct avrcp_control_handler control_handlers[] = {
{ AVRCP_GET_CAPABILITIES, AVC_CTYPE_STATUS,
avrcp_handle_get_capabilities },
@@ -349,6 +369,8 @@ static const struct avrcp_control_handler control_handlers[] = {
avrcp_handle_list_attributes },
{ AVRCP_GET_PLAYER_ATTRIBUTE_TEXT, AVC_CTYPE_STATUS,
avrcp_handle_get_player_attr_text },
+ { AVRCP_LIST_PLAYER_VALUES, AVC_CTYPE_STATUS,
+ avrcp_handle_list_player_values },
{ },
};
@@ -505,5 +527,15 @@ int main(int argc, char *argv[])
AVRCP_GET_PLAYER_ATTRIBUTE_TEXT,
0x00, 0x00, 0x01, 0x00));
+ define_test("/TP/PAS/BV-06-C", test_server,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58,
+ AVRCP_LIST_PLAYER_VALUES,
+ 0x00, 0x00, 0x01, 0x00),
+ raw_pdu(0x02, 0x11, 0x0e, 0x0c, 0x48, 0x00,
+ 0x00, 0x19, 0x58,
+ AVRCP_LIST_PLAYER_VALUES,
+ 0x00, 0x00, 0x01, 0x00));
+
return g_test_run();
}
--
1.8.3.2
^ permalink raw reply related
* [PATCH 2/9] unit/avrcp: Add /TP/PAS/BV-08-C test
From: Andrei Emeltchenko @ 2014-03-03 12:53 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1393851227-23483-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Test verifies that verify the get player application setting values
response issued from the Target.
---
unit/test-avrcp.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 44dc2f2..e45d995 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -362,6 +362,18 @@ fail:
return AVC_CTYPE_REJECTED;
}
+static uint8_t avrcp_handle_get_player_value_text(struct avrcp *session,
+ uint8_t transaction, uint16_t *params_len,
+ uint8_t *params, void *user_data)
+{
+ DBG("");
+
+ *params_len = 1;
+ params[0] = 0;
+
+ return AVC_CTYPE_STABLE;
+}
+
static const struct avrcp_control_handler control_handlers[] = {
{ AVRCP_GET_CAPABILITIES, AVC_CTYPE_STATUS,
avrcp_handle_get_capabilities },
@@ -371,6 +383,8 @@ static const struct avrcp_control_handler control_handlers[] = {
avrcp_handle_get_player_attr_text },
{ AVRCP_LIST_PLAYER_VALUES, AVC_CTYPE_STATUS,
avrcp_handle_list_player_values },
+ { AVRCP_GET_PLAYER_VALUE_TEXT, AVC_CTYPE_STATUS,
+ avrcp_handle_get_player_value_text },
{ },
};
@@ -537,5 +551,15 @@ int main(int argc, char *argv[])
AVRCP_LIST_PLAYER_VALUES,
0x00, 0x00, 0x01, 0x00));
+ define_test("/TP/PAS/BV-08-C", test_server,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58,
+ AVRCP_GET_PLAYER_VALUE_TEXT,
+ 0x00, 0x00, 0x01, 0x00),
+ raw_pdu(0x02, 0x11, 0x0e, 0x0c, 0x48, 0x00,
+ 0x00, 0x19, 0x58,
+ AVRCP_GET_PLAYER_VALUE_TEXT,
+ 0x00, 0x00, 0x01, 0x00));
+
return g_test_run();
}
--
1.8.3.2
^ permalink raw reply related
* [PATCH 3/9] avrcp: Fix buffer size check
From: Andrei Emeltchenko @ 2014-03-03 12:53 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1393851227-23483-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Fix size check taking into account that attributes starts from 1 (0 is
illegal).
---
profiles/audio/avrcp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index bea2dd2..aa932e0 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -1909,7 +1909,7 @@ static void avrcp_get_current_player_value(struct avrcp *session,
struct avrcp_header *pdu = (void *) buf;
uint16_t length = AVRCP_HEADER_LENGTH + count + 1;
- if (count > AVRCP_ATTRIBUTE_LAST + 1)
+ if (count > AVRCP_ATTRIBUTE_LAST)
return;
memset(buf, 0, sizeof(buf));
--
1.8.3.2
^ permalink raw reply related
* [PATCH 4/9] android/avrcp: Add avrcp_get_current_player_value() function
From: Andrei Emeltchenko @ 2014-03-03 12:53 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1393851227-23483-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/avrcp-lib.c | 21 +++++++++++++++++++++
android/avrcp-lib.h | 14 ++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
index 97259d5..39d8d9a 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -308,3 +308,24 @@ int avrcp_get_player_attribute_text(struct avrcp *session, uint8_t *attributes,
AVRCP_GET_PLAYER_ATTRIBUTE_TEXT, attributes,
attr_len, func, user_data);
}
+
+int avrcp_get_current_player_value(struct avrcp *session, uint8_t *attributes,
+ uint8_t attr_count, avctp_rsp_cb func,
+ void *user_data)
+
+{
+ uint8_t buf[AVRCP_ATTRIBUTE_LAST + 1];
+
+ if (attr_count > AVRCP_ATTRIBUTE_LAST)
+ return -EINVAL;
+
+ if (attributes && attr_count) {
+ buf[0] = attr_count;
+ memcpy(buf + 1, attributes, attr_count);
+ }
+
+ return avrcp_send_req(session, AVC_CTYPE_STATUS, AVC_SUBUNIT_PANEL,
+ AVRCP_GET_CURRENT_PLAYER_VALUE, buf,
+ attr_count + 1, func, user_data);
+
+}
diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
index 0407cb4..1f7eab0 100644
--- a/android/avrcp-lib.h
+++ b/android/avrcp-lib.h
@@ -74,6 +74,17 @@
#define CAP_COMPANY_ID 0x02
#define CAP_EVENTS_SUPPORTED 0x03
+/* Player Attributes */
+#define AVRCP_ATTRIBUTE_ILEGAL 0x00
+#define AVRCP_ATTRIBUTE_EQUALIZER 0x01
+#define AVRCP_ATTRIBUTE_REPEAT_MODE 0x02
+#define AVRCP_ATTRIBUTE_SHUFFLE 0x03
+#define AVRCP_ATTRIBUTE_SCAN 0x04
+#define AVRCP_ATTRIBUTE_LAST AVRCP_ATTRIBUTE_SCAN
+
+/* Company IDs for vendor dependent commands */
+#define IEEEID_BTSIG 0x001958
+
struct avrcp;
struct avrcp_control_handler {
@@ -110,3 +121,6 @@ int avrcp_list_player_attributes(struct avrcp *session, avctp_rsp_cb func,
int avrcp_get_player_attribute_text(struct avrcp *session, uint8_t *attributes,
uint8_t attr_len, avctp_rsp_cb func,
void *user_data);
+int avrcp_get_current_player_value(struct avrcp *session, uint8_t *attributes,
+ uint8_t attr_count, avctp_rsp_cb func,
+ void *user_data);
--
1.8.3.2
^ permalink raw reply related
* [PATCH 5/9] unit/avrcp: Add /TP/PAS/BV-09-C test
From: Andrei Emeltchenko @ 2014-03-03 12:53 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1393851227-23483-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Test verifies that get current player application setting value command
issued from the Controller.
---
unit/test-avrcp.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index e45d995..823c750 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -416,6 +416,14 @@ static void test_client(gconstpointer data)
avrcp_get_player_attribute_text(context->session, NULL, 0,
NULL, NULL);
+ if (g_str_equal(context->data->test_name, "/TP/PAS/BV-09-C")) {
+ uint8_t attributes[2] = { AVRCP_ATTRIBUTE_EQUALIZER,
+ AVRCP_ATTRIBUTE_REPEAT_MODE };
+
+ avrcp_get_current_player_value(context->session, attributes,
+ sizeof(attributes), NULL, NULL);
+ }
+
execute_context(context);
}
@@ -561,5 +569,13 @@ int main(int argc, char *argv[])
AVRCP_GET_PLAYER_VALUE_TEXT,
0x00, 0x00, 0x01, 0x00));
+ define_test("/TP/PAS/BV-09-C", test_client,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58,
+ AVRCP_GET_CURRENT_PLAYER_VALUE,
+ 0x00, 0x00, 0x03, 0x02,
+ AVRCP_ATTRIBUTE_EQUALIZER,
+ AVRCP_ATTRIBUTE_REPEAT_MODE));
+
return g_test_run();
}
--
1.8.3.2
^ permalink raw reply related
* [PATCH 6/9] unit/avrcp: Add /TP/PAS/BV-10-C test
From: Andrei Emeltchenko @ 2014-03-03 12:53 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1393851227-23483-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Test verifies that the get current player application setting value
response issued from the Target.
---
unit/test-avrcp.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 823c750..2675bdf 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -374,6 +374,30 @@ static uint8_t avrcp_handle_get_player_value_text(struct avrcp *session,
return AVC_CTYPE_STABLE;
}
+static uint8_t avrcp_handle_get_current_player_value(struct avrcp *session,
+ uint8_t transaction, uint16_t *params_len,
+ uint8_t *params, void *user_data)
+{
+ uint8_t *attributes;
+ int i;
+
+ DBG("num attributes %d", params[0]);
+
+ attributes = g_memdup(¶ms[1], params[0]);
+
+ for (i = 0; i < params[0]; i++) {
+ params[i * 2 + 1] = attributes[i];
+ params[i * 2 + 2] = 0; /* value */
+ }
+
+ g_free(attributes);
+
+ params[0] = i;
+ *params_len = params[0] * 2 + 1;
+
+ return AVC_CTYPE_STABLE;
+}
+
static const struct avrcp_control_handler control_handlers[] = {
{ AVRCP_GET_CAPABILITIES, AVC_CTYPE_STATUS,
avrcp_handle_get_capabilities },
@@ -383,6 +407,8 @@ static const struct avrcp_control_handler control_handlers[] = {
avrcp_handle_get_player_attr_text },
{ AVRCP_LIST_PLAYER_VALUES, AVC_CTYPE_STATUS,
avrcp_handle_list_player_values },
+ { AVRCP_GET_CURRENT_PLAYER_VALUE, AVC_CTYPE_STATUS,
+ avrcp_handle_get_current_player_value },
{ AVRCP_GET_PLAYER_VALUE_TEXT, AVC_CTYPE_STATUS,
avrcp_handle_get_player_value_text },
{ },
@@ -577,5 +603,19 @@ int main(int argc, char *argv[])
AVRCP_ATTRIBUTE_EQUALIZER,
AVRCP_ATTRIBUTE_REPEAT_MODE));
+ define_test("/TP/PAS/BV-10-C", test_server,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58,
+ AVRCP_GET_CURRENT_PLAYER_VALUE,
+ 0x00, 0x00, 0x03, 0x02,
+ AVRCP_ATTRIBUTE_EQUALIZER,
+ AVRCP_ATTRIBUTE_REPEAT_MODE),
+ raw_pdu(0x02, 0x11, 0x0e, 0x0c, 0x48, 0x00,
+ 0x00, 0x19, 0x58,
+ AVRCP_GET_CURRENT_PLAYER_VALUE,
+ 0x00, 0x00, 0x05, 0x02,
+ AVRCP_ATTRIBUTE_EQUALIZER, 0x00,
+ AVRCP_ATTRIBUTE_REPEAT_MODE, 0x00));
+
return g_test_run();
}
--
1.8.3.2
^ permalink raw reply related
* [PATCH 7/9] android/avrcp: Add avrcp_set_player_value() function
From: Andrei Emeltchenko @ 2014-03-03 12:53 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1393851227-23483-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/avrcp-lib.c | 18 ++++++++++++++++++
android/avrcp-lib.h | 3 +++
2 files changed, 21 insertions(+)
diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
index 39d8d9a..63f87da 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -327,5 +327,23 @@ int avrcp_get_current_player_value(struct avrcp *session, uint8_t *attributes,
return avrcp_send_req(session, AVC_CTYPE_STATUS, AVC_SUBUNIT_PANEL,
AVRCP_GET_CURRENT_PLAYER_VALUE, buf,
attr_count + 1, func, user_data);
+}
+
+int avrcp_set_player_value(struct avrcp *session, uint8_t *attributes,
+ uint8_t attr_count, uint8_t *values,
+ avctp_rsp_cb func, void *user_data)
+{
+ uint8_t buf[2 * attr_count + 1];
+ int i;
+ buf[0] = attr_count;
+
+ for (i = 0; i < attr_count; i++) {
+ buf[i * 2 + 1] = attributes[i];
+ buf[i * 2 + 2] = values[i];
+ }
+
+ return avrcp_send_req(session, AVC_CTYPE_CONTROL, AVC_SUBUNIT_PANEL,
+ AVRCP_SET_PLAYER_VALUE, buf, 2 * attr_count + 1,
+ func, user_data);
}
diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
index 1f7eab0..c6d61e4 100644
--- a/android/avrcp-lib.h
+++ b/android/avrcp-lib.h
@@ -124,3 +124,6 @@ int avrcp_get_player_attribute_text(struct avrcp *session, uint8_t *attributes,
int avrcp_get_current_player_value(struct avrcp *session, uint8_t *attributes,
uint8_t attr_count, avctp_rsp_cb func,
void *user_data);
+int avrcp_set_player_value(struct avrcp *session, uint8_t *attributes,
+ uint8_t attr_count, uint8_t *values,
+ avctp_rsp_cb func, void *user_data);
--
1.8.3.2
^ permalink raw reply related
* [PATCH 8/9] unit/avrcp: Add /TP/PAS/BV-11-C test
From: Andrei Emeltchenko @ 2014-03-03 12:53 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1393851227-23483-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Test verifies that the set player application setting value command
issued from the Controller.
---
unit/test-avrcp.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 2675bdf..359359b 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -450,6 +450,16 @@ static void test_client(gconstpointer data)
sizeof(attributes), NULL, NULL);
}
+ if (g_str_equal(context->data->test_name, "/TP/PAS/BV-11-C")) {
+ uint8_t attributes[2] = { AVRCP_ATTRIBUTE_EQUALIZER,
+ AVRCP_ATTRIBUTE_REPEAT_MODE };
+ uint8_t values[] = { 0xaa, 0xff };
+
+ avrcp_set_player_value(context->session, attributes,
+ sizeof(attributes), values,
+ NULL, NULL);
+ }
+
execute_context(context);
}
@@ -617,5 +627,13 @@ int main(int argc, char *argv[])
AVRCP_ATTRIBUTE_EQUALIZER, 0x00,
AVRCP_ATTRIBUTE_REPEAT_MODE, 0x00));
+ define_test("/TP/PAS/BV-11-C", test_client,
+ raw_pdu(0x00, 0x11, 0x0e, 0x00, 0x48, 0x00,
+ 0x00, 0x19, 0x58,
+ AVRCP_SET_PLAYER_VALUE,
+ 0x00, 0x00, 0x05, 0x02,
+ AVRCP_ATTRIBUTE_EQUALIZER, 0xaa,
+ AVRCP_ATTRIBUTE_REPEAT_MODE, 0xff));
+
return g_test_run();
}
--
1.8.3.2
^ permalink raw reply related
* [PATCH 9/9] doc: Update test coverage document
From: Andrei Emeltchenko @ 2014-03-03 12:53 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1393851227-23483-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Update AVRCP test numbers.
---
doc/test-coverage.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/test-coverage.txt b/doc/test-coverage.txt
index 7965f8e..89d884f 100644
--- a/doc/test-coverage.txt
+++ b/doc/test-coverage.txt
@@ -18,7 +18,7 @@ test-ringbuf 3 Ring buffer functionality
test-queue 1 Queue handling functionality
test-avdtp 60 AVDTP qualification test cases
test-avctp 9 AVCTP qualification test cases
-test-avrcp 7 AVRCP qualification test cases
+test-avrcp 23 AVRCP qualification test cases
test-gobex 31 Generic OBEX functionality
test-gobex-packet 9 OBEX packet handling
test-gobex-header 28 OBEX header handling
--
1.8.3.2
^ permalink raw reply related
* Re: [PATCH 1/9] android/tester: Coding style and syntax fix
From: Szymon Janc @ 2014-03-03 12:54 UTC (permalink / raw)
To: Grzegorz Kolodziejczyk; +Cc: linux-bluetooth
In-Reply-To: <1393513490-18674-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
Hi Grzegorz,
On Thursday 27 of February 2014 16:04:42 Grzegorz Kolodziejczyk wrote:
> Remove white spaces, break lines over 80 characters, redundand braces
> for single statement blocks.
> ---
> android/android-tester.c | 44 ++++++++++++++++++++++++++------------------
> 1 file changed, 26 insertions(+), 18 deletions(-)
>
> diff --git a/android/android-tester.c b/android/android-tester.c
> index 79c8e47..a94c536 100644
> --- a/android/android-tester.c
> +++ b/android/android-tester.c
> @@ -1154,7 +1154,7 @@ static void remote_device_properties_cb(bt_status_t status,
> }
>
> static bt_bdaddr_t enable_done_bdaddr_val = { {0x00} };
> -static char enable_done_bdname_val[] = "BlueZ for Android";
> +static const char enable_done_bdname_val[] = "BlueZ for Android";
> static bt_uuid_t enable_done_uuids_val = {
> .uu = { 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00,
> 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb},
> @@ -1305,7 +1305,7 @@ static const struct generic_data bluetooth_getprop_bdaddr_success_test = {
> .expected_adapter_status = BT_STATUS_SUCCESS,
> };
>
> -static char test_bdname[] = "test_bdname_setget";
> +static const char test_bdname[] = "test_bdname_setget";
>
> static struct priority_property getprop_bdname_props[] = {
> {
> @@ -1563,7 +1563,8 @@ static struct priority_property setprop_scanmode_none_props[] = {
> },
> };
>
> -static const struct generic_data bluetooth_setprop_scanmode_none_success2_test = {
> +static const struct generic_data
> + bluetooth_setprop_scanmode_none_success2_test = {
> .expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
> .expected_properties_num = 1,
> .expected_properties = setprop_scanmode_none_props,
> @@ -1601,7 +1602,7 @@ static const struct generic_data bluetooth_discovery_device_found_test = {
> .expected_adapter_status = BT_STATUS_NOT_EXPECTED,
> };
>
> -static char remote_get_properties_bdname_val[] = "00:AA:01:01:00:00";
> +static const char remote_get_properties_bdname_val[] = "00:AA:01:01:00:00";
> static uint32_t remote_get_properties_cod_val = 0;
> static bt_device_type_t remote_get_properties_tod_val = BT_DEVICE_DEVTYPE_BREDR;
> static int32_t remote_get_properties_rssi_val = -60;
> @@ -1657,7 +1658,7 @@ static const struct generic_data bt_dev_getprops_success_test = {
> .expected_adapter_status = BT_STATUS_NOT_EXPECTED,
> };
>
> -static char remote_getprop_bdname_val[] = "00:AA:01:01:00:00";
> +static const char remote_getprop_bdname_val[] = "00:AA:01:01:00:00";
>
> static struct priority_property remote_getprop_bdname_props[] = {
> {
> @@ -1932,7 +1933,7 @@ static const struct generic_data bt_dev_getprop_fname_fail_test = {
> .expected_adapter_status = BT_STATUS_FAIL,
> };
>
> -static char remote_setprop_fname_val[] = "set_fname_test";
> +static const char remote_setprop_fname_val[] = "set_fname_test";
>
> static struct priority_property remote_setprop_fname_props[] = {
> {
> @@ -1959,7 +1960,7 @@ static const struct generic_data bt_dev_setprop_fname_success_test = {
> .expected_adapter_status = BT_STATUS_SUCCESS,
> };
>
> -static char remote_setprop_bdname_val[] = "setprop_bdname_fail";
> +static const char remote_setprop_bdname_val[] = "setprop_bdname_fail";
>
> static struct priority_property remote_setprop_bdname_props[] = {
> {
> @@ -2328,7 +2329,8 @@ static void test_enable(const void *test_data)
>
> init_test_conditions(data);
>
> - bdaddr2android((const bdaddr_t *)bdaddr, &enable_done_bdaddr_val.address);
> + bdaddr2android((const bdaddr_t *)bdaddr,
> + &enable_done_bdaddr_val.address);
>
> adapter_status = data->if_bluetooth->enable();
> check_expected_status(adapter_status);
> @@ -2343,7 +2345,8 @@ static void test_enable_done(const void *test_data)
>
> init_test_conditions(data);
>
> - bdaddr2android((const bdaddr_t *)bdaddr, &enable_done_bdaddr_val.address);
> + bdaddr2android((const bdaddr_t *)bdaddr,
> + &enable_done_bdaddr_val.address);
>
> adapter_status = data->if_bluetooth->enable();
> check_expected_status(adapter_status);
> @@ -2405,7 +2408,8 @@ static void test_getprop_bdaddr_success(const void *test_data)
>
> init_test_conditions(data);
>
> - bdaddr2android((const bdaddr_t *)bdaddr, &test_getprop_bdaddr_val.address);
> + bdaddr2android((const bdaddr_t *)bdaddr,
> + &test_getprop_bdaddr_val.address);
>
> adapter_status = data->if_bluetooth->get_adapter_property(prop.type);
> check_expected_status(adapter_status);
> @@ -3779,7 +3783,6 @@ static void emu_powered_complete(uint16_t opcode, uint8_t status,
> bt_status = data->if_hid->connect(&bdaddr);
> if (bt_status != BT_STATUS_SUCCESS)
> tester_setup_failed();
> -
> }
>
> static void setup_hidhost_connect(const void *test_data)
> @@ -3978,15 +3981,20 @@ int main(int argc, char *argv[])
>
> test_bredrle("Bluetooth Init", NULL, setup_base, test_dummy, teardown);
>
> - test_bredrle("Bluetooth Enable - Success", &bluetooth_enable_success_test,
> - setup_base, test_enable, teardown);
> + test_bredrle("Bluetooth Enable - Success",
> + &bluetooth_enable_success_test,
> + setup_base, test_enable,
> + teardown);
>
> test_bredrle("Bluetooth Enable - Success 2",
> - &bluetooth_enable_success2_test, setup_enabled_adapter,
> - test_enable_done, teardown);
> -
> - test_bredrle("Bluetooth Disable - Success", &bluetooth_disable_success_test,
> - setup_enabled_adapter, test_disable, teardown);
> + &bluetooth_enable_success2_test,
> + setup_enabled_adapter,
> + test_enable_done, teardown);
> +
> + test_bredrle("Bluetooth Disable - Success",
> + &bluetooth_disable_success_test,
> + setup_enabled_adapter,
> + test_disable, teardown);
>
> test_bredrle("Bluetooth Set BDNAME - Success",
> &bluetooth_setprop_bdname_success_test,
>
This patch is now applied. Thnaks.
--
Best regards,
Szymon Janc
^ permalink raw reply
* Re: [PATCH v2 1/8] android/tester: Add create bond with PIN success test case
From: Szymon Janc @ 2014-03-03 12:55 UTC (permalink / raw)
To: Grzegorz Kolodziejczyk; +Cc: linux-bluetooth
In-Reply-To: <1393843458-5237-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
Hi Grzegorz,
On Monday 03 of March 2014 11:44:11 Grzegorz Kolodziejczyk wrote:
> This adds create bond with PIN success test case.
> ---
> android/android-tester.c | 138 ++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 136 insertions(+), 2 deletions(-)
>
> diff --git a/android/android-tester.c b/android/android-tester.c
> index a94c536..df89d82 100644
> --- a/android/android-tester.c
> +++ b/android/android-tester.c
> @@ -124,6 +124,8 @@ struct bt_cb_data {
> bt_status_t status;
>
> bt_bdaddr_t bdaddr;
> + bt_bdname_t bdname;
> + uint32_t cod;
>
> int num;
> bt_property_t *props;
> @@ -1019,6 +1021,22 @@ static void remote_setprop_fail_device_found_cb(int num_properties,
> check_expected_status(status);
> }
>
> +static void bond_device_found_cb(int num_properties, bt_property_t *properties)
> +{
> + struct test_data *data = tester_get_data();
> + uint8_t *bdaddr = (uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
> + bt_bdaddr_t remote_addr;
> + bt_status_t status;
> +
> + bdaddr2android((const bdaddr_t *)bdaddr, &remote_addr.address);
> +
> + if (data->cb_count == 4) {
> + data->cb_count--;
> + status = data->if_bluetooth->create_bond(&remote_addr);
> + check_expected_status(status);
> + }
> +}
> +
> static gboolean device_found(gpointer user_data)
> {
> struct test_data *data = tester_get_data();
> @@ -1153,6 +1171,92 @@ static void remote_device_properties_cb(bt_status_t status,
> g_idle_add(remote_device_properties, cb_data);
> }
>
> +static void bond_test_bonded_state_changed_cb(bt_status_t status,
> + bt_bdaddr_t *remote_bd_addr, bt_bond_state_t state)
> +{
> + struct test_data *data = tester_get_data();
> +
> + switch (state) {
> + case BT_BOND_STATE_BONDING:
> + data->cb_count--;
> + break;
> + case BT_BOND_STATE_BONDED:
> + data->cb_count--;
> + check_cb_count();
> + break;
> + default:
> + tester_test_failed();
> + break;
> + }
> +}
> +
> +static gboolean bond_state_changed(gpointer user_data)
> +{
> + struct test_data *data = tester_get_data();
> + const struct generic_data *test = data->test_data;
> + struct bt_cb_data *cb_data = user_data;
> +
> + if (data->test_init_done && test->expected_hal_cb.bond_state_changed_cb)
> + test->expected_hal_cb.bond_state_changed_cb(cb_data->status,
> + &cb_data->bdaddr, cb_data->state);
> +
> + g_free(cb_data);
> + return FALSE;
> +}
> +
> +static void bond_state_changed_cb(bt_status_t status,
> + bt_bdaddr_t *remote_bd_addr, bt_bond_state_t state)
> +{
> + struct bt_cb_data *cb_data = g_new0(struct bt_cb_data, 1);
> +
> + cb_data->status = status;
> + cb_data->bdaddr = *remote_bd_addr;
> + cb_data->state = state;
> +
> + g_idle_add(bond_state_changed, cb_data);
> +}
> +
> +static void bond_create_pin_success_request_cb(bt_bdaddr_t *remote_bd_addr,
> + bt_bdname_t *bd_name, uint32_t cod)
> +{
> + struct test_data *data = tester_get_data();
> + const bt_bdaddr_t *bdaddr = remote_bd_addr;
> + bt_pin_code_t pin_code = {
> + .pin = { 0x30, 0x30, 0x30, 0x30 },
> + };
> + uint8_t pin_len = 4;
> +
> + data->cb_count--;
> +
> + data->if_bluetooth->pin_reply(bdaddr, TRUE, pin_len, &pin_code);
> +}
> +
> +static gboolean pin_request(gpointer user_data)
> +{
> + struct test_data *data = tester_get_data();
> + const struct generic_data *test = data->test_data;
> + struct bt_cb_data *cb_data = user_data;
> +
> + if (data->test_init_done && test->expected_hal_cb.pin_request_cb)
> + test->expected_hal_cb.pin_request_cb(&cb_data->bdaddr,
> + &cb_data->bdname, cb_data->cod);
> +
> + g_free(cb_data);
> + return FALSE;
> +}
> +
> +static void pin_request_cb(bt_bdaddr_t *remote_bd_addr,
> + bt_bdname_t *bd_name, uint32_t cod)
> +{
> + struct bt_cb_data *cb_data = g_new0(struct bt_cb_data, 1);
> +
> + cb_data->bdaddr = *remote_bd_addr;
> + cb_data->bdname = *bd_name;
> + cb_data->cod = cod;
> +
> + g_idle_add(pin_request, cb_data);
> +}
> +
> static bt_bdaddr_t enable_done_bdaddr_val = { {0x00} };
> static const char enable_done_bdname_val[] = "BlueZ for Android";
> static bt_uuid_t enable_done_uuids_val = {
> @@ -2175,6 +2279,15 @@ static const struct generic_data bt_dev_setprop_disctimeout_fail_test = {
> .expected_adapter_status = BT_STATUS_FAIL,
> };
>
> +static const struct generic_data bt_bond_create_pin_success_test = {
> + .expected_hal_cb.device_found_cb = bond_device_found_cb,
> + .expected_hal_cb.bond_state_changed_cb =
> + bond_test_bonded_state_changed_cb,
> + .expected_hal_cb.pin_request_cb = bond_create_pin_success_request_cb,
> + .expected_cb_count = 4,
> + .expected_adapter_status = BT_STATUS_SUCCESS,
> +};
> +
> static bt_callbacks_t bt_callbacks = {
> .size = sizeof(bt_callbacks),
> .adapter_state_changed_cb = adapter_state_changed_cb,
> @@ -2182,9 +2295,9 @@ static bt_callbacks_t bt_callbacks = {
> .remote_device_properties_cb = remote_device_properties_cb,
> .device_found_cb = device_found_cb,
> .discovery_state_changed_cb = discovery_state_changed_cb,
> - .pin_request_cb = NULL,
> + .pin_request_cb = pin_request_cb,
> .ssp_request_cb = NULL,
> - .bond_state_changed_cb = NULL,
> + .bond_state_changed_cb = bond_state_changed_cb,
> .acl_state_changed_cb = NULL,
> .thread_evt_cb = NULL,
> .dut_mode_recv_cb = NULL,
> @@ -2913,6 +3026,22 @@ static void test_dev_setprop_disctimeout_fail(const void *test_data)
>
> data->if_bluetooth->start_discovery();
> }
> +static void test_bond_create_pin_success(const void *test_data)
> +{
> + struct test_data *data = tester_get_data();
> + struct bthost *bthost = hciemu_client_get_host(data->hciemu);
> +
> + static uint8_t pair_device_pin[] = { 0x30, 0x30, 0x30, 0x30 };
> + const void *pin = pair_device_pin;
> + uint8_t pin_len = 4;
> +
> + init_test_conditions(data);
> +
> + bthost_set_pin_code(bthost, pin, pin_len);
> +
> + data->if_bluetooth->start_discovery();
> +}
> +
> /* Test Socket HAL */
>
> static gboolean adapter_socket_state_changed(gpointer user_data)
> @@ -4251,6 +4380,11 @@ int main(int argc, char *argv[])
> setup_enabled_adapter,
> test_dev_setprop_disctimeout_fail, teardown);
>
> + test_bredrle("Bluetooth Create Bond PIN - Success",
> + &bt_bond_create_pin_success_test,
> + setup_enabled_adapter,
> + test_bond_create_pin_success, teardown);
> +
> test_bredrle("Socket Init", NULL, setup_socket_interface,
> test_dummy, teardown);
>
All patches applied. Thanks.
--
Best regards,
Szymon Janc
^ permalink raw reply
* Re: [PATCH v2] android/avrcp-lib: Fix destroy callback handling
From: Luiz Augusto von Dentz @ 2014-03-03 14:16 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1393842906-5883-1-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
On Mon, Mar 3, 2014 at 12:35 PM, Szymon Janc <szymon.janc@tieto.com> wrote:
> AVRCP destroy callback was directly passed as AVCTP destroy callback
> resulting in struct avrcp not being freed on remote disconnect.
>
> This fix following Valgrind report:
>
> 931 (36 direct, 895 indirect) bytes in 1 blocks are definitely lost in
> loss record 53 of 55
> at 0x4896DC8: calloc (in /system/lib/valgrind/
> vgpreload_memcheck-arm-linux.so)
> by 0x48C5DB7: g_malloc0 (gmem.c:189)
> by 0x118671: avrcp_new (avrcp-lib.c:219)
> by 0x117D4F: connect_cb (avrcp.c:346)
> by 0x12068B: connect_cb (btio.c:232)
> by 0x48BD9C7: g_io_unix_dispatch (giounix.c:166)
> by 0x48C2CCB: g_main_context_dispatch (gmain.c:2539)
> by 0x48C2ED9: g_main_context_iterate.isra.19 (gmain.c:3146)
> by 0x48C3167: g_main_loop_run (gmain.c:3340)
> by 0x10BA03: main (main.c:490)
> ---
>
> v2: fix crash on local shutdown due to double call to avrcp_shutdown,
> now avctp destroy callback is cleared when shuting down localy.
>
> android/avrcp-lib.c | 23 ++++++++++++++++++++++-
> 1 file changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
> index 26bcce1..c5cfa12 100644
> --- a/android/avrcp-lib.c
> +++ b/android/avrcp-lib.c
> @@ -98,6 +98,9 @@ struct avrcp {
> const struct avrcp_passthrough_handler *passthrough_handlers;
> void *passthrough_data;
> unsigned int passthrough_id;
> +
> + avrcp_destroy_cb_t destroy;
> + void *destroy_data;
> };
>
> void avrcp_shutdown(struct avrcp *session)
> @@ -109,9 +112,15 @@ void avrcp_shutdown(struct avrcp *session)
> if (session->passthrough_id > 0)
> avctp_unregister_passthrough_handler(session->conn,
> session->passthrough_id);
> +
> + /* clear destroy callback that would call shutdown again */
> + avctp_set_destroy_cb(session->conn, NULL, NULL);
> avctp_shutdown(session->conn);
> }
>
> + if (session->destroy)
> + session->destroy(session->destroy_data);
> +
> g_free(session->tx_buf);
> g_free(session);
> }
> @@ -199,6 +208,15 @@ static bool handle_passthrough_pdu(struct avctp *conn, uint8_t op,
> return handler->func(session);
> }
>
> +static void disconnect_cb(void *data)
> +{
> + struct avrcp *session = data;
> +
> + session->conn = NULL;
> +
> + avrcp_shutdown(session);
> +}
> +
> struct avrcp *avrcp_new(int fd, size_t imtu, size_t omtu, uint16_t version)
> {
> struct avrcp *session;
> @@ -223,13 +241,16 @@ struct avrcp *avrcp_new(int fd, size_t imtu, size_t omtu, uint16_t version)
> handle_vendordep_pdu,
> session);
>
> + avctp_set_destroy_cb(session->conn, disconnect_cb, session);
> +
> return session;
> }
>
> void avrcp_set_destroy_cb(struct avrcp *session, avrcp_destroy_cb_t cb,
> void *user_data)
> {
> - avctp_set_destroy_cb(session->conn, cb, user_data);
> + session->destroy = cb;
> + session->destroy_data = user_data;
> }
>
> void avrcp_set_control_handlers(struct avrcp *session,
> --
> 1.8.5.3
Pushed, thanks.
--
Luiz Augusto von Dentz
^ 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