Merge pull request #476 from tekka007/WaitEnhancement
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();
|
||||
// invalidate msg type
|
||||
_msg.type = !msgtype;
|
||||
while ( (hwMillis() - enter < ms) && !(mGetCommand(_msg)==cmd && _msg.type==msgtype) ) {
|
||||
bool expectedResponse = false;
|
||||
while ( (hwMillis() - enter < ms) && !expectedResponse ) {
|
||||
_process();
|
||||
#if defined(MY_GATEWAY_ESP8266)
|
||||
yield();
|
||||
#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 cmd Command of incoming message.
|
||||
* @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.
|
||||
|
||||
Reference in New Issue
Block a user