Skip to content

Commit

Permalink
wait for response fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
pa-pa committed Feb 3, 2017
1 parent 6551bb1 commit b39eee7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class Device {
result = radio->write(msg,msg.burstRequired());
if( result == true && msg.ackRequired() == true && to.valid() == true ) {
Message response;
if( waitResponse(msg,response,30) ) { // 300ms
if( (result=waitResponse(msg,response,30)) ) { // 300ms
#ifdef USE_AES
if( response.isChallengeAes() == true ) {
AesChallengeMsg& cm = response.aesChallenge();
Expand Down Expand Up @@ -382,10 +382,13 @@ class Device {

bool waitResponse(const Message& msg,Message& response,uint8_t timeout) {
do {
if( radio->read(response) > 0 &&
msg.count() == response.count() &&
msg.to() == response.from() ) {
return true;
uint8_t num = radio->read(response);
if( num > 0 ) {
// response.dump();
if( msg.count() == response.count() &&
msg.to() == response.from() ) {
return true;
}
}
_delay_ms(10); // wait 10ms
timeout--;
Expand Down

0 comments on commit b39eee7

Please sign in to comment.