diff --git a/android/tester-gatt.c b/android/tester-gatt.c
index c0065a7..2ceb295 100644
--- a/android/tester-gatt.c
+++ b/android/tester-gatt.c
#define L2CAP_ATT_EXCHANGE_MTU_REQ 0x02
#define L2CAP_ATT_EXCHANGE_MTU_RSP 0x03
+#define L2CAP_ATT_HANDLE_VALUE_NOTIFY 0x1b
+#define L2CAP_ATT_HANDLE_VALUE_IND 0x1d
#define GATT_STATUS_SUCCESS 0x00000000
#define GATT_STATUS_FAILURE 0x00000101
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 },
};
+static uint8_t value_1[] = {0x01};
+
struct gatt_connect_data {
const int app_id;
const int conn_id;
int *srvc_handle;
};
+struct send_indication_data {
+ int app_id;
+ int *attr_handle;
+ int conn_id;
+ int len;
+ int confirm;
+ char *p_value;
+};
+
static bt_bdaddr_t emu_remote_bdaddr_val = {
.address = { 0x00, 0xaa, 0x01, 0x01, 0x00, 0x00 },
};
.app_id = APP1_ID,
.srvc_handle = &srvc_bad_handle
};
+
+static int srvc_indication_handle_1 = 0x01;
+
+static struct send_indication_data send_indication_data_1 = {
+ .app_id = APP1_ID,
+ .attr_handle = &srvc_indication_handle_1,
+ .conn_id = CONN1_ID,
+ .len = sizeof(value_2),
+ .p_value = value_2,
+ .confirm = 1
+};
+
+static struct send_indication_data send_indication_data_2 = {
+ .app_id = APP1_ID,
+ .attr_handle = &srvc_indication_handle_1,
+ .conn_id = CONN1_ID,
+ .len = sizeof(value_2),
+ .p_value = value_2,
+ .confirm = 0
+};
+
+static struct send_indication_data send_bad_indication_data_1 = {
+ .app_id = APP1_ID,
+ .attr_handle = &srvc_indication_handle_1,
+ .conn_id = CONN2_ID,
+ .len = sizeof(value_2),
+ .p_value = value_2,
+ .confirm = 0
+};
+
struct set_read_params {
btgatt_read_params_t *params;
btgatt_srvc_id_t *srvc_id;
bt_bdaddr_t *bdaddr;
};
-static uint8_t value_1[] = {0x01};
-
static struct set_read_params set_read_param_1 = {
.params = &read_params_1,
.srvc_id = &service_1,
end_pdu
};
+static struct iovec send_indication_1[] = {
+ raw_pdu(0x1d, 0x01, 0x00, 0x00, 0x01, 0x02, 0x03),
+ raw_pdu(0x1e),
+ end_pdu
+};
+
+static struct iovec send_notification_1[] = {
+ raw_pdu(0x1b, 0x01, 0x00, 0x00, 0x01, 0x02, 0x03),
+ end_pdu
+};
+
static void gatt_client_register_action(void)
{
struct test_data *data = tester_get_data();
schedule_action_verification(step);
}
+static void gatt_server_send_indication_action(void)
+{
+ struct test_data *data = tester_get_data();
+ struct step *current_data_step = queue_peek_head(data->steps);
+ struct send_indication_data *send_indication_data =
+ current_data_step->set_data;
+ struct step *step = g_new0(struct step, 1);
+
+ step->action_status = data->if_gatt->server->send_indication(
+ send_indication_data->app_id,
+ *send_indication_data->attr_handle,
+ send_indication_data->conn_id,
+ send_indication_data->len,
+ send_indication_data->confirm,
+ send_indication_data->p_value);
+
+ schedule_action_verification(step);
+}
+
static void gatt_cid_hook_cb(const void *data, uint16_t len, void *user_data)
{
struct test_data *t_data = tester_get_data();
struct emu_l2cap_cid_data *cid_data = user_data;
const uint8_t *pdu = data;
struct iovec *gatt_pdu = queue_peek_head(t_data->pdus);
+ struct step *step;
tester_debug("Received att pdu with opcode 0x%02x", pdu[0]);
tester_print("Exchange MTU response received.");
break;
+ case L2CAP_ATT_HANDLE_VALUE_IND:
+ step = g_new0(struct step, 1);
+
+ step->callback = CB_EMU_VALUE_INDICATION;
+
+ schedule_callback_verification(step);
+ break;
+ case L2CAP_ATT_HANDLE_VALUE_NOTIFY:
+ step = g_new0(struct step, 1);
+
+ step->callback = CB_EMU_VALUE_NOTIFICATION;
+
+ schedule_callback_verification(step);
+ break;
default:
if (!gatt_pdu || !gatt_pdu->iov_base) {
tester_print("Unknown ATT packet.");
CALLBACK_GATTS_SERVICE_DELETED(GATT_STATUS_FAILURE, APP1_ID,
NULL),
),
+ TEST_CASE_BREDRLE("Gatt Server - Send Indication",
+ ACTION_SUCCESS(init_pdus, send_indication_1),
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
+ ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
+ ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
+ ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
+ CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
+ ACTION_SUCCESS(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ CALLBACK_DEVICE_FOUND(prop_emu_remotes_default_le_set, 2),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ ACTION_SUCCESS(gatt_server_connect_action, &app1_conn_req),
+ CALLBACK_GATTS_CONNECTION(GATT_SERVER_CONNECTED,
+ prop_emu_remotes_default_set,
+ CONN1_ID, APP1_ID),
+ ACTION_SUCCESS(gatt_server_send_indication_action,
+ &send_indication_data_1),
+ CALLBACK(CB_EMU_VALUE_INDICATION),
+ ACTION_SUCCESS(bluetooth_disable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
+ ),
+ TEST_CASE_BREDRLE("Gatt Server - Send Notification",
+ ACTION_SUCCESS(init_pdus, send_notification_1),
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
+ ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
+ ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
+ ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
+ CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
+ ACTION_SUCCESS(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ CALLBACK_DEVICE_FOUND(prop_emu_remotes_default_le_set, 2),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ ACTION_SUCCESS(gatt_server_connect_action, &app1_conn_req),
+ CALLBACK_GATTS_CONNECTION(GATT_SERVER_CONNECTED,
+ prop_emu_remotes_default_set,
+ CONN1_ID, APP1_ID),
+ ACTION_SUCCESS(gatt_server_send_indication_action,
+ &send_indication_data_2),
+ CALLBACK(CB_EMU_VALUE_NOTIFICATION),
+ ACTION_SUCCESS(bluetooth_disable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
+ ),
+ TEST_CASE_BREDRLE("Gatt Server - Send Notification, wrong conn id",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
+ ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
+ ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
+ ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
+ CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
+ ACTION_SUCCESS(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ CALLBACK_DEVICE_FOUND(prop_emu_remotes_default_le_set, 2),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ ACTION_SUCCESS(gatt_server_connect_action, &app1_conn_req),
+ CALLBACK_GATTS_CONNECTION(GATT_SERVER_CONNECTED,
+ prop_emu_remotes_default_set,
+ CONN1_ID, APP1_ID),
+ ACTION_FAIL(gatt_server_send_indication_action,
+ &send_bad_indication_data_1),
+ ACTION_SUCCESS(bluetooth_disable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
+ ),
};
struct queue *get_gatt_tests(void)
diff --git a/android/tester-main.c b/android/tester-main.c
index fc1de06..58f9e9f 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
DBG_CB(CB_EMU_ENCRYPTION_ENABLED),
DBG_CB(CB_EMU_ENCRYPTION_DISABLED),
DBG_CB(CB_EMU_CONNECTION_REJECTED),
+ DBG_CB(CB_EMU_VALUE_INDICATION),
+ DBG_CB(CB_EMU_VALUE_NOTIFICATION),
};
static gboolean check_callbacks_called(gpointer user_data)
diff --git a/android/tester-main.h b/android/tester-main.h
index 22c5c8b..31d271a 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
CB_EMU_ENCRYPTION_ENABLED,
CB_EMU_ENCRYPTION_DISABLED,
CB_EMU_CONNECTION_REJECTED,
+ CB_EMU_VALUE_INDICATION,
+ CB_EMU_VALUE_NOTIFICATION,
} expected_bt_callback_t;
struct test_data {