This patch set fixes the issue with Gatt: Double Listen test case, in which
we were trying to reconnect the emulated remote while the ACL was still
connected.
Jakub Tyszkowski (2):
android/tester: Wait for ACL disconnection before reconnect
android/tester: Make Gatt stop listening after ACL disconnects
Marcin Kraglak (2):
emulator/bthost: Add hci disconnect
android/tester: Force remotes ACL disconnection
android/tester-gatt.c | 23 ++++++++++++++++++++---
android/tester-main.c | 15 ++++++++++++++-
emulator/bthost.c | 11 +++++++++++
emulator/bthost.h | 3 +++
4 files changed, 48 insertions(+), 4 deletions(-)
--
1.9.1
Hi Jakub,
On Friday 22 of August 2014 14:40:45 Jakub Tyszkowski wrote:
> This patch set fixes the issue with Gatt: Double Listen test case, in which
> we were trying to reconnect the emulated remote while the ACL was still
> connected.
>
> Jakub Tyszkowski (2):
> android/tester: Wait for ACL disconnection before reconnect
> android/tester: Make Gatt stop listening after ACL disconnects
>
> Marcin Kraglak (2):
> emulator/bthost: Add hci disconnect
> android/tester: Force remotes ACL disconnection
>
> android/tester-gatt.c | 23 ++++++++++++++++++++---
> android/tester-main.c | 15 ++++++++++++++-
> emulator/bthost.c | 11 +++++++++++
> emulator/bthost.h | 3 +++
> 4 files changed, 48 insertions(+), 4 deletions(-)
>
Patches 1-3 applied. Thanks.
--
Best regards,
Szymon Janc
From: Marcin Kraglak <[email protected]>
This is needed or else we would need to extend the timeout for a single
test case in tester framework and wait two more seconds for ACL to disconnect.
---
android/tester-gatt.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/android/tester-gatt.c b/android/tester-gatt.c
index 0d99320..1d66309 100644
--- a/android/tester-gatt.c
+++ b/android/tester-gatt.c
@@ -286,6 +286,19 @@ static void emu_remote_connect_hci_action(void)
schedule_action_verification(step);
}
+static void emu_remote_disconnect_hci_action(void)
+{
+ struct test_data *data = tester_get_data();
+ struct bthost *bthost = hciemu_client_get_host(data->hciemu);
+ struct step *step = g_new0(struct step, 1);
+
+ bthost_hci_disconnect(bthost, cid_data.handle, 0x13);
+
+ step->action_status = BT_STATUS_SUCCESS;
+
+ schedule_action_verification(step);
+}
+
static struct test_case test_cases[] = {
TEST_CASE_BREDRLE("Gatt Init",
ACTION_SUCCESS(dummy_action, NULL),
@@ -453,6 +466,8 @@ static struct test_case test_cases[] = {
CALLBACK_GATTC_DISCONNECT(GATT_STATUS_SUCCESS,
prop_emu_remotes_default_set,
CONN1_ID, CLIENT1_ID),
+ /* Close ACL on emulated remotes side so it can reconnect */
+ ACTION_SUCCESS(emu_remote_disconnect_hci_action, NULL),
CALLBACK_STATE(CB_BT_ACL_STATE_CHANGED,
BT_ACL_STATE_DISCONNECTED),
ACTION_SUCCESS(gatt_client_do_listen_action, &client1_conn_req),
--
1.9.1
We are getting busy result if we try to stop the listen while ACL is
still connected.
---
android/tester-gatt.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/android/tester-gatt.c b/android/tester-gatt.c
index 1d66309..10939e7 100644
--- a/android/tester-gatt.c
+++ b/android/tester-gatt.c
@@ -458,9 +458,6 @@ static struct test_case test_cases[] = {
CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
prop_emu_remotes_default_set,
CONN1_ID, CLIENT1_ID),
- ACTION_SUCCESS(gatt_client_stop_listen_action,
- &client1_conn_req),
- CALLBACK_STATUS(CB_GATTC_LISTEN, GATT_STATUS_SUCCESS),
ACTION_SUCCESS(gatt_client_disconnect_action,
&client1_conn_req),
CALLBACK_GATTC_DISCONNECT(GATT_STATUS_SUCCESS,
@@ -470,6 +467,9 @@ static struct test_case test_cases[] = {
ACTION_SUCCESS(emu_remote_disconnect_hci_action, NULL),
CALLBACK_STATE(CB_BT_ACL_STATE_CHANGED,
BT_ACL_STATE_DISCONNECTED),
+ ACTION_SUCCESS(gatt_client_stop_listen_action,
+ &client1_conn_req),
+ CALLBACK_STATUS(CB_GATTC_LISTEN, GATT_STATUS_SUCCESS),
ACTION_SUCCESS(gatt_client_do_listen_action, &client1_conn_req),
CALLBACK_STATUS(CB_GATTC_LISTEN, GATT_STATUS_SUCCESS),
ACTION_SUCCESS(emu_remote_connect_hci_action, NULL),
--
1.9.1
We need the remote to drop its ACL before it tries to connect again.
---
android/tester-gatt.c | 2 ++
android/tester-main.c | 15 ++++++++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/android/tester-gatt.c b/android/tester-gatt.c
index d69b027..0d99320 100644
--- a/android/tester-gatt.c
+++ b/android/tester-gatt.c
@@ -453,6 +453,8 @@ static struct test_case test_cases[] = {
CALLBACK_GATTC_DISCONNECT(GATT_STATUS_SUCCESS,
prop_emu_remotes_default_set,
CONN1_ID, CLIENT1_ID),
+ CALLBACK_STATE(CB_BT_ACL_STATE_CHANGED,
+ BT_ACL_STATE_DISCONNECTED),
ACTION_SUCCESS(gatt_client_do_listen_action, &client1_conn_req),
CALLBACK_STATUS(CB_GATTC_LISTEN, GATT_STATUS_SUCCESS),
ACTION_SUCCESS(emu_remote_connect_hci_action, NULL),
diff --git a/android/tester-main.c b/android/tester-main.c
index 5f41ff1..369a943 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -841,6 +841,19 @@ static void ssp_request_cb(bt_bdaddr_t *remote_bd_addr,
schedule_callback_call(step);
}
+static void acl_state_changed_cb(bt_status_t status,
+ bt_bdaddr_t *remote_bd_addr,
+ bt_acl_state_t state) {
+ struct step *step = g_new0(struct step, 1);
+
+ step->callback = CB_BT_ACL_STATE_CHANGED;
+
+ step->callback_result.status = status;
+ step->callback_result.state = state;
+
+ schedule_callback_call(step);
+}
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -851,7 +864,7 @@ static bt_callbacks_t bt_callbacks = {
.pin_request_cb = pin_request_cb,
.ssp_request_cb = ssp_request_cb,
.bond_state_changed_cb = bond_state_changed_cb,
- .acl_state_changed_cb = NULL,
+ .acl_state_changed_cb = acl_state_changed_cb,
.thread_evt_cb = NULL,
.dut_mode_recv_cb = NULL,
.le_test_mode_cb = NULL
--
1.9.1
From: Marcin Kraglak <[email protected]>
---
emulator/bthost.c | 11 +++++++++++
emulator/bthost.h | 3 +++
2 files changed, 14 insertions(+)
diff --git a/emulator/bthost.c b/emulator/bthost.c
index b30999b..1394fca 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -2069,6 +2069,17 @@ void bthost_hci_connect(struct bthost *bthost, const uint8_t *bdaddr,
}
}
+void bthost_hci_disconnect(struct bthost *bthost, uint16_t handle,
+ uint8_t reason)
+{
+ struct bt_hci_cmd_disconnect disc;
+
+ disc.handle = cpu_to_le16(handle);
+ disc.reason = reason;
+
+ send_command(bthost, BT_HCI_CMD_DISCONNECT, &disc, sizeof(disc));
+}
+
void bthost_write_scan_enable(struct bthost *bthost, uint8_t scan)
{
send_command(bthost, BT_HCI_CMD_WRITE_SCAN_ENABLE, &scan, 1);
diff --git a/emulator/bthost.h b/emulator/bthost.h
index 4a7e2bd..d7d3d8a 100644
--- a/emulator/bthost.h
+++ b/emulator/bthost.h
@@ -52,6 +52,9 @@ void bthost_set_connect_cb(struct bthost *bthost, bthost_new_conn_cb cb,
void bthost_hci_connect(struct bthost *bthost, const uint8_t *bdaddr,
uint8_t addr_type);
+void bthost_hci_disconnect(struct bthost *bthost, uint16_t handle,
+ uint8_t reason);
+
typedef void (*bthost_cid_hook_func_t)(const void *data, uint16_t len,
void *user_data);
--
1.9.1