bthost->new_conn_data = user_data;
}
-void bthost_hci_connect(struct bthost *bthost, const uint8_t *bdaddr)
+void bthost_hci_connect(struct bthost *bthost, const uint8_t *bdaddr,
+ uint8_t addr_type)
{
- struct bt_hci_cmd_create_conn cmd;
+ if (addr_type == BDADDR_BREDR) {
+ struct bt_hci_cmd_create_conn cc;
- memset(&cmd, 0, sizeof(cmd));
- memcpy(cmd.bdaddr, bdaddr, sizeof(cmd.bdaddr));
+ memset(&cc, 0, sizeof(cc));
+ memcpy(cc.bdaddr, bdaddr, sizeof(cc.bdaddr));
+
+ send_command(bthost, BT_HCI_CMD_CREATE_CONN, &cc, sizeof(cc));
+ } else {
+ struct bt_hci_cmd_le_create_conn cc;
- send_command(bthost, BT_HCI_CMD_CREATE_CONN, &cmd, sizeof(cmd));
+ memset(&cc, 0, sizeof(cc));
+ memcpy(cc.peer_addr, bdaddr, sizeof(cc.peer_addr));
+
+ if (addr_type == BDADDR_LE_RANDOM)
+ cc.peer_addr_type = 0x01;
+
+ send_command(bthost, BT_HCI_CMD_LE_CREATE_CONN,
+ &cc, sizeof(cc));
+ }
}
void bthost_write_scan_enable(struct bthost *bthost, uint8_t scan)
void bthost_set_connect_cb(struct bthost *bthost, bthost_new_conn_cb cb,
void *user_data);
-void bthost_hci_connect(struct bthost *bthost, const uint8_t *bdaddr);
+void bthost_hci_connect(struct bthost *bthost, const uint8_t *bdaddr,
+ uint8_t addr_type);
typedef void (*bthost_l2cap_rsp_cb) (uint8_t code, const void *data,
uint16_t len, void *user_data);
struct test_data *data = tester_get_data();
const struct l2cap_server_data *l2data = data->test_data;
const uint8_t *master_bdaddr;
+ uint8_t addr_type;
struct bthost *bthost;
GIOChannel *io;
int sk;
bthost = hciemu_client_get_host(data->hciemu);
bthost_set_connect_cb(bthost, client_new_conn, data);
- bthost_hci_connect(bthost, master_bdaddr);
+
+ if (data->hciemu_type == HCIEMU_TYPE_BREDR)
+ addr_type = BDADDR_BREDR;
+ else
+ addr_type = BDADDR_LE_PUBLIC;
+
+ bthost_hci_connect(bthost, master_bdaddr, addr_type);
}
int main(int argc, char *argv[])