Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
forks
ble
Commits
7627da41
Commit
7627da41
authored
Mar 14, 2019
by
Jeff Lassahn
Browse files
Prevent HCI send from blocking forever if the device doesn't respond.
parent
53fc7ac0
Changes
1
Hide whitespace changes
Inline
Side-by-side
linux/hci/hci.go
View file @
7627da41
...
...
@@ -259,10 +259,18 @@ func (h *HCI) send(c Command) ([]byte, error) {
h
.
close
(
fmt
.
Errorf
(
"hci: failed to send whole cmd pkt to hci socket"
))
}
// emergency timeout to prevent calls from locking up if the HCI
// interface doesn't respond. Responsed here should normally be fast
// a timeout indicates a major problem with HCI.
timeout
:=
time
.
NewTimer
(
10
*
time
.
Second
)
select
{
case
<-
timeout
.
C
:
return
nil
,
fmt
.
Errorf
(
"hci: no response to command, hci connection failed"
)
case
<-
h
.
done
:
timeout
.
Stop
()
return
nil
,
h
.
err
case
b
:=
<-
p
.
done
:
timeout
.
Stop
()
return
b
,
nil
}
}
...
...
@@ -561,4 +569,3 @@ func (h *HCI) setAllowedCommands(n int) {
h
.
chCmdBufs
<-
make
([]
byte
,
64
)
// TODO make buffer size a constant
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment