Add return value to wait()
This commit is contained in:
@@ -388,16 +388,19 @@ void wait(unsigned long ms) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wait(unsigned long ms, uint8_t cmd, uint8_t msgtype) {
|
bool wait(unsigned long ms, uint8_t cmd, uint8_t msgtype) {
|
||||||
unsigned long enter = hwMillis();
|
unsigned long enter = hwMillis();
|
||||||
// invalidate msg type
|
// invalidate msg type
|
||||||
_msg.type = !msgtype;
|
_msg.type = !msgtype;
|
||||||
while ( (hwMillis() - enter < ms) && !(mGetCommand(_msg)==cmd && _msg.type==msgtype) ) {
|
bool expectedResponse = false;
|
||||||
|
while ( (hwMillis() - enter < ms) && !expectedResponse ) {
|
||||||
_process();
|
_process();
|
||||||
#if defined(MY_GATEWAY_ESP8266)
|
#if defined(MY_GATEWAY_ESP8266)
|
||||||
yield();
|
yield();
|
||||||
#endif
|
#endif
|
||||||
|
expectedResponse = (mGetCommand(_msg) == cmd && _msg.type == msgtype);
|
||||||
}
|
}
|
||||||
|
return expectedResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -177,8 +177,9 @@ void wait(unsigned long ms);
|
|||||||
* @param ms Number of milliseconds to sleep.
|
* @param ms Number of milliseconds to sleep.
|
||||||
* @param cmd Command of incoming message.
|
* @param cmd Command of incoming message.
|
||||||
* @param msgtype Message type.
|
* @param msgtype Message type.
|
||||||
|
* @return True if specified message received
|
||||||
*/
|
*/
|
||||||
void wait(unsigned long ms, uint8_t cmd, uint8_t msgtype);
|
bool wait(unsigned long ms, uint8_t cmd, uint8_t msgtype);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sleep (PowerDownMode) the MCU and radio. Wake up on timer.
|
* Sleep (PowerDownMode) the MCU and radio. Wake up on timer.
|
||||||
|
|||||||
Reference in New Issue
Block a user