static void test_pre_setup(const void *test_data) { struct test_data *data = tester_get_data(); data->crypto = bt_crypto_new(); if (!data->crypto) { tester_warn("Failed to setup crypto"); tester_pre_setup_failed(); return; } data->mgmt = mgmt_new_default(); if (!data->mgmt) { tester_warn("Failed to setup management interface"); bt_crypto_unref(data->crypto); tester_pre_setup_failed(); return; } if (tester_use_debug()) mgmt_set_debug(data->mgmt, mgmt_debug, "mgmt: ", NULL); mgmt_send(data->mgmt, MGMT_OP_READ_INDEX_LIST, MGMT_INDEX_NONE, 0, NULL, read_index_list_callback, NULL, NULL); }
static void mgmt_setup(void) { mgmt_master = mgmt_new_default(); if (!mgmt_master) { DBG("Could not connect to the BT management interface, try with su rights"); } else { mgmt_set_debug(mgmt_master, mgmt_debug, "mgmt: ", NULL); /* For READ_VERSION, it is mandatory to use INDEX_NONE */ if (!mgmt_send(mgmt_master, MGMT_OP_READ_VERSION, MGMT_INDEX_NONE, 0, NULL, read_version_complete, NULL, NULL)) { DBG("mgmt_send(MGMT_OP_READ_VERSION) failed"); } if (!mgmt_register(mgmt_master, MGMT_EV_DEVICE_CONNECTED, opt_src_idx, mgmt_device_connected, NULL, NULL)) { DBG("mgmt_register(MGMT_EV_DEVICE_CONNECTED) failed"); } if (!mgmt_register(mgmt_master, MGMT_EV_DEVICE_DISCONNECTED, opt_src_idx, mgmt_device_disconnected, NULL, NULL)) { DBG("mgmt_register(MGMT_EV_DEVICE_DISCONNECTED) failed"); } if (!mgmt_register(mgmt_master, MGMT_EV_DISCOVERING, opt_src_idx, mgmt_scanning, NULL, NULL)) { DBG("mgmt_register(MGMT_EV_DISCOVERING) failed"); } if (!mgmt_register(mgmt_master, MGMT_EV_DEVICE_FOUND, opt_src_idx, mgmt_device_found, NULL, NULL)) { DBG("mgmt_register(MGMT_EV_DEVICE_FOUND) failed"); } } }