adapted to latest changes in gwen, more work on data and nodes servers.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "aqhome/msg/msg_sendstats.h"
|
||||
#include "aqhome/msg/msg_recvstats.h"
|
||||
#include "aqhome/msg/msg_value2.h"
|
||||
#include "aqhome/msg/msg_value3.h"
|
||||
#include "aqhome/msg/msg_needaddr.h"
|
||||
#include "aqhome/msg/msg_claimaddr.h"
|
||||
#include "aqhome/msg/msg_haveaddr.h"
|
||||
@@ -39,6 +40,7 @@
|
||||
*/
|
||||
|
||||
static void _handleMsgValue2(AQHOMED *aqh, const GWEN_MSG *msg);
|
||||
static void _handleMsgValue3(AQHOMED *aqh, const GWEN_MSG *msg);
|
||||
static void _handleMsgNeedAddress(AQHOMED *aqh, const GWEN_MSG *msg);
|
||||
static void _handleMsgClaimAddress(AQHOMED *aqh, const GWEN_MSG *msg);
|
||||
static void _handleMsgHaveAddress(AQHOMED *aqh, const GWEN_MSG *msg);
|
||||
@@ -49,6 +51,7 @@ static void _handleMsgFlashReady(AQHOMED *aqh, const GWEN_MSG *msg);
|
||||
|
||||
static AQH_NODE_INFO *_getOrCreateNodeAndUpdateUidAddr(AQHOMED *aqh, const GWEN_MSG *msg, uint32_t uid);
|
||||
static void _updateTimestampLastChange(AQH_NODE_INFO *ni);
|
||||
static void _assignDeviceId(AQHOMED *aqh, AQH_NODE_INFO *ni, uint32_t uid);
|
||||
|
||||
|
||||
|
||||
@@ -78,6 +81,7 @@ void AqHomed_NodeMsgToDb(AQHOMED *aqh, const GWEN_MSG *msg)
|
||||
case AQH_MSG_TYPE_COMSENDSTATS: _handleMsgComSendStat(aqh, msg); break;
|
||||
case AQH_MSG_TYPE_COMRECVSTATS: _handleMsgComRecvStat(aqh, msg); break;
|
||||
case AQH_MSG_TYPE_VALUE2: _handleMsgValue2(aqh, msg); break;
|
||||
case AQH_MSG_TYPE_VALUE_REPORT: _handleMsgValue3(aqh, msg); break;
|
||||
case AQH_MSG_TYPE_NEED_ADDRESS: _handleMsgNeedAddress(aqh, msg); break;
|
||||
case AQH_MSG_TYPE_CLAIM_ADDRESS: _handleMsgClaimAddress(aqh, msg); break;
|
||||
case AQH_MSG_TYPE_HAVE_ADDRESS: _handleMsgHaveAddress(aqh, msg); break;
|
||||
@@ -119,6 +123,20 @@ void _handleMsgValue2(AQHOMED *aqh, const GWEN_MSG *msg)
|
||||
|
||||
|
||||
|
||||
void _handleMsgValue3(AQHOMED *aqh, const GWEN_MSG *msg)
|
||||
{
|
||||
AQH_NODE_INFO *ni;
|
||||
uint32_t uid;
|
||||
|
||||
uid=AQH_Value3Msg_GetUid(msg);
|
||||
ni=_getOrCreateNodeAndUpdateUidAddr(aqh, msg, uid);
|
||||
if (ni==NULL) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Error handling message");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _handleMsgNeedAddress(AQHOMED *aqh, const GWEN_MSG *msg)
|
||||
{
|
||||
AQH_NODE_INFO *ni;
|
||||
@@ -207,6 +225,8 @@ void _handleMsgDevice(AQHOMED *aqh, const GWEN_MSG *msg)
|
||||
uid=AQH_DeviceMsg_GetUid(msg);
|
||||
ni=_getOrCreateNodeAndUpdateUidAddr(aqh, msg, uid);
|
||||
if (ni) {
|
||||
const char *s;
|
||||
|
||||
AQH_NodeInfo_SetManufacturer(ni, AQH_DeviceMsg_GetManufacturer(msg));
|
||||
AQH_NodeInfo_SetDeviceType(ni, AQH_DeviceMsg_GetDeviceType(msg));
|
||||
AQH_NodeInfo_SetDeviceVersion(ni, (AQH_DeviceMsg_GetDeviceVersion(msg)<<8)+AQH_DeviceMsg_GetDeviceRevision(msg));
|
||||
@@ -215,6 +235,9 @@ void _handleMsgDevice(AQHOMED *aqh, const GWEN_MSG *msg)
|
||||
(AQH_DeviceMsg_GetFirmwareVersionMajor(msg)<<16) |
|
||||
(AQH_DeviceMsg_GetFirmwareVersionMinor(msg)<<8) |
|
||||
AQH_DeviceMsg_GetFirmwareVersionPatchlevel(msg));
|
||||
s=AQH_NodeInfo_GetDeviceId(ni);
|
||||
if (!(s && *s))
|
||||
_assignDeviceId(aqh, ni, uid);
|
||||
_updateTimestampLastChange(ni);
|
||||
AQH_NodeDb_SetModified(aqh->nodeDb);
|
||||
}
|
||||
@@ -233,6 +256,8 @@ void _handleMsgFlashReady(AQHOMED *aqh, const GWEN_MSG *msg)
|
||||
uid=AQH_FlashReadyMsg_GetUid(msg);
|
||||
ni=_getOrCreateNodeAndUpdateUidAddr(aqh, msg, uid);
|
||||
if (ni) {
|
||||
const char *s;
|
||||
|
||||
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));
|
||||
@@ -241,6 +266,9 @@ void _handleMsgFlashReady(AQHOMED *aqh, const GWEN_MSG *msg)
|
||||
(AQH_FlashReadyMsg_GetFirmwareVersionMajor(msg)<<16) |
|
||||
(AQH_FlashReadyMsg_GetFirmwareVersionMinor(msg)<<8) |
|
||||
AQH_FlashReadyMsg_GetFirmwareVersionPatchlevel(msg));
|
||||
s=AQH_NodeInfo_GetDeviceId(ni);
|
||||
if (!(s && *s))
|
||||
_assignDeviceId(aqh, ni, uid);
|
||||
_updateTimestampLastChange(ni);
|
||||
AQH_NodeDb_SetModified(aqh->nodeDb);
|
||||
}
|
||||
@@ -291,6 +319,32 @@ AQH_NODE_INFO *_getOrCreateNodeAndUpdateUidAddr(AQHOMED *aqh, const GWEN_MSG *ms
|
||||
|
||||
|
||||
|
||||
void _assignDeviceId(AQHOMED *aqh, AQH_NODE_INFO *ni, uint32_t uid)
|
||||
{
|
||||
const AQHNODE_DEVICE *dev;
|
||||
|
||||
dev=AqHomed_FindDeviceDef(aqh,
|
||||
AQH_NodeInfo_GetManufacturer(ni),
|
||||
AQH_NodeInfo_GetDeviceType(ni),
|
||||
AQH_NodeInfo_GetDeviceVersion(ni));
|
||||
if (dev==NULL) {
|
||||
DBG_ERROR(NULL,
|
||||
"Unknown NODE device encountered (%08x, %04x, %04x)",
|
||||
AQH_NodeInfo_GetManufacturer(ni),
|
||||
AQH_NodeInfo_GetDeviceType(ni),
|
||||
AQH_NodeInfo_GetDeviceVersion(ni));
|
||||
}
|
||||
else {
|
||||
const char *s;
|
||||
|
||||
s=AQHNODE_Device_GetName(dev);
|
||||
DBG_ERROR(NULL, "Found device \"%s\" (%08x)", s?s:"<no name>", uid);
|
||||
AQH_NodeInfo_SetDeviceId(ni, s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _updateTimestampLastChange(AQH_NODE_INFO *ni)
|
||||
{
|
||||
GWEN_TIMESTAMP *t;
|
||||
|
||||
Reference in New Issue
Block a user