aqhome: adapted to latest changes in node firmware.
This commit is contained in:
@@ -91,6 +91,7 @@
|
||||
msg_sysstats.c
|
||||
msg_value.c
|
||||
msg_value2.c
|
||||
msg_value3.c
|
||||
msg_device.c
|
||||
msg_flashready.c
|
||||
msg_flashstart.c
|
||||
|
||||
@@ -18,13 +18,18 @@
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_DEVICE_UID 0 /* 4 bytes */
|
||||
#define AQH_MSG_OFFS_DEVICE_FWTYPE 4 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_DEVICE_FWLOW 6 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_DEVICE_FWHIGH 7 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_DEVICE_MODULES 8 /* 2 byte */
|
||||
#define AQH_MSG_OFFS_DEVICE_UID 0 /* 4 bytes */
|
||||
#define AQH_MSG_OFFS_DEVICE_MANUF 4 /* 4 bytes */
|
||||
#define AQH_MSG_OFFS_DEVICE_DEVTYPE 8 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_DEVICE_DEVVERSION 10 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_DEVICE_DEVREVISION 11 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_DEVICE_FWVARIANT 12 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_DEVICE_FWVMAJOR 13 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_DEVICE_FWVMINOR 14 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_DEVICE_FWVPATCH 15 /* 1 byte */
|
||||
|
||||
#define AQH_MSG_DEVICE_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_MODULES+2)
|
||||
|
||||
#define AQH_MSG_DEVICE_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_FWVPATCH+1)
|
||||
|
||||
|
||||
|
||||
@@ -35,30 +40,57 @@ uint32_t AQH_DeviceMsg_GetUid(const GWEN_MSG *msg)
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_DeviceMsg_GetFirmwareType(const GWEN_MSG *msg)
|
||||
uint32_t AQH_DeviceMsg_GetManufacturer(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_FWTYPE, 0);
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_MANUF, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_DeviceMsg_GetFirmwareLow(const GWEN_MSG *msg)
|
||||
uint16_t AQH_DeviceMsg_GetDeviceType(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_FWLOW, 0);
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_DEVTYPE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_DeviceMsg_GetFirmwareHigh(const GWEN_MSG *msg)
|
||||
uint8_t AQH_DeviceMsg_GetDeviceVersion(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_FWHIGH, 0);
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_DEVVERSION, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_DeviceMsg_GetModuleMask(const GWEN_MSG *msg)
|
||||
uint8_t AQH_DeviceMsg_GetDeviceRevision(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_MODULES, 0);
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_DEVREVISION, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_DeviceMsg_GetFirmwareVariant(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_FWVARIANT, 0);
|
||||
}
|
||||
|
||||
|
||||
uint8_t AQH_DeviceMsg_GetFirmwareVersionMajor(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_FWVMAJOR, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_DeviceMsg_GetFirmwareVersionMinor(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_FWVMINOR, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_DeviceMsg_GetFirmwareVersionPatchlevel(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_FWVPATCH, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,36 +98,20 @@ uint16_t AQH_DeviceMsg_GetModuleMask(const GWEN_MSG *msg)
|
||||
void AQH_DeviceMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_DEVICE_MINSIZE) {
|
||||
uint16_t modules;
|
||||
|
||||
modules=AQH_DeviceMsg_GetModuleMask(msg);
|
||||
GWEN_Buffer_AppendArgs(dbuf, "0x%02x->0x%02x: DEVICE %s (uid=0x%08x, fw type=%d, fw ver=%d.%d, mods=0x%04x",
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"0x%02x->0x%02x: DEVICE %s (uid=0x%08x, dev=%08x:%04x v%d.%d, fw=%d.%d.%d (%d))\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_DeviceMsg_GetUid(msg),
|
||||
AQH_DeviceMsg_GetFirmwareType(msg),
|
||||
AQH_DeviceMsg_GetFirmwareHigh(msg),
|
||||
AQH_DeviceMsg_GetFirmwareLow(msg),
|
||||
modules);
|
||||
if (modules) {
|
||||
GWEN_Buffer_AppendString(dbuf, "[");
|
||||
if (modules & AQH_MSG_MODULES_MASK_TIMER)
|
||||
GWEN_Buffer_AppendString(dbuf, " TIMER");
|
||||
if (modules & AQH_MSG_MODULES_MASK_COM)
|
||||
GWEN_Buffer_AppendString(dbuf, " COM");
|
||||
if (modules & AQH_MSG_MODULES_MASK_LED)
|
||||
GWEN_Buffer_AppendString(dbuf, " LED");
|
||||
if (modules & AQH_MSG_MODULES_MASK_TWIMASTER)
|
||||
GWEN_Buffer_AppendString(dbuf, " TWIMASTER");
|
||||
if (modules & AQH_MSG_MODULES_MASK_LCD)
|
||||
GWEN_Buffer_AppendString(dbuf, " LCD");
|
||||
if (modules & AQH_MSG_MODULES_MASK_SI7021)
|
||||
GWEN_Buffer_AppendString(dbuf, " SI7021");
|
||||
if (modules & AQH_MSG_MODULES_MASK_STATS)
|
||||
GWEN_Buffer_AppendString(dbuf, " STATS");
|
||||
GWEN_Buffer_AppendString(dbuf, " ]");
|
||||
}
|
||||
AQH_DeviceMsg_GetManufacturer(msg),
|
||||
AQH_DeviceMsg_GetDeviceType(msg),
|
||||
AQH_DeviceMsg_GetDeviceVersion(msg),
|
||||
AQH_DeviceMsg_GetDeviceRevision(msg),
|
||||
AQH_DeviceMsg_GetFirmwareVersionMajor(msg),
|
||||
AQH_DeviceMsg_GetFirmwareVersionMinor(msg),
|
||||
AQH_DeviceMsg_GetFirmwareVersionPatchlevel(msg),
|
||||
AQH_DeviceMsg_GetFirmwareVariant(msg));
|
||||
GWEN_Buffer_AppendString(dbuf, ")\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,14 @@
|
||||
|
||||
|
||||
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);
|
||||
AQHOME_API uint8_t AQH_DeviceMsg_GetFirmwareHigh(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_DeviceMsg_GetModuleMask(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API uint32_t AQH_DeviceMsg_GetManufacturer(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_DeviceMsg_GetDeviceType(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_DeviceMsg_GetDeviceVersion(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_DeviceMsg_GetDeviceRevision(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_DeviceMsg_GetFirmwareVariant(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_DeviceMsg_GetFirmwareVersionMajor(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_DeviceMsg_GetFirmwareVersionMinor(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_DeviceMsg_GetFirmwareVersionPatchlevel(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API void AQH_DeviceMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
@@ -18,10 +18,16 @@
|
||||
#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_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)
|
||||
|
||||
@@ -34,16 +40,57 @@ uint32_t AQH_FlashReadyMsg_GetUid(const GWEN_MSG *msg)
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_FlashReadyMsg_GetFirmwareType(const GWEN_MSG *msg)
|
||||
uint32_t AQH_FlashReadyMsg_GetManufacturer(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_FWTYPE, 0);
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_MANUF, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_FlashReadyMsg_GetFirmwareVersion(const GWEN_MSG *msg)
|
||||
uint16_t AQH_FlashReadyMsg_GetDeviceType(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_FWVER, 0);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,17 +109,21 @@ void AQH_FlashReadyMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, cons
|
||||
{
|
||||
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",
|
||||
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_GetFirmwareType(msg),
|
||||
(fwVersion>>8) & 0xff,
|
||||
fwVersion & 0xff,
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,14 @@
|
||||
|
||||
|
||||
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 uint32_t AQH_FlashReadyMsg_GetManufacturer(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_FlashReadyMsg_GetDeviceType(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_FlashReadyMsg_GetDeviceVersion(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_FlashReadyMsg_GetDeviceRevision(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_FlashReadyMsg_GetFirmwareVariant(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_FlashReadyMsg_GetFirmwareVersionMajor(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_FlashReadyMsg_GetFirmwareVersionMinor(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_FlashReadyMsg_GetFirmwareVersionPatchlevel(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_FlashReadyMsg_GetPagesize(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API void AQH_FlashReadyMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
@@ -27,32 +27,37 @@
|
||||
#define AQH_MSG_OFFS_ALL_DATA_BEGIN 4
|
||||
|
||||
|
||||
#define AQH_MSG_TYPE_PING 10
|
||||
#define AQH_MSG_TYPE_PONG 11
|
||||
#define AQH_MSG_TYPE_COMSENDSTATS 20
|
||||
#define AQH_MSG_TYPE_COMRECVSTATS 21
|
||||
#define AQH_MSG_TYPE_TWIBUSMEMBER 30
|
||||
#define AQH_MSG_TYPE_DEBUG 40
|
||||
#define AQH_MSG_TYPE_VALUE 50
|
||||
#define AQH_MSG_TYPE_VALUE2 51
|
||||
#define AQH_MSG_TYPE_NEED_ADDRESS 60
|
||||
#define AQH_MSG_TYPE_HAVE_ADDRESS 61
|
||||
#define AQH_MSG_TYPE_CLAIM_ADDRESS 62
|
||||
#define AQH_MSG_TYPE_DENY_ADDRESS 63
|
||||
#define AQH_MSG_TYPE_ADDRESS_RANGE 64
|
||||
#define AQH_MSG_TYPE_PING 10
|
||||
#define AQH_MSG_TYPE_PONG 11
|
||||
#define AQH_MSG_TYPE_COMSENDSTATS 20
|
||||
#define AQH_MSG_TYPE_COMRECVSTATS 21
|
||||
#define AQH_MSG_TYPE_TWIBUSMEMBER 30
|
||||
#define AQH_MSG_TYPE_DEBUG 40
|
||||
#define AQH_MSG_TYPE_VALUE 50 /* deprecated */
|
||||
#define AQH_MSG_TYPE_VALUE2 51 /* deprecated */
|
||||
#define AQH_MSG_TYPE_NEED_ADDRESS 60
|
||||
#define AQH_MSG_TYPE_HAVE_ADDRESS 61
|
||||
#define AQH_MSG_TYPE_CLAIM_ADDRESS 62
|
||||
#define AQH_MSG_TYPE_DENY_ADDRESS 63
|
||||
#define AQH_MSG_TYPE_ADDRESS_RANGE 64
|
||||
|
||||
#define AQH_MSG_TYPE_FLASH_START 70
|
||||
#define AQH_MSG_TYPE_FLASH_END 71
|
||||
#define AQH_MSG_TYPE_FLASH_READY 72
|
||||
#define AQH_MSG_TYPE_FLASH_DATA 73
|
||||
#define AQH_MSG_TYPE_FLASH_RSP 74
|
||||
#define AQH_MSG_TYPE_FLASH_START 70
|
||||
#define AQH_MSG_TYPE_FLASH_END 71
|
||||
#define AQH_MSG_TYPE_FLASH_READY 72
|
||||
#define AQH_MSG_TYPE_FLASH_DATA 73
|
||||
#define AQH_MSG_TYPE_FLASH_RSP 74
|
||||
|
||||
#define AQH_MSG_TYPE_DEVICE 80
|
||||
#define AQH_MSG_TYPE_MEMSTATS 81
|
||||
#define AQH_MSG_TYPE_SYSSTATS 82
|
||||
#define AQH_MSG_TYPE_DEVICE 80
|
||||
#define AQH_MSG_TYPE_MEMSTATS 81
|
||||
#define AQH_MSG_TYPE_SYSSTATS 82
|
||||
|
||||
#define AQH_MSG_TYPE_REBOOT_REQ 90
|
||||
#define AQH_MSG_TYPE_REBOOT_RSP 91
|
||||
#define AQH_MSG_TYPE_REBOOT_REQ 90
|
||||
#define AQH_MSG_TYPE_REBOOT_RSP 91
|
||||
|
||||
#define AQH_MSG_TYPE_VALUE_REPORT 100
|
||||
#define AQH_MSG_TYPE_VALUE_SET 101
|
||||
#define AQH_MSG_TYPE_VALUE_SET_ACK 102
|
||||
#define AQH_MSG_TYPE_VALUE_SET_NACK 103
|
||||
|
||||
|
||||
/* internal msg types via NET interface */
|
||||
|
||||
170
aqhome/msg/msg_value3.c
Normal file
170
aqhome/msg/msg_value3.c
Normal file
@@ -0,0 +1,170 @@
|
||||
/****************************************************************************
|
||||
* 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_value3.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_VALUE3_UID 0 /* 4 bytes */
|
||||
#define AQH_MSG_OFFS_VALUE3_MSGID 4 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_VALUE3_VALUEID 6 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_VALUE3_VALUETYPE 7 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_VALUE3_VALUE 8 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_VALUE3_DENOM 10 /* 2 bytes */
|
||||
|
||||
#define AQH_MSG_VALUE3_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE3_DENOM+2)
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_Value3Msg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE3_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int16_t AQH_Value3Msg_GetMsgId(const GWEN_MSG *msg)
|
||||
{
|
||||
return (int16_t) GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE3_MSGID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_Value3Msg_GetValueId(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE3_VALUEID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_Value3Msg_GetValueType(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE3_VALUETYPE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int16_t AQH_Value3Msg_GetValueNom(const GWEN_MSG *msg)
|
||||
{
|
||||
return (int16_t) GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE3_VALUE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int16_t AQH_Value3Msg_GetValueDenom(const GWEN_MSG *msg)
|
||||
{
|
||||
return (int16_t) GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE3_DENOM, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *AQH_Value3Msg_GetValueTypeName(const GWEN_MSG *msg)
|
||||
{
|
||||
uint8_t t;
|
||||
|
||||
t=AQH_Value3Msg_GetValueType(msg);
|
||||
switch(t) {
|
||||
case AQH_MSG_VALUE3_TYPE_TEMP: return "temperature";
|
||||
case AQH_MSG_VALUE3_TYPE_HUMIDITY: return "humidity";
|
||||
case AQH_MSG_VALUE3_TYPE_DOOR: return "door_window";
|
||||
default: break;
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *AQH_Value3Msg_GetValueAsWindowStateString(const GWEN_MSG *msg)
|
||||
{
|
||||
switch(AQH_Value3Msg_GetValueNom(msg)) {
|
||||
case 0: return "closed";
|
||||
case 128: return "tilted";
|
||||
case 255: return "open";
|
||||
default: break;
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *AQH_Value3Msg_GetValueTypeUnits(const GWEN_MSG *msg)
|
||||
{
|
||||
uint8_t t;
|
||||
|
||||
t=AQH_Value3Msg_GetValueType(msg);
|
||||
switch(t) {
|
||||
case AQH_MSG_VALUE3_TYPE_TEMP: return "Celsius";
|
||||
case AQH_MSG_VALUE3_TYPE_HUMIDITY: return "%";
|
||||
case AQH_MSG_VALUE3_TYPE_DOOR: return NULL;
|
||||
default: break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
double AQH_Value3Msg_GetValue(const GWEN_MSG *msg)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_VALUE3_MINSIZE) {
|
||||
const uint8_t *ptr;
|
||||
double value;
|
||||
double denom;
|
||||
uint16_t intDenom;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN;
|
||||
value=(double)((ptr[AQH_MSG_OFFS_VALUE3_VALUE])+(ptr[AQH_MSG_OFFS_VALUE3_VALUE+1]<<8));
|
||||
intDenom=(ptr[AQH_MSG_OFFS_VALUE3_DENOM])+(ptr[AQH_MSG_OFFS_VALUE3_DENOM+1]<<8);
|
||||
denom=(double)(intDenom);
|
||||
if (intDenom==0)
|
||||
denom=1.0;
|
||||
return (double)(value/denom);
|
||||
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_Value3Msg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_VALUE3_MINSIZE) {
|
||||
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",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_Value3Msg_GetUid(msg),
|
||||
(unsigned int)AQH_Value3Msg_GetMsgId(msg),
|
||||
AQH_Value3Msg_GetValueId(msg),
|
||||
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",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_Value3Msg_GetUid(msg),
|
||||
(unsigned int)AQH_Value3Msg_GetMsgId(msg),
|
||||
AQH_Value3Msg_GetValueId(msg),
|
||||
AQH_Value3Msg_GetValueTypeName(msg),
|
||||
AQH_Value3Msg_GetValue(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
47
aqhome/msg/msg_value3.h
Normal file
47
aqhome/msg/msg_value3.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2024 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_VALUE3_H
|
||||
#define AQH_MSG_VALUE3_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_VALUE3_TYPE_TEMP 1
|
||||
#define AQH_MSG_VALUE3_TYPE_HUMIDITY 2
|
||||
#define AQH_MSG_VALUE3_TYPE_DOOR 3
|
||||
|
||||
|
||||
|
||||
AQHOME_API uint32_t AQH_Value3Msg_GetUid(const GWEN_MSG *msg);
|
||||
AQHOME_API int16_t AQH_Value3Msg_GetMsgId(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_Value3Msg_GetValueId(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_Value3Msg_GetValueType(const GWEN_MSG *msg);
|
||||
AQHOME_API int16_t AQH_Value3Msg_GetValueNom(const GWEN_MSG *msg);
|
||||
AQHOME_API int16_t AQH_Value3Msg_GetValueDenom(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API double AQH_Value3Msg_GetValue(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API const char *AQH_Value3Msg_GetValueAsWindowStateString(const GWEN_MSG *msg);
|
||||
AQHOME_API const char *AQH_Value3Msg_GetValueTypeName(const GWEN_MSG *msg);
|
||||
AQHOME_API const char *AQH_Value3Msg_GetValueTypeUnits(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API void AQH_Value3Msg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user