137 lines
4.2 KiB
C
137 lines
4.2 KiB
C
/****************************************************************************
|
|
* 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_MANUF 4 /* 4 bytes */
|
|
#define AQH_MSG_OFFS_FLASHREADY_DEVTYPE 8 /* 2 bytes */
|
|
#define AQH_MSG_OFFS_FLASHREADY_DEVVERSION 10 /* 1 byte */
|
|
#define AQH_MSG_OFFS_FLASHREADY_DEVREVISION 11 /* 1 byte */
|
|
#define AQH_MSG_OFFS_FLASHREADY_FWVARIANT 12 /* 1 byte */
|
|
#define AQH_MSG_OFFS_FLASHREADY_FWVMAJOR 13 /* 1 byte */
|
|
#define AQH_MSG_OFFS_FLASHREADY_FWVMINOR 14 /* 1 byte */
|
|
#define AQH_MSG_OFFS_FLASHREADY_FWVPATCH 15 /* 1 byte */
|
|
#define AQH_MSG_OFFS_FLASHREADY_PAGESIZE 16 /* 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);
|
|
}
|
|
|
|
|
|
|
|
uint32_t AQH_FlashReadyMsg_GetManufacturer(const GWEN_MSG *msg)
|
|
{
|
|
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_MANUF, 0);
|
|
}
|
|
|
|
|
|
|
|
uint16_t AQH_FlashReadyMsg_GetDeviceType(const GWEN_MSG *msg)
|
|
{
|
|
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_DEVTYPE, 0);
|
|
}
|
|
|
|
|
|
|
|
uint8_t AQH_FlashReadyMsg_GetDeviceVersion(const GWEN_MSG *msg)
|
|
{
|
|
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_DEVVERSION, 0);
|
|
}
|
|
|
|
|
|
|
|
uint8_t AQH_FlashReadyMsg_GetDeviceRevision(const GWEN_MSG *msg)
|
|
{
|
|
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_DEVREVISION, 0);
|
|
}
|
|
|
|
|
|
|
|
uint8_t AQH_FlashReadyMsg_GetFirmwareVariant(const GWEN_MSG *msg)
|
|
{
|
|
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_FWVARIANT, 0);
|
|
}
|
|
|
|
|
|
uint8_t AQH_FlashReadyMsg_GetFirmwareVersionMajor(const GWEN_MSG *msg)
|
|
{
|
|
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_FWVMAJOR, 0);
|
|
}
|
|
|
|
|
|
|
|
uint8_t AQH_FlashReadyMsg_GetFirmwareVersionMinor(const GWEN_MSG *msg)
|
|
{
|
|
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_FWVMINOR, 0);
|
|
}
|
|
|
|
|
|
|
|
uint8_t AQH_FlashReadyMsg_GetFirmwareVersionPatchlevel(const GWEN_MSG *msg)
|
|
{
|
|
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_FWVPATCH, 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)) {
|
|
|
|
GWEN_Buffer_AppendArgs(dbuf,
|
|
"0x%02x->0x%02x: FLASHREADY %s (uid=0x%08x, dev=%08x:%04x v%d.%d, fw=%d.%d.%d (%d) pagesize=%d)\n",
|
|
AQH_NodeMsg_GetSourceAddress(msg),
|
|
AQH_NodeMsg_GetDestAddress(msg),
|
|
sText,
|
|
(unsigned int) AQH_FlashReadyMsg_GetUid(msg),
|
|
AQH_FlashReadyMsg_GetManufacturer(msg),
|
|
AQH_FlashReadyMsg_GetDeviceType(msg),
|
|
AQH_FlashReadyMsg_GetDeviceVersion(msg),
|
|
AQH_FlashReadyMsg_GetDeviceRevision(msg),
|
|
AQH_FlashReadyMsg_GetFirmwareVersionMajor(msg),
|
|
AQH_FlashReadyMsg_GetFirmwareVersionMinor(msg),
|
|
AQH_FlashReadyMsg_GetFirmwareVersionPatchlevel(msg),
|
|
AQH_FlashReadyMsg_GetFirmwareVariant(msg),
|
|
AQH_FlashReadyMsg_GetPagesize(msg));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|