diff --git a/apps/aqhome-tool/nodes/flash.c b/apps/aqhome-tool/nodes/flash.c index d64b4b4..34ef1d1 100644 --- a/apps/aqhome-tool/nodes/flash.c +++ b/apps/aqhome-tool/nodes/flash.c @@ -68,7 +68,7 @@ static int _sendFlashRecord(GWEN_MSG_ENDPOINT *epTcp, const AQH_FLASHRECORD *flashRecord, uint16_t pageSize, int timeoutInSeconds); -static int _sendFlashEnd(GWEN_MSG_ENDPOINT *epTcp, int reason); +static int _sendFlashEnd(GWEN_MSG_ENDPOINT *epTcp, int reason, int timeoutInSeconds); @@ -344,7 +344,7 @@ int _performFlashProcedure(GWEN_MSG_ENDPOINT *epTcp, flashRecord=AQH_FlashRecord_List_Next(flashRecord); } - rv=_sendFlashEnd(epTcp, 0); + rv=_sendFlashEnd(epTcp, 0, timeoutInSeconds); if (rv<0) { DBG_INFO(NULL, "here (%d)", rv); return rv; @@ -502,22 +502,44 @@ int _sendFlashStart(GWEN_MSG_ENDPOINT *epTcp, unsigned int uid) -int _sendFlashEnd(GWEN_MSG_ENDPOINT *epTcp, int reason) +int _sendFlashEnd(GWEN_MSG_ENDPOINT *epTcp, int reason, int timeoutInSeconds) { - GWEN_MSG *msgNode; - GWEN_MSG *msgOut; + int i; - msgNode=AQH_FlashEndMsg_new(0, 0xc1, AQH_MSG_TYPE_FLASH_END, reason); - if (msgNode==NULL) { - DBG_ERROR(NULL, "Error creating message"); - return GWEN_ERROR_GENERIC; + for (i=0;i ACK received.\n"); + break; + } + else { + DBG_ERROR(NULL, "Negative response to flash end message (%d)", rv); + } + } /* for */ + if (i>=FLASH_TOOL_MAX_REPEAT) { + DBG_ERROR(NULL, "Too many errors (tried %d times), giving up", i); + return GWEN_ERROR_IO; } - - msgOut=AQH_ForwardIpcMsg_new(AQH_MSGTYPE_IPC_NODES_FORWARD, - GWEN_MsgEndpoint_GetNextMessageId(epTcp), 0, - GWEN_Msg_GetConstBuffer(msgNode), GWEN_Msg_GetBytesInBuffer(msgNode)); - GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut); - GWEN_Msg_free(msgNode); return 0; }