/**************************************************************************** * This file is part of the project AqHome. * AqHome (c) by 2023 Martin Preuss, all rights reserved. * * The license for this file can be found in the file COPYING which you * should have received along with this file. ****************************************************************************/ #ifdef HAVE_CONFIG_H # include #endif #include "./loop_broker.h" #include "./aqhomed_p.h" #include "./b_setdata.h" #include "./tty_log.h" #include "./db.h" #include "aqhome/msg/endpoint_tty.h" #include "aqhome/msg/msg_node.h" #include "aqhome/msg/msg_value2.h" #include "aqhome/msg/msg_ping.h" #include "aqhome/ipc/endpoint_ipc.h" #include "aqhome/ipc/msg_ipc_result.h" #include "aqhome/ipc/data/ipc_data.h" #include #include #include #include /* ------------------------------------------------------------------------------------------------ * defines * ------------------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------------------ * forward declarations * ------------------------------------------------------------------------------------------------ */ static void _handleIpcMsg(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, GWEN_MSG *msg); /* ------------------------------------------------------------------------------------------------ * implementations * ------------------------------------------------------------------------------------------------ */ void AqHomed_ReadAndHandleBrokerMessages(AQHOMED *aqh) { if (aqh->brokerEndpoint) { GWEN_MSG_ENDPOINT *epTcp; GWEN_MSG *msg; epTcp=aqh->brokerEndpoint; while( (msg=GWEN_MsgEndpoint_TakeFirstReceivedMessage(epTcp)) ) { uint16_t code; code=GWEN_IpcMsg_GetCode(msg); DBG_DEBUG(AQH_LOGDOMAIN, "Received IPC packet %d (%x)", (int) code, code); _handleIpcMsg(aqh, epTcp, msg); GWEN_Msg_free(msg); } } } void _handleIpcMsg(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, GWEN_MSG *msg) { uint16_t code; /* exec IPC message */ code=GWEN_IpcMsg_GetCode(msg); DBG_DEBUG(AQH_LOGDOMAIN, "Received IPC packet"); switch(code) { // case AQH_MSGTYPE_IPC_DATA_SETDATA: AqHomeNodes_HandleBrokerSetData(aqh, ep, msg); break; default: break; } }