diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 0aef944..7db0d41 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
uint32_t initial_settings;
struct mgmt *mgmt;
struct mgmt *mgmt_alt;
+ unsigned int mgmt_settings_id;
+ unsigned int mgmt_alt_settings_id;
+ unsigned int mgmt_alt_class_id;
uint8_t mgmt_version;
uint16_t mgmt_revision;
uint16_t mgmt_index;
uint16_t expect_len;
uint32_t expect_settings_set;
uint32_t expect_settings_unset;
+ const void *expect_class_of_dev;
uint16_t expect_hci_command;
const void *expect_hci_param;
uint8_t expect_hci_len;
.expect_status = MGMT_STATUS_SUCCESS,
.expect_param = set_dev_class_valid_rsp,
.expect_len = sizeof(set_dev_class_valid_rsp),
+ .expect_class_of_dev = set_dev_class_valid_rsp,
.expect_hci_command = BT_HCI_CMD_WRITE_CLASS_OF_DEV,
.expect_hci_param = set_dev_class_valid_hci,
.expect_hci_len = sizeof(set_dev_class_valid_hci),
tester_print("New settings event received");
- mgmt_unregister_index(data->mgmt, index);
+ mgmt_unregister(data->mgmt, data->mgmt_settings_id);
tester_test_failed();
}
done:
tester_print("Unregistering new settings notification");
- mgmt_unregister_index(data->mgmt_alt, index);
+ mgmt_unregister(data->mgmt_alt, data->mgmt_alt_settings_id);
if (test->expect_hci_command && !data->hci_commands_complete) {
tester_warn("Settings received without expected HCI command");
tester_test_passed();
}
+static void command_generic_class_changed_alt(uint16_t index, uint16_t length,
+ const void *param, void *user_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const struct mgmt_ev_class_of_dev_changed *ev = param;
+
+ if (length != sizeof(*ev)) {
+ tester_warn("Invalid length Class of Device changed event");
+ tester_test_failed();
+ return;
+ }
+
+ tester_print("New Class of Device 0x%02x%02x%02x received",
+ ev->class_of_dev[2], ev->class_of_dev[1],
+ ev->class_of_dev[0]);
+
+ if (!test->expect_class_of_dev)
+ return;
+
+ if (memcmp(ev->class_of_dev, test->expect_class_of_dev, 3) != 0)
+ return;
+
+ tester_print("Unregistering Class of Device notification");
+
+ mgmt_unregister(data->mgmt_alt, data->mgmt_alt_class_id);
+
+ if (test->expect_hci_command && !data->hci_commands_complete) {
+ tester_warn("CoD changed without expected HCI command");
+ tester_test_failed();
+ return;
+ }
+
+ tester_test_passed();
+}
+
static void command_generic_callback(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
{
struct test_data *data = tester_get_data();
const struct generic_data *test = data->test_data;
+ unsigned int id;
uint16_t index;
index = test->send_index_none ? MGMT_INDEX_NONE : data->mgmt_index;
if (test->expect_settings_set) {
tester_print("Registering new settings notification");
- mgmt_register(data->mgmt, MGMT_EV_NEW_SETTINGS, index,
+ id = mgmt_register(data->mgmt, MGMT_EV_NEW_SETTINGS, index,
command_generic_new_settings, NULL, NULL);
+ data->mgmt_settings_id = id;
- mgmt_register(data->mgmt_alt, MGMT_EV_NEW_SETTINGS, index,
+ id = mgmt_register(data->mgmt_alt, MGMT_EV_NEW_SETTINGS, index,
command_generic_new_settings_alt, NULL, NULL);
+ data->mgmt_alt_settings_id = id;
+ }
+
+ if (test->expect_class_of_dev) {
+ tester_print("Registering Class of Device notification");
+ id = mgmt_register(data->mgmt_alt,
+ MGMT_EV_CLASS_OF_DEV_CHANGED, index,
+ command_generic_class_changed_alt,
+ NULL, NULL);
+ data->mgmt_alt_class_id = id;
}
if (test->expect_hci_command) {