-
-
Redpine Signals, Inc. Proprietary and Confidential
Page 41
R
R
S
S
9
9
1
1
1
1
3
3
-
-
n
n
-
-
L
L
i
i
n
n
k
k
-
-
M
M
o
o
d
d
u
u
l
l
e
e
-
-
D
D
r
r
i
i
v
v
e
e
r
r
-
-
I
I
n
n
s
s
t
t
a
a
l
l
l
l
a
a
t
t
i
i
o
o
n
n
-
-
G
G
u
u
i
i
d
d
e
e
V
V
e
e
r
r
s
s
i
i
o
o
n
n
3
3
.
.
0
0
break;
}
close(hci_sock);
usleep(10000); // 10 ms retry delay
}
if (attempt == 0) {
LOGE("%s: Timeout waiting for HCI device to come up",
__FUNCTION__);
goto out;
}
LOGI("Starting bluetoothd deamon");
if (property_set("ctl.start", "bluetoothd") < 0) {
LOGE("Failed to start bluetoothd");
goto out;
}
sleep(HCID_START_DELAY_SEC);
ret = 0;
out:
if (hci_sock >= 0) close(hci_sock);
return ret;
}
/*In bt_disable comment the hciattach and instead remove Redpine’s driver via
rmmod.*/
int bt_disable() {
LOGV(__FUNCTION__);
int ret = -1;
int hci_sock = -1;
LOGI("Stopping bluetoothd deamon");
if (property_set("ctl.stop", "bluetoothd") < 0) {
LOGE("Error stopping bluetoothd");
goto out;
}
usleep(HCID_STOP_DELAY_USEC);
hci_sock = create_hci_sock();
if (hci_sock < 0) goto out;
ioctl(hci_sock, HCIDEVDOWN, HCI_DEV_ID);
/*
LOGI("Stopping hciattach deamon");
if (property_set("ctl.stop", "hciattach") < 0) {
LOGE("Error stopping hciattach");
goto out;
}
if (set_bluetooth_power(0) < 0) {