aqhome: adapted to latest changes in node firmware.
This commit is contained in:
@@ -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