aqhome: adapted to latest changes.

This commit is contained in:
Martin Preuss
2024-09-07 14:57:40 +02:00
parent 9b724d5a5f
commit 5f2da242c5
5 changed files with 50 additions and 66 deletions

View File

@@ -16,6 +16,7 @@
#include "aqhome/msg/msg_value.h"
#include "aqhome/msg/msg_value2.h"
#include "aqhome/msg/msg_value3.h"
#include "aqhome/msg/msg_sendstats.h"
#include "aqhome/msg/msg_recvstats.h"
#include "aqhome/msg/msg_memstats.h"
@@ -99,6 +100,10 @@ void AqHomed_LogTtyMsg(AQHOMED *aqh, const GWEN_MSG *msg)
case AQH_MSG_TYPE_FLASH_DATA: AQH_FlashDataMsg_DumpToBuffer(msg, dbuf, "received"); break;
case AQH_MSG_TYPE_REBOOT_REQ: AQH_RebootRequestMsg_DumpToBuffer(msg, dbuf, "received"); break;
case AQH_MSG_TYPE_REBOOT_RSP: AQH_RebootResponseMsg_DumpToBuffer(msg, dbuf, "received"); break;
case AQH_MSG_TYPE_VALUE_REPORT:
case AQH_MSG_TYPE_VALUE_SET:
case AQH_MSG_TYPE_VALUE_SET_ACK:
case AQH_MSG_TYPE_VALUE_SET_NACK: AQH_Value3Msg_DumpToBuffer(msg, dbuf, "received"); break;
default: AQH_NodeMsg_DumpToBuffer(msg, dbuf, "received"); break;
}
}

View File

@@ -484,7 +484,7 @@ int _sendFlashStart(GWEN_MSG_ENDPOINT *epTcp, unsigned int uid)
GWEN_MSG *msgNode;
GWEN_MSG *msgOut;
msgNode=AQH_FlashStartMsg_new(0, 0xc1, AQH_MSG_TYPE_FLASH_START, uid, 0, 0);
msgNode=AQH_FlashStartMsg_new(0, 0xc1, AQH_MSG_TYPE_FLASH_START, uid);
if (msgNode==NULL) {
DBG_ERROR(NULL, "Error creating message");
return GWEN_ERROR_GENERIC;

View File

@@ -19,15 +19,12 @@
#define AQH_MSG_OFFS_FLASHSTART_UID 0 /* 4 bytes */
#define AQH_MSG_OFFS_FLASHSTART_FWTYPE 4 /* 2 bytes */
#define AQH_MSG_OFFS_FLASHSTART_FWVER 6 /* 2 bytes */
#define AQH_MSG_FLASHSTART_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHSTART_FWVER+2)
#define AQH_MSG_FLASHSTART_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHSTART_UID+4)
GWEN_MSG *AQH_FlashStartMsg_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code,
uint32_t uid, uint16_t firmwareType, uint16_t firmwareVersion)
GWEN_MSG *AQH_FlashStartMsg_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code, uint32_t uid)
{
GWEN_MSG *msg;
uint8_t *ptr;
@@ -41,12 +38,6 @@ GWEN_MSG *AQH_FlashStartMsg_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code,
*(ptr++)=(uid>>16) & 0xff;
*(ptr++)=(uid>>24) & 0xff;
*(ptr++)=firmwareType & 0xff; /* fw type */
*(ptr++)=(firmwareType>>8) & 0xff;
*(ptr++)=firmwareVersion & 0xff; /* fw ver */
*(ptr++)=(firmwareVersion>>8) & 0xff;
rv=AQH_NodeMsg_AddChecksum(msg);
if (rv<0) {
DBG_INFO(AQH_LOGDOMAIN, "here (%d)", rv);
@@ -67,35 +58,14 @@ uint32_t AQH_FlashStartMsg_GetUid(const GWEN_MSG *msg)
uint16_t AQH_FlashStartMsg_GetFirmwareType(const GWEN_MSG *msg)
{
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHSTART_FWTYPE, 0);
}
uint16_t AQH_FlashStartMsg_GetFirmwareVersion(const GWEN_MSG *msg)
{
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHSTART_FWVER, 0);
}
void AQH_FlashStartMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
{
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_FLASHSTART_MINSIZE) {
uint16_t fwVersion;
fwVersion=AQH_FlashStartMsg_GetFirmwareVersion(msg);
GWEN_Buffer_AppendArgs(dbuf, "0x%02x->0x%02x: FLASHSTART %s (uid=0x%08x, fw type=%d, fw ver=%d.%d)\n",
GWEN_Buffer_AppendArgs(dbuf, "0x%02x->0x%02x: FLASHSTART %s (uid=0x%08x)\n",
AQH_NodeMsg_GetSourceAddress(msg),
AQH_NodeMsg_GetDestAddress(msg),
sText,
(unsigned int) AQH_FlashStartMsg_GetUid(msg),
AQH_FlashStartMsg_GetFirmwareType(msg),
(fwVersion>>8) & 0xff,
fwVersion & 0xff);
(unsigned int) AQH_FlashStartMsg_GetUid(msg));
}
}

