aqhome: fixed flashing messages and code

use consisten order of arguments.
This commit is contained in:
Martin Preuss
2025-03-23 22:38:37 +01:00
parent 7b6cb4da34
commit 24dc3e1c0a
5 changed files with 15 additions and 14 deletions

View File

@@ -72,7 +72,7 @@ static int _flashData(AQH_OBJECT *o, uint32_t address, const uint8_t *ptr, uint3
static int _flashEnd(AQH_OBJECT *o, int reason, int timeoutInSeconds); static int _flashEnd(AQH_OBJECT *o, int reason, int timeoutInSeconds);
/** frees msg! */ /** frees msg! */
static int _trySendMsgAndWaitForFlasgResponse(AQH_OBJECT *o, AQH_MESSAGE *msg, const char *msgInfo, int timeoutInSeconds); static int _trySendMsgAndWaitForFlashResponse(AQH_OBJECT *o, AQH_MESSAGE *msg, const char *msgInfo, int timeoutInSeconds);
static int _waitForFlashResponse(AQH_OBJECT *o, int timeoutInSeconds); static int _waitForFlashResponse(AQH_OBJECT *o, int timeoutInSeconds);
static AQH_FLASHRECORD_LIST *_readHexfileIntoFlashRecordList(const char *hexFilename); static AQH_FLASHRECORD_LIST *_readHexfileIntoFlashRecordList(const char *hexFilename);
@@ -189,7 +189,8 @@ int doFlash(AQH_OBJECT *o)
AQH_Message_free(msg); AQH_Message_free(msg);
/* perform flash */ /* perform flash */
rv=_performFlashProcedure(o, uid, flashRecordList, pageSize, timeoutInSeconds); // rv=_performFlashProcedure(o, uid, flashRecordList, pageSize, timeoutInSeconds);
rv=_performFlashProcedure(o, uid, flashRecordList, 16, timeoutInSeconds);
if (rv<0) { if (rv<0) {
if (rv<0) { if (rv<0) {
DBG_INFO(NULL, "here (%d)", rv); DBG_INFO(NULL, "here (%d)", rv);
@@ -211,7 +212,7 @@ int _rebootNode(AQH_OBJECT *o, unsigned int uid, int timeoutInSeconds)
/* send REBOOT_REQUEST message */ /* send REBOOT_REQUEST message */
fprintf(stdout, "- sending REBOOT request\n"); fprintf(stdout, "- sending REBOOT request\n");
DBG_INFO(NULL, "Sending REBOOT REQUEST message"); DBG_INFO(NULL, "Sending REBOOT REQUEST message");
nodeMsg=AQH_RebootMessage_new(0, 0xff, AQH_MSG_TYPE_REBOOT_REQ, uid); nodeMsg=AQH_RebootMessage_new(0xff, 0x00, AQH_MSG_TYPE_REBOOT_REQ, uid);
if (nodeMsg==NULL) { if (nodeMsg==NULL) {
DBG_ERROR(NULL, "Error creating message"); DBG_ERROR(NULL, "Error creating message");
return GWEN_ERROR_GENERIC; return GWEN_ERROR_GENERIC;
@@ -272,12 +273,12 @@ int _flashStart(AQH_OBJECT *o, unsigned int uid, int timeoutInSeconds)
{ {
AQH_MESSAGE *nodeMsg; AQH_MESSAGE *nodeMsg;
nodeMsg=AQH_FlashStartMessage_new(0, 0xc1, AQH_MSG_TYPE_FLASH_START, uid); nodeMsg=AQH_FlashStartMessage_new(0xc1, 0x00, AQH_MSG_TYPE_FLASH_START, uid);
if (nodeMsg==NULL) { if (nodeMsg==NULL) {
DBG_ERROR(NULL, "Error creating message"); DBG_ERROR(NULL, "Error creating message");
return GWEN_ERROR_GENERIC; return GWEN_ERROR_GENERIC;
} }
return _trySendMsgAndWaitForFlasgResponse(o, nodeMsg, "FLASH_START", timeoutInSeconds); return _trySendMsgAndWaitForFlashResponse(o, nodeMsg, "FLASH_START", timeoutInSeconds);
} }
@@ -326,12 +327,12 @@ int _flashData(AQH_OBJECT *o, uint32_t address, const uint8_t *ptr, uint32_t len
GWEN_Buffer_AppendString(dbuf, "FLASH_DATA ("); GWEN_Buffer_AppendString(dbuf, "FLASH_DATA (");
GWEN_Buffer_AppendArgs(dbuf, "addr=%04x, data len=%d)", address, len); GWEN_Buffer_AppendArgs(dbuf, "addr=%04x, data len=%d)", address, len);
nodeMsg=AQH_FlashDataMessage_new(0, 0xc1, AQH_MSG_TYPE_FLASH_DATA, address, ptr, len); nodeMsg=AQH_FlashDataMessage_new(0xc1, 0x00, AQH_MSG_TYPE_FLASH_DATA, address, ptr, len);
if (nodeMsg==NULL) { if (nodeMsg==NULL) {
DBG_ERROR(NULL, "Error creating message"); DBG_ERROR(NULL, "Error creating message");
return GWEN_ERROR_GENERIC; return GWEN_ERROR_GENERIC;
} }
rv=_trySendMsgAndWaitForFlasgResponse(o, nodeMsg, GWEN_Buffer_GetStart(dbuf), timeoutInSeconds); rv=_trySendMsgAndWaitForFlashResponse(o, nodeMsg, GWEN_Buffer_GetStart(dbuf), timeoutInSeconds);
GWEN_Buffer_free(dbuf); GWEN_Buffer_free(dbuf);
return rv; return rv;
} }
@@ -342,17 +343,17 @@ int _flashEnd(AQH_OBJECT *o, int reason, int timeoutInSeconds)
{ {
AQH_MESSAGE *nodeMsg; AQH_MESSAGE *nodeMsg;
nodeMsg=AQH_FlashEndMessage_new(0, 0xc1, AQH_MSG_TYPE_FLASH_END, reason); nodeMsg=AQH_FlashEndMessage_new(0xc1, 0x00, AQH_MSG_TYPE_FLASH_END, reason);
if (nodeMsg==NULL) { if (nodeMsg==NULL) {
DBG_ERROR(NULL, "Error creating message"); DBG_ERROR(NULL, "Error creating message");
return GWEN_ERROR_GENERIC; return GWEN_ERROR_GENERIC;
} }
return _trySendMsgAndWaitForFlasgResponse(o, nodeMsg, "FLASH_END", timeoutInSeconds); return _trySendMsgAndWaitForFlashResponse(o, nodeMsg, "FLASH_END", timeoutInSeconds);
} }
int _trySendMsgAndWaitForFlasgResponse(AQH_OBJECT *o, AQH_MESSAGE *msg, const char *msgInfo, int timeoutInSeconds) int _trySendMsgAndWaitForFlashResponse(AQH_OBJECT *o, AQH_MESSAGE *msg, const char *msgInfo, int timeoutInSeconds)
{ {
int i; int i;

View File

@@ -28,7 +28,7 @@
AQH_MESSAGE *AQH_FlashDataMessage_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code, uint32_t addr, AQH_MESSAGE *AQH_FlashDataMessage_new(uint8_t destAddr, uint8_t srcAddr, uint8_t code, uint32_t addr,
const uint8_t *dataPtr, uint32_t dataLen) const uint8_t *dataPtr, uint32_t dataLen)
{ {
AQH_MESSAGE *msg; AQH_MESSAGE *msg;

View File

@@ -16,7 +16,7 @@
#include <gwenhywfar/debug.h> #include <gwenhywfar/debug.h>
AQHOME_API AQH_MESSAGE *AQH_FlashDataMessage_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code, uint32_t addr, AQHOME_API AQH_MESSAGE *AQH_FlashDataMessage_new(uint8_t destAddr, uint8_t srcAddr, uint8_t code, uint32_t addr,
const uint8_t *dataPtr, uint32_t dataLen); const uint8_t *dataPtr, uint32_t dataLen);
AQHOME_API uint32_t AQH_FlashDataMessage_GetAddress(const AQH_MESSAGE *msg); AQHOME_API uint32_t AQH_FlashDataMessage_GetAddress(const AQH_MESSAGE *msg);
AQHOME_API uint8_t AQH_FlashDataMessage_GetDataLen(const AQH_MESSAGE *msg); AQHOME_API uint8_t AQH_FlashDataMessage_GetDataLen(const AQH_MESSAGE *msg);

View File

@@ -24,7 +24,7 @@
AQH_MESSAGE *AQH_FlashEndMessage_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code, uint8_t reason) AQH_MESSAGE *AQH_FlashEndMessage_new(uint8_t destAddr, uint8_t srcAddr, uint8_t code, uint8_t reason)
{ {
AQH_MESSAGE *msg; AQH_MESSAGE *msg;
uint8_t *ptr; uint8_t *ptr;

View File

@@ -16,7 +16,7 @@
#include <gwenhywfar/debug.h> #include <gwenhywfar/debug.h>
AQHOME_API AQH_MESSAGE *AQH_FlashEndMessage_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code, uint8_t reason); AQHOME_API AQH_MESSAGE *AQH_FlashEndMessage_new(uint8_t destAddr, uint8_t srcAddr, uint8_t code, uint8_t reason);
AQHOME_API uint8_t AQH_FlashEndMessage_GetReason(const AQH_MESSAGE *msg); AQHOME_API uint8_t AQH_FlashEndMessage_GetReason(const AQH_MESSAGE *msg);
AQHOME_API void AQH_FlashEndMessage_DumpToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *dbuf, const char *sText); AQHOME_API void AQH_FlashEndMessage_DumpToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *dbuf, const char *sText);