aqhome: added FLASH_READY msg.

This commit is contained in:
Martin Preuss
2023-04-19 15:39:51 +02:00
parent 20efe7d473
commit fd2c4da9ce
8 changed files with 140 additions and 17 deletions

View File

@@ -63,6 +63,7 @@
msg_value.h
msg_value2.h
msg_device.h
msg_flashready.h
</headers>
@@ -96,6 +97,7 @@
msg_value.c
msg_value2.c
msg_device.c
msg_flashready.c
</sources>

View File

@@ -27,6 +27,7 @@
#include "aqhome/msg/msg_haveaddr.h"
#include "aqhome/msg/msg_denyaddr.h"
#include "aqhome/msg/msg_device.h"
#include "aqhome/msg/msg_flashready.h"
#include <gwenhywfar/list.h>
#include <gwenhywfar/inherit.h>
@@ -139,6 +140,7 @@ void _logMessage(GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg)
case AQH_MSG_TYPE_DEVICE: AQH_DeviceMsg_DumpToBuffer(msg, dbuf, "received"); break;
case AQH_MSG_TYPE_MEMSTATS: AQH_MemStatsMsg_DumpToBuffer(msg, dbuf, "received"); break;
case AQH_MSG_TYPE_SYSSTATS: AQH_SysStatsMsg_DumpToBuffer(msg, dbuf, "received"); break;
case AQH_MSG_TYPE_FLASH_READY: AQH_FlashReadyMsg_DumpToBuffer(msg, dbuf, "received"); break;
default: AQH_NodeMsg_DumpToBuffer(msg, dbuf, "received"); break;
}
}

View File

@@ -80,19 +80,19 @@ void AQH_DeviceMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const ch
modules);
if (modules) {
GWEN_Buffer_AppendString(dbuf, "[");
if (modules & AQH_MSG_DEVICE_MASK_TIMER)
if (modules & AQH_MSG_MODULES_MASK_TIMER)
GWEN_Buffer_AppendString(dbuf, " TIMER");
if (modules & AQH_MSG_DEVICE_MASK_COM)
if (modules & AQH_MSG_MODULES_MASK_COM)
GWEN_Buffer_AppendString(dbuf, " COM");
if (modules & AQH_MSG_DEVICE_MASK_LED)
if (modules & AQH_MSG_MODULES_MASK_LED)
GWEN_Buffer_AppendString(dbuf, " LED");
if (modules & AQH_MSG_DEVICE_MASK_TWIMASTER)
if (modules & AQH_MSG_MODULES_MASK_TWIMASTER)
GWEN_Buffer_AppendString(dbuf, " TWIMASTER");
if (modules & AQH_MSG_DEVICE_MASK_LCD)
if (modules & AQH_MSG_MODULES_MASK_LCD)
GWEN_Buffer_AppendString(dbuf, " LCD");
if (modules & AQH_MSG_DEVICE_MASK_SI7021)
if (modules & AQH_MSG_MODULES_MASK_SI7021)
GWEN_Buffer_AppendString(dbuf, " SI7021");
if (modules & AQH_MSG_DEVICE_MASK_STATS)
if (modules & AQH_MSG_MODULES_MASK_STATS)
GWEN_Buffer_AppendString(dbuf, " STATS");
GWEN_Buffer_AppendString(dbuf, " ]");
}

View File

@@ -18,16 +18,6 @@
#define AQH_MSG_DEVICE_MASK_TIMER 0x02
#define AQH_MSG_DEVICE_MASK_COM 0x04
#define AQH_MSG_DEVICE_MASK_LED 0x08
#define AQH_MSG_DEVICE_MASK_TWIMASTER 0x10
#define AQH_MSG_DEVICE_MASK_LCD 0x20
#define AQH_MSG_DEVICE_MASK_SI7021 0x40
#define AQH_MSG_DEVICE_MASK_STATS 0x80
AQHOME_API uint32_t AQH_DeviceMsg_GetUid(const GWEN_MSG *msg);
AQHOME_API uint16_t AQH_DeviceMsg_GetFirmwareType(const GWEN_MSG *msg);
AQHOME_API uint8_t AQH_DeviceMsg_GetFirmwareLow(const GWEN_MSG *msg);

View File

