aqhome: adapted to latest changes in node firmware.
This commit is contained in:
@@ -23,32 +23,35 @@
|
||||
#include <gwenhywfar/msg_ipc.h>
|
||||
|
||||
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_FLAGS 0 /* 1 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_BUSADDR 1 /* 1 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_UID 2 /* 4 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_FWTYPE 6 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_FWVER 8 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_MODULES 10 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_LASTCHG 12 /* 8 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_PKGOUT 20 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_PKGIN 22 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_COLLISIONS 24 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_BUSY 26 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_CRC 28 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_IO 30 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_FLAGS 0 /* 1 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_BUSADDR 1 /* 1 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_UID 2 /* 4 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_MANUF 6 /* 4 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_DEVTYPE 10 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_DEVVER 12 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_FWVER 14 /* 4 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_LASTCHG 18 /* 8 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_PKGOUT 26 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_PKGIN 28 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_COLLISIONS 30 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_BUSY 32 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_CRC 34 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_IO 36 /* 2 bytes */
|
||||
|
||||
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_LASTCHG+8)
|
||||
|
||||
|
||||
static void _addU16t(uint8_t **pPtr, uint16_t i);
|
||||
static void _addU32t(uint8_t **pPtr, uint32_t i);
|
||||
static void _addU64t(uint8_t **pPtr, uint64_t i);
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_GetDevicesResponseIpcMsg_new(uint16_t code, uint8_t flags, const AQH_NODE_INFO *ni)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
uint8_t *ptr;
|
||||
uint32_t u32;
|
||||
uint64_t u64=0;
|
||||
const GWEN_TIMESTAMP *t;
|
||||
|
||||
msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code, AQH_MSGIPC_GETDEVICES_RSP_MINSIZE, NULL);
|
||||
@@ -57,60 +60,21 @@ GWEN_MSG *AQH_GetDevicesResponseIpcMsg_new(uint16_t code, uint8_t flags, const A
|
||||
*(ptr++)=flags & 0xff;
|
||||
|
||||
*(ptr++)=AQH_NodeInfo_GetBusAddress(ni);
|
||||
_addU32t(&ptr, AQH_NodeInfo_GetUid(ni));
|
||||
|
||||
u32=AQH_NodeInfo_GetUid(ni);
|
||||
*(ptr++)=u32 & 0xff;
|
||||
*(ptr++)=(u32>>8) & 0xff;
|
||||
*(ptr++)=(u32>>16) & 0xff;
|
||||
*(ptr++)=(u32>>24) & 0xff;
|
||||
|
||||
u32=AQH_NodeInfo_GetFirmwareType(ni);
|
||||
*(ptr++)=u32 & 0xff;
|
||||
*(ptr++)=(u32>>8) & 0xff;
|
||||
|
||||
u32=AQH_NodeInfo_GetFirmwareVersion(ni);
|
||||
*(ptr++)=u32 & 0xff;
|
||||
*(ptr++)=(u32>>8) & 0xff;
|
||||
|
||||
u32=AQH_NodeInfo_GetModules(ni);
|
||||
*(ptr++)=u32 & 0xff;
|
||||
*(ptr++)=(u32>>8) & 0xff;
|
||||
|
||||
_addU32t(&ptr, AQH_NodeInfo_GetManufacturer(ni));
|
||||
_addU16t(&ptr, AQH_NodeInfo_GetDeviceType(ni));
|
||||
_addU16t(&ptr, AQH_NodeInfo_GetDeviceVersion(ni));
|
||||
_addU32t(&ptr, AQH_NodeInfo_GetFirmwareVersion(ni));
|
||||
t=AQH_NodeInfo_GetTimestampLastChange(ni);
|
||||
if (t)
|
||||
u64=(uint64_t)GWEN_Timestamp_toInt64(t);
|
||||
*(ptr++)=u64 & 0xff;
|
||||
*(ptr++)=(u64>>8) & 0xff;
|
||||
*(ptr++)=(u64>>16) & 0xff;
|
||||
*(ptr++)=(u64>>24) & 0xff;
|
||||
*(ptr++)=(u64>>32) & 0xff;
|
||||
*(ptr++)=(u64>>40) & 0xff;
|
||||
*(ptr++)=(u64>>48) & 0xff;
|
||||
*(ptr++)=(u64>>56) & 0xff;
|
||||
_addU64t(&ptr, t?((uint64_t)GWEN_Timestamp_toInt64(t)):0L);
|
||||
|
||||
u32=AQH_NodeInfo_GetStatsPacketsOut(ni);
|
||||
*(ptr++)=u32 & 0xff;
|
||||
*(ptr++)=(u32>>8) & 0xff;
|
||||
|
||||
u32=AQH_NodeInfo_GetStatsPacketsIn(ni);
|
||||
*(ptr++)=u32 & 0xff;
|
||||
*(ptr++)=(u32>>8) & 0xff;
|
||||
|
||||
u32=AQH_NodeInfo_GetStatsCollisions(ni);
|
||||
*(ptr++)=u32 & 0xff;
|
||||
*(ptr++)=(u32>>8) & 0xff;
|
||||
|
||||
u32=AQH_NodeInfo_GetStatsBusy(ni);
|
||||
*(ptr++)=u32 & 0xff;
|
||||
*(ptr++)=(u32>>8) & 0xff;
|
||||
|
||||
u32=AQH_NodeInfo_GetStatsCrcErrors(ni);
|
||||
*(ptr++)=u32 & 0xff;
|
||||
*(ptr++)=(u32>>8) & 0xff;
|
||||
|
||||
u32=AQH_NodeInfo_GetStatsIoErrors(ni);
|
||||
*(ptr++)=u32 & 0xff;
|
||||
*(ptr++)=(u32>>8) & 0xff;
|
||||
_addU16t(&ptr, AQH_NodeInfo_GetStatsPacketsOut(ni));
|
||||
_addU16t(&ptr, AQH_NodeInfo_GetStatsPacketsIn(ni));
|
||||
_addU16t(&ptr, AQH_NodeInfo_GetStatsCollisions(ni));
|
||||
_addU16t(&ptr, AQH_NodeInfo_GetStatsBusy(ni));
|
||||
_addU16t(&ptr, AQH_NodeInfo_GetStatsCrcErrors(ni));
|
||||
_addU16t(&ptr, AQH_NodeInfo_GetStatsIoErrors(ni));
|
||||
|
||||
return msg;
|
||||
}
|
||||
@@ -138,23 +102,30 @@ uint32_t AQH_GetDevicesResponseIpcMsg_GetUid(const GWEN_MSG *msg)
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_GetDevicesResponseIpcMsg_GetFirmwareType(const GWEN_MSG *msg)
|
||||
uint32_t AQH_GetDevicesResponseIpcMsg_GetManufacturer(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_FWTYPE, 0);
|
||||
return GWEN_Msg_GetUint32At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_MANUF, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_GetDevicesResponseIpcMsg_GetFirmwareVersion(const GWEN_MSG *msg)
|
||||
uint16_t AQH_GetDevicesResponseIpcMsg_GetDeviceType(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_FWVER, 0);
|
||||
return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_DEVTYPE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_GetDevicesResponseIpcMsg_GetModules(const GWEN_MSG *msg)
|
||||
uint16_t AQH_GetDevicesResponseIpcMsg_GetDeviceVersion(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_MODULES, 0);
|
||||
return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_DEVVER, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_GetDevicesResponseIpcMsg_GetFirmwareVersion(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_FWVER, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -216,7 +187,8 @@ void AQH_GetDevicesResponseIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGIPC_GETDEVICES_RSP_MINSIZE) {
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"GET_DEVICES_RSP (code=%d, proto=%d, proto version=%d, uid=0x%08x, bus addr=0x%02x, flags=0x%02x)\n",
|
||||
"GET_DEVICES_RSP %s (code=%d, proto=%d, proto version=%d, uid=0x%08x, bus addr=0x%02x, flags=0x%02x)\n",
|
||||
sText,
|
||||
GWEN_IpcMsg_GetCode(msg),
|
||||
GWEN_IpcMsg_GetProtoId(msg),
|
||||
GWEN_IpcMsg_GetProtoVersion(msg),
|
||||
@@ -228,6 +200,47 @@ void AQH_GetDevicesResponseIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER
|
||||
|
||||
|
||||
|
||||
void _addU16t(uint8_t **pPtr, uint16_t i)
|
||||
{
|
||||
uint8_t *ptr=*pPtr;
|
||||
|
||||
*(ptr++)=i & 0xff;
|
||||
*(ptr++)=(i>>8) & 0xff;
|
||||
*pPtr=ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _addU32t(uint8_t **pPtr, uint32_t i)
|
||||
{
|
||||
uint8_t *ptr=*pPtr;
|
||||
|
||||
*(ptr++)=i & 0xff;
|
||||
*(ptr++)=(i>>8) & 0xff;
|
||||
*(ptr++)=(i>>16) & 0xff;
|
||||
*(ptr++)=(i>>24) & 0xff;
|
||||
*pPtr=ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _addU64t(uint8_t **pPtr, uint64_t i)
|
||||
{
|
||||
uint8_t *ptr=*pPtr;
|
||||
|
||||
*(ptr++)=i & 0xff;
|
||||
*(ptr++)=(i>>8) & 0xff;
|
||||
*(ptr++)=(i>>16) & 0xff;
|
||||
*(ptr++)=(i>>24) & 0xff;
|
||||
*(ptr++)=(i>>32) & 0xff;
|
||||
*(ptr++)=(i>>40) & 0xff;
|
||||
*(ptr++)=(i>>48) & 0xff;
|
||||
*(ptr++)=(i>>56) & 0xff;
|
||||
*pPtr=ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -27,9 +27,12 @@ AQHOME_API uint8_t AQH_GetDevicesResponseIpcMsg_GetFlags(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_GetDevicesResponseIpcMsg_GetBusAddress(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API uint32_t AQH_GetDevicesResponseIpcMsg_GetUid(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetFirmwareType(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetFirmwareVersion(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetModules(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API uint32_t AQH_GetDevicesResponseIpcMsg_GetManufacturer(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetDeviceType(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetDeviceVersion(const GWEN_MSG *msg);
|
||||
AQHOME_API uint32_t AQH_GetDevicesResponseIpcMsg_GetFirmwareVersion(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API int64_t AQH_GetDevicesResponseIpcMsg_GetTimestamp(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetPkgOut(const GWEN_MSG *msg);
|
||||
|
||||
Reference in New Issue
Block a user