aqhome apps: sending a message via aqhome-nodes to nodes now works.
This commit is contained in:
@@ -41,6 +41,8 @@
|
||||
devicesdump.h
|
||||
r_setdata.h
|
||||
r_connect.h
|
||||
r_forward.h
|
||||
r_setaccmsggrps.h
|
||||
</headers>
|
||||
|
||||
<sources>
|
||||
@@ -51,6 +53,8 @@
|
||||
devicesdump.c
|
||||
r_setdata.c
|
||||
r_connect.c
|
||||
r_forward.c
|
||||
r_setaccmsggrps.c
|
||||
main.c
|
||||
</sources>
|
||||
|
||||
|
||||
@@ -29,9 +29,8 @@
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void AQH_NodeServer_HandleConnect(GWEN_UNUSED AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg)
|
||||
void AQH_NodeServer_HandleConnect(GWEN_UNUSED AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList)
|
||||
{
|
||||
GWEN_TAG16_LIST *tagList;
|
||||
AQH_MESSAGE *outMsg;
|
||||
int resultCode=AQH_MSGDATA_RESULT_SUCCESS;
|
||||
char *clientId=NULL;
|
||||
@@ -39,7 +38,6 @@ void AQH_NodeServer_HandleConnect(GWEN_UNUSED AQH_OBJECT *o, AQH_OBJECT *ep, con
|
||||
char *passw=NULL;
|
||||
uint32_t flags;
|
||||
|
||||
tagList=AQH_IpcMessageTag16_ParsePayload(msg, 0);
|
||||
clientId=AQH_Tag16_GetTagDataAsNewString(tagList, AQH_MSG_CONNECT_TAGS_CLIENTID, NULL);
|
||||
userId=AQH_Tag16_GetTagDataAsNewString(tagList, AQH_MSG_CONNECT_TAGS_USERID, NULL);
|
||||
flags=AQH_Tag16_GetTagDataAsUint32(tagList, AQH_MSG_CONNECT_TAGS_FLAGS, 0);
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
|
||||
#include "./server.h"
|
||||
|
||||
#include <gwenhywfar/request.h>
|
||||
#include <gwenhywfar/tag16.h>
|
||||
|
||||
|
||||
|
||||
void AQH_NodeServer_HandleConnect(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *recvdMsg);
|
||||
void AQH_NodeServer_HandleConnect(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *recvdMsg, const GWEN_TAG16_LIST *tagList);
|
||||
|
||||
|
||||
|
||||
|
||||
79
apps/aqhome-nodes/r_forward.c
Normal file
79
apps/aqhome-nodes/r_forward.c
Normal file
@@ -0,0 +1,79 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2025 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 "./r_forward.h"
|
||||
#include "./server_p.h"
|
||||
#include "aqhome/ipc2/endpoint.h"
|
||||
#include "aqhome/msg/ipc/m_ipc.h"
|
||||
#include "aqhome/msg/ipc/nodes/m_ipcn.h"
|
||||
#include "aqhome/msg/ipc/nodes/m_ipcn_forward.h"
|
||||
#include "aqhome/msg/ipc/m_ipc_connect.h"
|
||||
#include "aqhome/msg/ipc/m_ipc_result.h"
|
||||
#include "aqhome/msg/ipc/m_ipc_tag16.h"
|
||||
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* code
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void AQH_NodeServer_HandleForward(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList)
|
||||
{
|
||||
AQH_NODE_SERVER *xo;
|
||||
|
||||
xo=AQH_NodeServer_GetServerData(o);
|
||||
if (xo) {
|
||||
AQH_MESSAGE *outMsg;
|
||||
int resultCode=AQH_MSGDATA_RESULT_SUCCESS;
|
||||
const GWEN_TAG16 *tag;
|
||||
const uint8_t *ptr;
|
||||
uint32_t len;
|
||||
|
||||
tag=tagList?GWEN_Tag16_List_FindFirstByTagType(tagList, AQH_MSGNODE_FORWARD_TAGS_MSG):NULL;
|
||||
ptr=tag?GWEN_Tag16_GetTagData(tag):NULL;
|
||||
len=tag?GWEN_Tag16_GetTagLength(tag):0;
|
||||
|
||||
if (ptr && len) {
|
||||
if (xo->ttyEndpoint) {
|
||||
AQH_MESSAGE *nodeMsg;
|
||||
|
||||
nodeMsg=AQH_Message_new();
|
||||
AQH_Message_SetData(nodeMsg, ptr, len);
|
||||
AQH_Message_SetUsedSize(nodeMsg, len);
|
||||
AQH_Endpoint_AddMsgOut(xo->ttyEndpoint, nodeMsg);
|
||||
}
|
||||
else {
|
||||
DBG_ERROR(NULL, "TTY endpoint currently not connected");
|
||||
resultCode=AQH_MSGDATA_RESULT_ERROR_TRYAGAIN;
|
||||
}
|
||||
}
|
||||
else {
|
||||
DBG_ERROR(NULL, "Empty message to forward");
|
||||
resultCode=AQH_MSGDATA_RESULT_ERROR_BADDATA;
|
||||
}
|
||||
|
||||
outMsg=AQH_IpcMessageResult_new(AQH_IPC_PROTOCOL_NODES_ID,
|
||||
AQH_IPC_PROTOCOL_NODES_VERSION,
|
||||
AQH_MSGTYPE_IPC_NODES_RESULT,
|
||||
AQH_Endpoint_GetNextMessageId(ep),
|
||||
AQH_IpcMessage_GetMsgId(msg),
|
||||
resultCode, NULL);
|
||||
AQH_Endpoint_AddMsgOut(ep, outMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
27
apps/aqhome-nodes/r_forward.h
Normal file
27
apps/aqhome-nodes/r_forward.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2024 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.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQHOMED_R_FORWARD_H
|
||||
#define AQHOMED_R_FORWARD_H
|
||||
|
||||
|
||||
#include "./server.h"
|
||||
|
||||
#include <gwenhywfar/tag16.h>
|
||||
|
||||
|
||||
void AQH_NodeServer_HandleForward(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
56
apps/aqhome-nodes/r_setaccmsggrps.c
Normal file
56
apps/aqhome-nodes/r_setaccmsggrps.c
Normal file
@@ -0,0 +1,56 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2025 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 "./r_setaccmsggrps.h"
|
||||
#include "./server_p.h"
|
||||
#include "aqhome/ipc2/endpoint.h"
|
||||
#include "aqhome/msg/ipc/m_ipc.h"
|
||||
#include "aqhome/msg/ipc/nodes/m_ipcn.h"
|
||||
#include "aqhome/msg/ipc/nodes/m_ipcn_setaccmsggrps.h"
|
||||
#include "aqhome/msg/ipc/m_ipc_connect.h"
|
||||
#include "aqhome/msg/ipc/m_ipc_result.h"
|
||||
#include "aqhome/msg/ipc/m_ipc_tag16.h"
|
||||
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* code
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void AQH_NodeServer_HandleSetAccMsgGrps(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList)
|
||||
{
|
||||
AQH_NODE_SERVER *xo;
|
||||
|
||||
xo=AQH_NodeServer_GetServerData(o);
|
||||
if (xo) {
|
||||
AQH_MESSAGE *outMsg;
|
||||
int resultCode=AQH_MSGDATA_RESULT_SUCCESS;
|
||||
uint32_t msgGrps=0;
|
||||
|
||||
msgGrps=AQH_IpcnMessageSetAcceptedMsgGroups_GetGroups(tagList);
|
||||
AQH_Endpoint_SetAcceptedMsgGroups(ep, msgGrps);
|
||||
outMsg=AQH_IpcMessageResult_new(AQH_IPC_PROTOCOL_NODES_ID,
|
||||
AQH_IPC_PROTOCOL_NODES_VERSION,
|
||||
AQH_MSGTYPE_IPC_NODES_RESULT,
|
||||
AQH_Endpoint_GetNextMessageId(ep),
|
||||
AQH_IpcMessage_GetMsgId(msg),
|
||||
resultCode, NULL);
|
||||
AQH_Endpoint_AddMsgOut(ep, outMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
27
apps/aqhome-nodes/r_setaccmsggrps.h
Normal file
27
apps/aqhome-nodes/r_setaccmsggrps.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2024 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.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQHOMED_R_SETACCMSGGRPS_H
|
||||
#define AQHOMED_R_SETACCMSGGRPS_H
|
||||
|
||||
|
||||
#include "./server.h"
|
||||
|
||||
#include <gwenhywfar/tag16.h>
|
||||
|
||||
|
||||
void AQH_NodeServer_HandleSetAccMsgGrps(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "./devicesread.h"
|
||||
#include "./r_setdata.h"
|
||||
#include "./r_connect.h"
|
||||
#include "./r_forward.h"
|
||||
#include "./r_setaccmsggrps.h"
|
||||
|
||||
#include <aqhome/aqhome.h>
|
||||
#include <aqhome/ipc2/ipc_endpoint.h>
|
||||
@@ -29,6 +31,7 @@
|
||||
#include <aqhome/msg/ipc/m_ipc.h>
|
||||
#include <aqhome/msg/ipc/m_ipc_result.h>
|
||||
#include <aqhome/msg/ipc/m_ipc_connect.h>
|
||||
#include <aqhome/msg/ipc/m_ipc_tag16.h>
|
||||
#include <aqhome/msg/ipc/data/m_ipcd.h>
|
||||
#include <aqhome/msg/ipc/data/m_ipcd_multidata.h>
|
||||
#include <aqhome/msg/ipc/nodes/m_ipcn.h>
|
||||
@@ -594,13 +597,13 @@ int _exchangeConnect(AQH_NODE_SERVER *xo, uint32_t flags)
|
||||
uint32_t msgId;
|
||||
|
||||
msgId=AQH_Endpoint_GetNextMessageId(xo->brokerEndpoint);
|
||||
msgOut=AQH_IpcMessageConnect_new(xo->protoId, xo->protoVer,
|
||||
msgOut=AQH_IpcMessageConnect_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION,
|
||||
AQH_MSGTYPE_IPC_CONNECT_REQ,
|
||||
msgId, 0,
|
||||
xo->brokerClientId, NULL, NULL, flags);
|
||||
AQH_Endpoint_AddMsgOut(xo->brokerEndpoint, msgOut);
|
||||
return AQH_IpcEndpoint_WaitForResultMsg(xo->brokerEndpoint,
|
||||
xo->protoId, xo->protoVer, AQH_MSGTYPE_IPC_RESULT,
|
||||
AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, AQH_MSGTYPE_IPC_RESULT,
|
||||
msgId, xo->timeoutInSeconds);
|
||||
}
|
||||
|
||||
@@ -751,11 +754,19 @@ void _handleMsgFromClient(GWEN_UNUSED AQH_OBJECT *o, GWEN_UNUSED AQH_NODE_SERVER
|
||||
/* exec IPC message */
|
||||
code=AQH_IpcMessage_GetCode(msg);
|
||||
protoId=AQH_IpcMessage_GetProtoId(msg);
|
||||
if (protoId==AQH_IPC_PROTOCOL_DATA_ID) {
|
||||
DBG_ERROR(NULL, "Received IPC packet %d (%x)", (int) code, code);
|
||||
switch(code) {
|
||||
case AQH_MSGTYPE_IPC_DATA_CONNECT_REQ: AQH_NodeServer_HandleConnect(o, ep, msg); break;
|
||||
default: break;
|
||||
if (protoId==AQH_IPC_PROTOCOL_NODES_ID) {
|
||||
GWEN_TAG16_LIST *tagList;
|
||||
|
||||
tagList=AQH_IpcMessageTag16_ParsePayload(msg, 0);
|
||||
if (tagList) {
|
||||
DBG_ERROR(NULL, "Received IPC packet %d (%x)", (int) code, code);
|
||||
switch(code) {
|
||||
case AQH_MSGTYPE_IPC_NODES_CONNECT_REQ: AQH_NodeServer_HandleConnect(o, ep, msg, tagList); break;
|
||||
case AQH_MSGTYPE_IPC_NODES_FORWARD: AQH_NodeServer_HandleForward(o, ep, msg, tagList); break;
|
||||
case AQH_MSGTYPE_IPC_NODES_SETACCMSGGRPS: AQH_NodeServer_HandleSetAccMsgGrps(o, ep, msg, tagList); break;
|
||||
default: break;
|
||||
}
|
||||
GWEN_Tag16_List_free(tagList);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -835,6 +846,7 @@ void _forwardTtyMsgToClients(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg)
|
||||
if (AQH_Endpoint_GetAcceptedMsgGroups(ep) & msgGroup) {
|
||||
AQH_MESSAGE *outMsg;
|
||||
|
||||
DBG_ERROR(NULL, "Forwarding node message %d to client", AQH_NodeMessage_GetMsgType(msg));
|
||||
outMsg=AQH_IpcnMessageForward_new(AQH_MSGTYPE_IPC_NODES_FORWARD,
|
||||
AQH_Endpoint_GetNextMessageId(ep), 0,
|
||||
AQH_Message_GetMsgPointer(msg), AQH_Message_GetUsedSize(msg));
|
||||
|
||||
Reference in New Issue
Block a user