View File

@@ -16,12 +16,9 @@
#include <gwenhywfar/msg.h>
#include <gwenhywfar/buffer.h>
AQHOME_API GWEN_MSG *AQH_FlashStartMsg_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code,
uint32_t uid, uint16_t firmwareType, uint16_t firmwareVersion);
AQHOME_API GWEN_MSG *AQH_FlashStartMsg_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code, uint32_t uid);
AQHOME_API uint32_t AQH_FlashStartMsg_GetUid(const GWEN_MSG *msg);
AQHOME_API uint16_t AQH_FlashStartMsg_GetFirmwareType(const GWEN_MSG *msg);
AQHOME_API uint16_t AQH_FlashStartMsg_GetFirmwareVersion(const GWEN_MSG *msg);
AQHOME_API void AQH_FlashStartMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);

View File

@@ -142,10 +142,21 @@ double AQH_Value3Msg_GetValue(const GWEN_MSG *msg)
void AQH_Value3Msg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
{
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_VALUE3_MINSIZE) {
const char *sCmd;
switch(AQH_NodeMsg_GetMsgType(msg)) {
case AQH_MSG_TYPE_VALUE_REPORT: sCmd="report"; break;
case AQH_MSG_TYPE_VALUE_SET: sCmd="set"; break;
case AQH_MSG_TYPE_VALUE_SET_ACK: sCmd="ack"; break;
case AQH_MSG_TYPE_VALUE_SET_NACK: sCmd="nack"; break;
default: sCmd="unknown"; break;
}
if (AQH_Value3Msg_GetValueType(msg)==AQH_MSG_VALUE3_TYPE_DOOR)
GWEN_Buffer_AppendArgs(dbuf, "0x%02x->0x%02x: VALUE3 %s (uid=0x%08x, msgId=%u, value_id=0x%02x type=%s value=%s)\n",
GWEN_Buffer_AppendArgs(dbuf, "0x%02x->0x%02x: VALUE3(%s) %s (uid=0x%08x, msgId=%u, value_id=0x%02x type=%s value=%s)\n",
AQH_NodeMsg_GetSourceAddress(msg),
AQH_NodeMsg_GetDestAddress(msg),
sCmd,
sText,
(unsigned int) AQH_Value3Msg_GetUid(msg),
(unsigned int)AQH_Value3Msg_GetMsgId(msg),
@@ -153,9 +164,10 @@ void AQH_Value3Msg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const ch
AQH_Value3Msg_GetValueTypeName(msg),
AQH_Value3Msg_GetValueAsWindowStateString(msg));
else
GWEN_Buffer_AppendArgs(dbuf, "0x%02x->0x%02x: VALUE3 %s (uid=0x%08x, msgId=%u, value_id=0x%02x type=%s value=%f)\n",
GWEN_Buffer_AppendArgs(dbuf, "0x%02x->0x%02x: VALUE3(%s) %s (uid=0x%08x, msgId=%u, value_id=0x%02x type=%s value=%f)\n",
AQH_NodeMsg_GetSourceAddress(msg),
AQH_NodeMsg_GetDestAddress(msg),
sCmd,
sText,
(unsigned int) AQH_Value3Msg_GetUid(msg),
(unsigned int)AQH_Value3Msg_GetMsgId(msg),