Revert "Revert "aqhome: convenience code.""
This reverts commit bb77c6acd1.
This commit is contained in:
44
aqhome/ipc/data/cmd_data.c
Normal file
44
aqhome/ipc/data/cmd_data.c
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_CmdDataIpc_WaitForSpecificIpcMessage(GWEN_MSG_ENDPOINT *epTcp, int msgCode, int timeoutInSeconds)
|
||||
{
|
||||
time_t startTime;
|
||||
|
||||
startTime=time(NULL);
|
||||
|
||||
for (;;) {
|
||||
GWEN_MSG *msg;
|
||||
time_t now;
|
||||
|
||||
while( (msg=GWEN_MsgEndpoint_TakeFirstReceivedMessage(epTcp)) ) {
|
||||
uint16_t code;
|
||||
|
||||
code=GWEN_IpcMsg_GetCode(msg);
|
||||
if (code==msgCode) {
|
||||
DBG_INFO(NULL, "Received expected IPC message");
|
||||
return msg;
|
||||
}
|
||||
else if (code==AQH_MSGTYPE_IPC_DATA_RESULT) {
|
||||
DBG_INFO(NULL, "Received IPC result message");
|
||||
return msg;
|
||||
}
|
||||
else {
|
||||
DBG_INFO(NULL, "Received unexpected message %d (%x)", code, code);
|
||||
}
|
||||
GWEN_Msg_free(msg);
|
||||
}
|
||||
now=time(NULL);
|
||||
if (now-startTime>timeoutInSeconds) {
|
||||
DBG_INFO(NULL, "Timeout");
|
||||
break;
|
||||
}
|
||||
GWEN_MsgEndpoint_IoLoop(epTcp, 2000); /* 2000 ms */
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user