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
Donald Chen
pc-ble-driver-sd_api_v6
Commits
aa7ec8a1
Commit
aa7ec8a1
authored
Jan 16, 2018
by
Bjørn Inge Hanssen
Browse files
Add fix for spurious condition variable wakeup
Fix typo in packet error encoding
parent
404ff3ee
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/common/ble_common.cpp
View file @
aa7ec8a1
...
@@ -60,8 +60,8 @@ uint32_t encode_decode(adapter_t *adapter, encode_function_t encode_function, de
...
@@ -60,8 +60,8 @@ uint32_t encode_decode(adapter_t *adapter, encode_function_t encode_function, de
if
(
_adapter
->
isInternalError
(
err_code
))
if
(
_adapter
->
isInternalError
(
err_code
))
{
{
error_message
<<
"Not able to
d
ecode packet
received from target
. Code #"
<<
err_code
;
error_message
<<
"Not able to e
n
code packet. Code #"
<<
err_code
;
_adapter
->
statusHandler
(
PKT_
D
ECODE_ERROR
,
error_message
.
str
().
c_str
());
_adapter
->
statusHandler
(
PKT_E
N
CODE_ERROR
,
error_message
.
str
().
c_str
());
return
NRF_ERROR_INTERNAL
;
return
NRF_ERROR_INTERNAL
;
}
}
...
...
src/common/transport/h5_transport.cpp
View file @
aa7ec8a1
...
@@ -227,9 +227,17 @@ uint32_t H5Transport::send(std::vector<uint8_t> &data)
...
@@ -227,9 +227,17 @@ uint32_t H5Transport::send(std::vector<uint8_t> &data)
logPacket
(
true
,
h5EncodedPacket
);
logPacket
(
true
,
h5EncodedPacket
);
nextTransportLayer
->
send
(
lastPacket
);
nextTransportLayer
->
send
(
lastPacket
);
const
uint8_t
seqNumBefore
=
seqNum
;
auto
status
=
ackWaitCondition
.
wait_for
(
ackGuard
,
std
::
chrono
::
milliseconds
(
retransmissionInterval
));
auto
status
=
ackWaitCondition
.
wait_for
(
ackGuard
,
std
::
chrono
::
milliseconds
(
retransmissionInterval
));
if
(
status
==
std
::
cv_status
::
no_timeout
)
// Checking for timeout. Also checking against spurios wakeup by making sure the sequence
// number has actually increased. If the sequence number has not increased, we have not
// received an ACK packet, and should not exit the loop (unless timeout).
// Ref. spurious wakeup:
// http://en.cppreference.com/w/cpp/thread/condition_variable
// https://en.wikipedia.org/wiki/Spurious_wakeup
if
(
status
==
std
::
cv_status
::
no_timeout
&&
seqNum
!=
seqNumBefore
)
{
{
lastPacket
.
clear
();
lastPacket
.
clear
();
return
NRF_SUCCESS
;
return
NRF_SUCCESS
;
...
...
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