More work on aqhome-react.
- added some units - added some types
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "./loop.h"
|
||||
#include "./aqhome_react_p.h"
|
||||
#include "aqhome-react/units/u_varchanges.h"
|
||||
|
||||
#include "aqhome/ipc/data/ipc_data.h"
|
||||
#include "aqhome/ipc/data/msg_data_multidata.h"
|
||||
@@ -35,7 +36,9 @@
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void _handleDataResponse(GWEN_MSG *msg);
|
||||
static void _handleDataResponse(AQHREACT_UNIT *varChangeUnit, GWEN_MSG *msg);
|
||||
static int _processAllNets(AQHOME_REACT *aqh);
|
||||
static int _processNet(AQHREACT_UNIT_NET *unitNet);
|
||||
|
||||
|
||||
|
||||
@@ -44,19 +47,19 @@ static void _handleDataResponse(GWEN_MSG *msg);
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void AqHomeReact_Loop(AQHOME_REACT *aqh, int timeoutInMilliSecs)
|
||||
void AqHomeReact_IoLoop(AQHOME_REACT *aqh, int timeoutInMilliSecs)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
|
||||
GWEN_MsgEndpoint_IoLoop(aqh->brokerEndpoint, timeoutInMilliSecs);
|
||||
msg=GWEN_MsgEndpoint_TakeFirstReceivedMessage(aqh->brokerEndpoint);
|
||||
if (msg) {
|
||||
|
||||
while( (msg=GWEN_MsgEndpoint_TakeFirstReceivedMessage(aqh->brokerEndpoint)) ) {
|
||||
uint16_t code;
|
||||
|
||||
code=GWEN_IpcMsg_GetCode(msg);
|
||||
if (code==AQH_MSGTYPE_IPC_DATA_DATACHANGED) {
|
||||
DBG_INFO(NULL, "Received expected IPC message");
|
||||
_handleDataResponse(msg);
|
||||
_handleDataResponse(aqh->varChangeUnit, msg);
|
||||
}
|
||||
else if (code==AQH_MSGTYPE_IPC_DATA_RESULT) {
|
||||
DBG_INFO(NULL, "Received IPC result message, ignoring");
|
||||
@@ -65,12 +68,80 @@ void AqHomeReact_Loop(AQHOME_REACT *aqh, int timeoutInMilliSecs)
|
||||
DBG_INFO(NULL, "Received unexpected message %d (%x)", code, code);
|
||||
}
|
||||
GWEN_Msg_free(msg);
|
||||
}
|
||||
} /* while */
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _handleDataResponse(GWEN_MSG *msg)
|
||||
void AqHomeReact_ProcessAllUnits(AQHOME_REACT *aqh)
|
||||
{
|
||||
int rv;
|
||||
|
||||
do {
|
||||
rv=_processAllNets(aqh);
|
||||
} while (rv==1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int _processAllNets(AQHOME_REACT *aqh)
|
||||
{
|
||||
int result=0;
|
||||
int rv;
|
||||
AQHREACT_UNIT_NET *unitNet;
|
||||
|
||||
rv=AQHREACT_Unit_Process(aqh->varChangeUnit);
|
||||
if (rv>0)
|
||||
result=1;
|
||||
|
||||
rv=AQHREACT_Unit_Process(aqh->timerUnit);
|
||||
if (rv>0)
|
||||
result=1;
|
||||
|
||||
unitNet=AQHREACT_UnitNet_List_First(aqh->unitNetList);
|
||||
while(unitNet) {
|
||||
rv=_processNet(unitNet);
|
||||
if (rv>0)
|
||||
result=1;
|
||||
|
||||
unitNet=AQHREACT_UnitNet_List_Next(unitNet);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int _processNet(AQHREACT_UNIT_NET *unitNet)
|
||||
{
|
||||
AQHREACT_UNIT_LIST *unitList;
|
||||
const char *netName;
|
||||
|
||||
netName=AQHREACT_UnitNet_GetName(unitNet);
|
||||
DBG_INFO(NULL, "Processing net \"%s\"", netName?netName:"<unnamed>");
|
||||
unitList=AQHREACT_UnitNet_GetUnitList(unitNet);
|
||||
if (unitList) {
|
||||
int result=0;
|
||||
AQHREACT_UNIT *unit;
|
||||
|
||||
unit=AQHREACT_Unit_List_First(unitList);
|
||||
while(unit) {
|
||||
int rv;
|
||||
|
||||
rv=AQHREACT_Unit_Process(unit);
|
||||
if (rv>0)
|
||||
result=1;
|
||||
unit=AQHREACT_Unit_List_Next(unit);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _handleDataResponse(AQHREACT_UNIT *varChangeUnit, GWEN_MSG *msg)
|
||||
{
|
||||
AQH_VALUE *value;
|
||||
const GWEN_TAG16 *tag;
|
||||
@@ -92,7 +163,7 @@ void _handleDataResponse(GWEN_MSG *msg)
|
||||
|
||||
timestamp=*(dataPoints++);
|
||||
u.i=*(dataPoints++);
|
||||
// Utils_PrintFormattedSingleDataPoint(value, timestamp, u.f, tmpl);
|
||||
AqHomeReact_UnitVarChanges_ValueUpdated(varChangeUnit, value, timestamp, u.f);
|
||||
}
|
||||
}
|
||||
AQH_Value_free(value);
|
||||
|
||||
Reference in New Issue
Block a user