|
|
|
|
@ -84,10 +84,14 @@ int BluetoothHci::openBtHci() {
|
|
|
|
|
}
|
|
|
|
|
bt_soc_fd_ = fd;
|
|
|
|
|
|
|
|
|
|
if (waitHciDev(hci_interface)) {
|
|
|
|
|
int ret = waitHciDev(hci_interface);
|
|
|
|
|
if (ret < 0) {
|
|
|
|
|
ALOGE( "HCI interface (%d) not found", hci_interface);
|
|
|
|
|
::close(fd);
|
|
|
|
|
return -1;
|
|
|
|
|
} else if (hci_interface != ret) {
|
|
|
|
|
hci_interface = ret;
|
|
|
|
|
ALOGD( "HCI interface (%d) found", hci_interface);
|
|
|
|
|
}
|
|
|
|
|
struct sockaddr_hci addr;
|
|
|
|
|
memset(&addr, 0, sizeof(addr));
|
|
|
|
|
@ -173,7 +177,10 @@ int BluetoothHci::waitHciDev(int hci_interface) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ev.opcode == MGMT_EV_INDEX_ADDED && ev.index == hci_interface) {
|
|
|
|
|
if (ev.opcode == MGMT_EV_INDEX_ADDED) {
|
|
|
|
|
if (hci_interface != ev.index) {
|
|
|
|
|
ret = ev.index;
|
|
|
|
|
}
|
|
|
|
|
goto end;
|
|
|
|
|
} else if (ev.opcode == MGMT_EV_COMMAND_COMP) {
|
|
|
|
|
struct mgmt_event_read_index* cc;
|
|
|
|
|
@ -186,6 +193,10 @@ int BluetoothHci::waitHciDev(int hci_interface) {
|
|
|
|
|
for (i = 0; i < cc->num_intf; i++) {
|
|
|
|
|
if (cc->index[i] == hci_interface) goto end;
|
|
|
|
|
}
|
|
|
|
|
if (cc->num_intf > 0) {
|
|
|
|
|
ret = cc->index[0];
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|