aqhome: completed adapting to msgio2 interface.
This commit is contained in:
89
apps/aqhomed/loop_tty.c
Normal file
89
apps/aqhomed/loop_tty.c
Normal file
@@ -0,0 +1,89 @@
|
||||
/****************************************************************************
|
||||
* 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 <config.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "./loop_tty.h"
|
||||
#include "./loop_tty_ipc.h"
|
||||
#include "./loop_tty_mqtt.h"
|
||||
#include "./aqhomed_p.h"
|
||||
#include "./tty_log.h"
|
||||
#include "./tty_write.h"
|
||||
#include "./db.h"
|
||||
|
||||
#include "aqhome/msg/endpoint2_tty.h"
|
||||
#include "aqhome/msg/msg_node.h"
|
||||
#include "aqhome/msg/msg_value2.h"
|
||||
#include "aqhome/ipc/endpoint2_ipc.h"
|
||||
#include "aqhome/ipc/msg_ipc_forward.h"
|
||||
#include "aqhome/ipc/msg_ipc_value.h"
|
||||
#include "aqhome/mqtt/endpoint2_mqttc.h"
|
||||
|
||||
#include <gwenhywfar/gwenhywfar.h>
|
||||
#include <gwenhywfar/args.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
#include <gwenhywfar/endpoint2_tcpd.h>
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* defines
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define I18N(msg) msg
|
||||
#define I18S(msg) msg
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* forward declarations
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void _handleTtyMsg(AQHOMED *aqh, const GWEN_MSG *msg);
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* implementations
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
void AqHomed_ReadAndHandleTtyMessages(AQHOMED *aqh)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
|
||||
while( (msg=GWEN_MsgEndpoint2_TakeFirstReceivedMessage(aqh->ttyEndpoint)) ) {
|
||||
_handleTtyMsg(aqh, msg);
|
||||
GWEN_Msg_free(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _handleTtyMsg(AQHOMED *aqh, const GWEN_MSG *msg)
|
||||
{
|
||||
if (aqh->logFile)
|
||||
AqHomed_LogTtyMsg(aqh, msg);
|
||||
if (aqh->writeFolder)
|
||||
AqHomed_WriteTtyMsg(aqh, msg);
|
||||
if (aqh->nodeDb)
|
||||
AqHomed_NodeMsgToDb(aqh, msg);
|
||||
if (aqh->ipcdEndpoint)
|
||||
AqHomed_ForwardTtyMsgToIpcClients(aqh, msg);
|
||||
if (aqh->mqttEndpoint)
|
||||
AqHomed_ForwardTtyMsgToMqttServer(aqh, msg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user