aqhome: adapted to latest changes in node firmware.
This commit is contained in:
@@ -192,9 +192,7 @@ void _handleMsgDevice(AQHOMED *aqh, const GWEN_MSG *msg)
|
||||
uid=AQH_DeviceMsg_GetUid(msg);
|
||||
ni=_getOrCreateNodeAndUpdateUidAddr(aqh, msg, uid);
|
||||
if (ni) {
|
||||
AQH_NodeInfo_SetFirmwareType(ni, AQH_DeviceMsg_GetFirmwareType(msg));
|
||||
AQH_NodeInfo_SetFirmwareVersion(ni, (AQH_DeviceMsg_GetFirmwareHigh(msg)<<8) | AQH_DeviceMsg_GetFirmwareLow(msg));
|
||||
AQH_NodeInfo_SetModules(ni, AQH_DeviceMsg_GetModuleMask(msg));
|
||||
// TODO
|
||||
_updateTimestampLastChange(ni);
|
||||
AQH_NodeDb_SetModified(aqh->nodeDb);
|
||||
}
|
||||
@@ -213,8 +211,14 @@ void _handleMsgFlashReady(AQHOMED *aqh, const GWEN_MSG *msg)
|
||||
uid=AQH_FlashReadyMsg_GetUid(msg);
|
||||
ni=_getOrCreateNodeAndUpdateUidAddr(aqh, msg, uid);
|
||||
if (ni) {
|
||||
AQH_NodeInfo_SetFirmwareType(ni, AQH_FlashReadyMsg_GetFirmwareType(msg));
|
||||
AQH_NodeInfo_SetFirmwareVersion(ni, AQH_FlashReadyMsg_GetFirmwareVersion(msg));
|
||||
AQH_NodeInfo_SetManufacturer(ni, AQH_FlashReadyMsg_GetManufacturer(msg));
|
||||
AQH_NodeInfo_SetDeviceType(ni, AQH_FlashReadyMsg_GetDeviceType(msg));
|
||||
AQH_NodeInfo_SetDeviceVersion(ni, (AQH_FlashReadyMsg_GetDeviceVersion(msg)<<8)+AQH_FlashReadyMsg_GetDeviceRevision(msg));
|
||||
AQH_NodeInfo_SetFirmwareVersion(ni,
|
||||
(AQH_FlashReadyMsg_GetFirmwareVariant(msg)<<24) |
|
||||
(AQH_FlashReadyMsg_GetFirmwareVersionMajor(msg)<<16) |
|
||||
(AQH_FlashReadyMsg_GetFirmwareVersionMinor(msg)<<8) |
|
||||
AQH_FlashReadyMsg_GetFirmwareVersionPatchlevel(msg));
|
||||
_updateTimestampLastChange(ni);
|
||||
AQH_NodeDb_SetModified(aqh->nodeDb);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "aqhome/msg/endpoint_tty.h"
|
||||
#include "aqhome/msg/msg_node.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/ipc/endpoint_ipc.h"
|
||||
@@ -48,6 +49,7 @@
|
||||
*/
|
||||
|
||||
static void _processValue2Message(AQHOMED *aqh, const GWEN_MSG *nodeMsg);
|
||||
static void _processValue3Message(AQHOMED *aqh, const GWEN_MSG *nodeMsg);
|
||||
static void _processSendStatsMessage(AQHOMED *aqh, const GWEN_MSG *nodeMsg);
|
||||
static void _processRecvStatsMessage(AQHOMED *aqh, const GWEN_MSG *nodeMsg);
|
||||
static void _publishInt(AQHOMED *aqh, uint32_t uid, int valueId, const char *valueUnits, const char *valuePath, int v);
|
||||
@@ -70,6 +72,12 @@ void AqHomed_ForwardTtyMsgToBroker(AQHOMED *aqh, const GWEN_MSG *nodeMsg)
|
||||
case AQH_MSG_TYPE_VALUE2:
|
||||
_processValue2Message(aqh, nodeMsg);
|
||||
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:
|
||||
_processValue3Message(aqh, nodeMsg);
|
||||
break;
|
||||
case AQH_MSG_TYPE_COMSENDSTATS:
|
||||
_processSendStatsMessage(aqh, nodeMsg);
|
||||
break;
|
||||
@@ -96,6 +104,18 @@ void _processValue2Message(AQHOMED *aqh, const GWEN_MSG *nodeMsg)
|
||||
|
||||
|
||||
|
||||
void _processValue3Message(AQHOMED *aqh, const GWEN_MSG *nodeMsg)
|
||||
{
|
||||
_publishDouble(aqh,
|
||||
AQH_Value3Msg_GetUid(nodeMsg),
|
||||
AQH_Value3Msg_GetValueId(nodeMsg),
|
||||
AQH_Value3Msg_GetValueTypeUnits(nodeMsg),
|
||||
AQH_Value3Msg_GetValueTypeName(nodeMsg),
|
||||
AQH_Value3Msg_GetValue(nodeMsg));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _processSendStatsMessage(AQHOMED *aqh, const GWEN_MSG *nodeMsg)
|
||||
{
|
||||
uint16_t packetsOutInt;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
#define I18S(msg) msg
|
||||
@@ -35,6 +36,8 @@
|
||||
|
||||
static int _doGetNodes(GWEN_DB_NODE *dbArgs);
|
||||
static int _sendGetDevices(GWEN_MSG_ENDPOINT *epTcp);
|
||||
static void _printNodeFromMsg(const GWEN_MSG *msg);
|
||||
static void _printUintAsTextOrHex(uint32_t u, int bits);
|
||||
|
||||
|
||||
|
||||
@@ -159,31 +162,11 @@ int _doGetNodes(GWEN_DB_NODE *dbArgs)
|
||||
break;
|
||||
}
|
||||
else if (code==AQH_MSGTYPE_IPC_NODES_GETDEVICES_RSP) {
|
||||
uint16_t fwVersion;
|
||||
int64_t ts64;
|
||||
GWEN_TIMESTAMP *ts;
|
||||
uint8_t flags;
|
||||
|
||||
flags=AQH_GetDevicesResponseIpcMsg_GetFlags(msg);
|
||||
fwVersion=AQH_GetDevicesResponseIpcMsg_GetFirmwareVersion(msg);
|
||||
ts64=AQH_GetDevicesResponseIpcMsg_GetTimestamp(msg);
|
||||
ts=GWEN_Timestamp_fromInt64(ts64); /* TODO: fix timestamp */
|
||||
_printNodeFromMsg(msg);
|
||||
|
||||
fprintf(stdout, "- node: %02x (uid=%04x, fw type=%02x, fw version=%d.%d, timeStamp: %016lx"
|
||||
", pkg out: %d, pkg in: %d, collisions: %d, busy: %d, crc: %d, io: %d)\n",
|
||||
AQH_GetDevicesResponseIpcMsg_GetBusAddress(msg),
|
||||
AQH_GetDevicesResponseIpcMsg_GetUid(msg),
|
||||
AQH_GetDevicesResponseIpcMsg_GetFirmwareType(msg),
|
||||
(fwVersion>>8) & 0xff,
|
||||
fwVersion & 0xff,
|
||||
(unsigned long int)ts64,
|
||||
AQH_GetDevicesResponseIpcMsg_GetPkgOut(msg),
|
||||
AQH_GetDevicesResponseIpcMsg_GetPkgIn(msg),
|
||||
AQH_GetDevicesResponseIpcMsg_GetCollisions(msg),
|
||||
AQH_GetDevicesResponseIpcMsg_GetBusy(msg),
|
||||
AQH_GetDevicesResponseIpcMsg_GetCrcErrors(msg),
|
||||
AQH_GetDevicesResponseIpcMsg_GetIoErrors(msg));
|
||||
GWEN_Timestamp_free(ts);
|
||||
GWEN_Msg_free(msg);
|
||||
if (flags & AQH_MSGIPC_GETDEVICES_RSP_FLAGS_LAST) {
|
||||
DBG_INFO(NULL, "Last");
|
||||
@@ -202,6 +185,71 @@ int _doGetNodes(GWEN_DB_NODE *dbArgs)
|
||||
|
||||
|
||||
|
||||
void _printNodeFromMsg(const GWEN_MSG *msg)
|
||||
{
|
||||
uint32_t u;
|
||||
int64_t ts64;
|
||||
GWEN_TIMESTAMP *ts;
|
||||
|
||||
ts64=AQH_GetDevicesResponseIpcMsg_GetTimestamp(msg);
|
||||
ts=GWEN_Timestamp_fromInt64(ts64); /* TODO: fix timestamp */
|
||||
|
||||
fprintf(stdout, "- node: addr=%d, uid=0x%08x, device=",
|
||||
AQH_GetDevicesResponseIpcMsg_GetBusAddress(msg),
|
||||
(unsigned int) AQH_GetDevicesResponseIpcMsg_GetUid(msg));
|
||||
u=AQH_GetDevicesResponseIpcMsg_GetManufacturer(msg);
|
||||
_printUintAsTextOrHex(u, 32);
|
||||
fprintf(stdout, ":");
|
||||
u=AQH_GetDevicesResponseIpcMsg_GetDeviceType(msg);
|
||||
_printUintAsTextOrHex(u, 16);
|
||||
u=AQH_GetDevicesResponseIpcMsg_GetDeviceVersion(msg);
|
||||
fprintf(stdout, " v%d.%d", (u>>8) & 0xff, u & 0xff);
|
||||
u=AQH_GetDevicesResponseIpcMsg_GetFirmwareVersion(msg);
|
||||
fprintf(stdout, ", firmware=%d.%d.%d (%d), ",
|
||||
(u>>16) & 0xff, (u>>8) & 0xff, u & 0xff, (u>>24) & 0xff);
|
||||
if (ts) {
|
||||
fprintf(stdout, "last seen %s, ", GWEN_Timestamp_GetString(ts));
|
||||
GWEN_Timestamp_free(ts);
|
||||
}
|
||||
fprintf(stdout, "pkg out: %d, pkg in: %d, collisions: %d, busy: %d, crc: %d, io: %d\n",
|
||||
AQH_GetDevicesResponseIpcMsg_GetPkgOut(msg),
|
||||
AQH_GetDevicesResponseIpcMsg_GetPkgIn(msg),
|
||||
AQH_GetDevicesResponseIpcMsg_GetCollisions(msg),
|
||||
AQH_GetDevicesResponseIpcMsg_GetBusy(msg),
|
||||
AQH_GetDevicesResponseIpcMsg_GetCrcErrors(msg),
|
||||
AQH_GetDevicesResponseIpcMsg_GetIoErrors(msg));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _printUintAsTextOrHex(uint32_t u, int bits)
|
||||
{
|
||||
int i;
|
||||
uint8_t d;
|
||||
int hasNonPrintable=0;
|
||||
int hasPrintable=0;
|
||||
|
||||
for (i=0; i<bits; i+=8) {
|
||||
d=((u>>i) & 0xff);
|
||||
if (d==0) { /* undecided */
|
||||
}
|
||||
else if (isalnum(d))
|
||||
hasPrintable=1;
|
||||
else
|
||||
hasNonPrintable=1;
|
||||
}
|
||||
if (hasNonPrintable || !hasPrintable)
|
||||
fprintf(stdout, "%08x", u);
|
||||
else {
|
||||
for (i=0; i<bits; i+=8) {
|
||||
d=((u>>i) & 0xff);
|
||||
|
||||
fprintf(stdout, "%c", d?d:' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int _sendGetDevices(GWEN_MSG_ENDPOINT *epTcp)
|
||||
{
|
||||
GWEN_MSG *msgOut;
|
||||
|
||||
Reference in New Issue
Block a user