@@ -0,0 +1,85 @@
/****************************************************************************
* This file is part of the project AqHome.
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
*
* The license for this file can be found in the file COPYING which you
* should have received along with this file.
****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "aqhome/msg/msg_flashready.h"
#include <gwenhywfar/misc.h>
#include <gwenhywfar/list.h>
#include <gwenhywfar/error.h>
#include <gwenhywfar/debug.h>
#define AQH_MSG_OFFS_FLASHREADY_UID 0 /* 4 bytes */
#define AQH_MSG_OFFS_FLASHREADY_FWTYPE 4 /* 2 bytes */
#define AQH_MSG_OFFS_FLASHREADY_FWVER 6 /* 2 bytes */
#define AQH_MSG_OFFS_FLASHREADY_PAGESIZE 8 /* 2 bytes */
#define AQH_MSG_FLASHREADY_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_PAGESIZE+2)
uint32_t AQH_FlashReadyMsg_GetUid(const GWEN_MSG *msg)
{
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_UID, 0);
}
uint16_t AQH_FlashReadyMsg_GetFirmwareType(const GWEN_MSG *msg)
{
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_FWTYPE, 0);
}
uint16_t AQH_FlashReadyMsg_GetFirmwareVersion(const GWEN_MSG *msg)
{
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_FWVER, 0);
}
uint16_t AQH_FlashReadyMsg_GetPagesize(const GWEN_MSG *msg)
{
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_PAGESIZE, 0);
}
void AQH_FlashReadyMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
{
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_FLASH_READY) &&
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_FLASHREADY_MINSIZE)) {
uint16_t fwVersion;
fwVersion=AQH_FlashReadyMsg_GetFirmwareVersion(msg);
GWEN_Buffer_AppendArgs(dbuf, "0x%02x->0x%02x: FLASHREADY %s (uid=0x%08x, fw type=%d, fw ver=%d.%d, pagesize=%d)\n",
AQH_NodeMsg_GetSourceAddress(msg),
AQH_NodeMsg_GetDestAddress(msg),
sText,
(unsigned int) AQH_FlashReadyMsg_GetUid(msg),
AQH_FlashReadyMsg_GetFirmwareType(msg),
(fwVersion>>8) & 0xff,
fwVersion & 0xff,
AQH_FlashReadyMsg_GetPagesize(msg));
}
}

View File

@@ -0,0 +1,32 @@
/****************************************************************************
* This file is part of the project AqHome.
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
*
* The license for this file can be found in the file COPYING which you
* should have received along with this file.
****************************************************************************/
#ifndef AQH_MSG_FLASHREADY_H
#define AQH_MSG_FLASHREADY_H
#include <aqhome/api.h>
#include <aqhome/msg/msg_node.h>
#include <gwenhywfar/msg.h>
#include <gwenhywfar/buffer.h>
AQHOME_API uint32_t AQH_FlashReadyMsg_GetUid(const GWEN_MSG *msg);
AQHOME_API uint16_t AQH_FlashReadyMsg_GetFirmwareType(const GWEN_MSG *msg);
AQHOME_API uint16_t AQH_FlashReadyMsg_GetFirmwareVersion(const GWEN_MSG *msg);
AQHOME_API uint16_t AQH_FlashReadyMsg_GetModules(const GWEN_MSG *msg);
AQHOME_API void AQH_FlashReadyMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
#endif

View File

@@ -14,6 +14,7 @@
#include "aqhome/msg/msg_node.h"
#include <gwenhywfar/debug.h>
#include <gwenhywfar/text.h>
#define COM_USE_CRC8 1
@@ -177,6 +178,7 @@ void AQH_NodeMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char
AQH_NodeMsg_GetDestAddress(msg),
AQH_NodeMsg_GetMsgType(msg),
sText);
GWEN_Text_DumpString2Buffer((const char*)GWEN_Msg_GetConstBuffer(msg), GWEN_Msg_GetBytesInBuffer(msg), dbuf, 34);
}

View File

@@ -64,6 +64,16 @@
#define AQH_MSG_TYPEGROUP_ALL 0xffffffff
#define AQH_MSG_MODULES_MASK_TIMER 0x02
#define AQH_MSG_MODULES_MASK_COM 0x04
#define AQH_MSG_MODULES_MASK_LED 0x08
#define AQH_MSG_MODULES_MASK_TWIMASTER 0x10
#define AQH_MSG_MODULES_MASK_LCD 0x20
#define AQH_MSG_MODULES_MASK_SI7021 0x40
#define AQH_MSG_MODULES_MASK_STATS 0x80
AQHOME_API GWEN_MSG *AQH_NodeMsg_new(uint8_t destAddr, uint8_t srcAddr, uint8_t code, uint8_t payloadLen, const uint8_t *payload);