From 8d1661d8e44a300114de8ccc5c2a7429a23c71f5 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 1 Jun 2025 00:20:28 +0200 Subject: [PATCH] improved output from "getdevices" command. --- apps/aqhome-tool/nodes/getnodes.c | 35 ++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/apps/aqhome-tool/nodes/getnodes.c b/apps/aqhome-tool/nodes/getnodes.c index 9f08745..8cacc6e 100644 --- a/apps/aqhome-tool/nodes/getnodes.c +++ b/apps/aqhome-tool/nodes/getnodes.c @@ -58,6 +58,7 @@ static AQH_MESSAGE *_createRequestMessage(AQH_OBJECT *o, uint32_t msgId); static int _handleResponseMessage(AQH_OBJECT *o, const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList, int first); static void _printNode(const AQH_NODE_INFO *ni, int printAll); static void _printUintAsTextOrHex(uint32_t u, int bits); +static void _printDeviceIdAsTextOrHex(uint32_t u, int version); @@ -163,9 +164,7 @@ void _printNode(const AQH_NODE_INFO *ni, int printAll) _printUintAsTextOrHex(u, 32); fprintf(stdout, ":"); u=AQH_NodeInfo_GetDeviceType(ni); - _printUintAsTextOrHex(u, 16); - u=AQH_NodeInfo_GetDeviceVersion(ni); - fprintf(stdout, " v%d.%d", (u>>8) & 0xff, u & 0xff); + _printDeviceIdAsTextOrHex(u, AQH_NodeInfo_GetDeviceVersion(ni)); u=AQH_NodeInfo_GetFirmwareVersion(ni); fprintf(stdout, ", firmware=%d.%d.%d (%d), ", (u>>16) & 0xff, (u>>8) & 0xff, u & 0xff, (u>>24) & 0xff); @@ -189,6 +188,36 @@ void _printNode(const AQH_NODE_INFO *ni, int printAll) +void _printDeviceIdAsTextOrHex(uint32_t u, int version) +{ + int i; + uint8_t d; + int hasNonPrintable=0; + int hasPrintable=0; + + for (i=0; i<16; i+=8) { + d=((u>>i) & 0xff); + if (d==0) { /* undecided */ + } + else if (isalnum(d)) + hasPrintable=1; + else + hasNonPrintable=1; + } + if (hasNonPrintable || !hasPrintable) + fprintf(stdout, "%02x v%d.%d", u, (version>>8) & 0xff, version & 0xff); + else { + for (i=0; i<16; i+=8) { + d=((u>>i) & 0xff); + + fprintf(stdout, "%c", d?d:' '); + } + fprintf(stdout, "%2d (%d)", (version>>8) & 0xff, version & 0xff); + } +} + + + void _printUintAsTextOrHex(uint32_t u, int bits) { int i;