adapted to last changes in gwen.
This commit is contained in:
@@ -47,11 +47,11 @@ static GWEN_MSG_REQUEST *_mkRequest_SetData(AQHOMED *aqh,
|
|||||||
int destAddr, int valueId, uint16_t dataVal, uint16_t dataDenom);
|
int destAddr, int valueId, uint16_t dataVal, uint16_t dataDenom);
|
||||||
|
|
||||||
static void _rqSubRequestFinished(GWEN_MSG_REQUEST *rq, GWEN_MSG_REQUEST *subRq, int reason);
|
static void _rqSubRequestFinished(GWEN_MSG_REQUEST *rq, GWEN_MSG_REQUEST *subRq, int reason);
|
||||||
static void _rqAbort(GWEN_MSG_REQUEST *rq);
|
static void _rqAbort(GWEN_MSG_REQUEST *rq, int reason);
|
||||||
|
|
||||||
static GWEN_MSG_REQUEST *_mkSubRequest_SetData(AQHOMED *aqh, int destAddr, int valueId, uint16_t dataVal, uint16_t dataDenom);
|
static GWEN_MSG_REQUEST *_mkSubRequest_SetData(AQHOMED *aqh, int destAddr, int valueId, uint16_t dataVal, uint16_t dataDenom);
|
||||||
static int _subRqHandleResponse(GWEN_MSG_REQUEST *rq, GWEN_MSG *msg);
|
static int _subRqHandleResponse(GWEN_MSG_REQUEST *rq, GWEN_MSG *msg);
|
||||||
static void _subRqAbort(GWEN_MSG_REQUEST *rq);
|
static void _subRqAbort(GWEN_MSG_REQUEST *rq, int reason);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ void AqHomeNodes_HandleSetData(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, GWEN_MSG *re
|
|||||||
{
|
{
|
||||||
uint32_t msgId;
|
uint32_t msgId;
|
||||||
|
|
||||||
DBG_ERROR(AQH_LOGDOMAIN, "Received IPC SetDataRequest message");
|
DBG_INFO(NULL, "Received IPC SetDataRequest message");
|
||||||
msgId=GWEN_IpcMsg_GetMsgId(recvdMsg);
|
msgId=GWEN_IpcMsg_GetMsgId(recvdMsg);
|
||||||
|
|
||||||
if (aqh->ttyEndpoint && GWEN_MsgEndpoint_GetState(aqh->ttyEndpoint)==GWEN_MSG_ENDPOINT_STATE_CONNECTED) {
|
if (aqh->ttyEndpoint && GWEN_MsgEndpoint_GetState(aqh->ttyEndpoint)==GWEN_MSG_ENDPOINT_STATE_CONNECTED) {
|
||||||
@@ -106,55 +106,55 @@ void AqHomeNodes_HandleSetData(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, GWEN_MSG *re
|
|||||||
int destAddr;
|
int destAddr;
|
||||||
|
|
||||||
destAddr=AQH_NodeInfo_GetBusAddress(nodeInfo);
|
destAddr=AQH_NodeInfo_GetBusAddress(nodeInfo);
|
||||||
DBG_ERROR(NULL, "Creating SETDATA request");
|
DBG_DEBUG(NULL, "Creating SETDATA request");
|
||||||
|
|
||||||
rq=_mkRequest_SetData(aqh, ep, msgId, destAddr, AQHNODE_Value_GetId(devValue), dataVal, dataDenom);
|
rq=_mkRequest_SetData(aqh, ep, msgId, destAddr, AQHNODE_Value_GetId(devValue), dataVal, dataDenom);
|
||||||
AqHomed_AddRequestToTree(aqh, rq);
|
AqHomed_AddRequestToTree(aqh, rq);
|
||||||
/* done */
|
/* done */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DBG_ERROR(AQH_LOGDOMAIN, "Bad data \"%s\"", data);
|
DBG_ERROR(NULL, "Bad data \"%s\"", data);
|
||||||
AQH_IpcEndpoint_SendResponseResult(ep, msgId, AQH_MSGTYPE_IPC_DATA_RESULT, AQH_MSG_IPC_ERROR_BADDATA);
|
AQH_IpcEndpoint_SendResponseResult(ep, msgId, AQH_MSGTYPE_IPC_DATA_RESULT, AQH_MSG_IPC_ERROR_BADDATA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DBG_ERROR(AQH_LOGDOMAIN, "Invalid value name \"%s\"", varName);
|
DBG_ERROR(NULL, "Invalid value name \"%s\"", varName);
|
||||||
AQH_IpcEndpoint_SendResponseResult(ep, msgId, AQH_MSGTYPE_IPC_DATA_RESULT, AQH_MSG_IPC_ERROR_INVALID);
|
AQH_IpcEndpoint_SendResponseResult(ep, msgId, AQH_MSGTYPE_IPC_DATA_RESULT, AQH_MSG_IPC_ERROR_INVALID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DBG_ERROR(AQH_LOGDOMAIN, "Unknown node \"%s\"", devName);
|
DBG_ERROR(NULL, "Unknown node \"%s\"", devName);
|
||||||
AQH_IpcEndpoint_SendResponseResult(ep, msgId, AQH_MSGTYPE_IPC_DATA_RESULT, AQH_MSG_IPC_ERROR_INVALID);
|
AQH_IpcEndpoint_SendResponseResult(ep, msgId, AQH_MSGTYPE_IPC_DATA_RESULT, AQH_MSG_IPC_ERROR_INVALID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DBG_ERROR(AQH_LOGDOMAIN, "Node not yet fully identified, come back later");
|
DBG_ERROR(NULL, "Node not yet fully identified, come back later");
|
||||||
AQH_IpcEndpoint_SendResponseResult(ep, msgId, AQH_MSGTYPE_IPC_DATA_RESULT, AQH_MSG_IPC_ERROR_TRYAGAIN);
|
AQH_IpcEndpoint_SendResponseResult(ep, msgId, AQH_MSGTYPE_IPC_DATA_RESULT, AQH_MSG_IPC_ERROR_TRYAGAIN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DBG_ERROR(AQH_LOGDOMAIN, "No matching nodeinfo");
|
DBG_ERROR(NULL, "No matching nodeinfo");
|
||||||
AQH_IpcEndpoint_SendResponseResult(ep, msgId, AQH_MSGTYPE_IPC_DATA_RESULT, AQH_MSG_IPC_ERROR_INVALID);
|
AQH_IpcEndpoint_SendResponseResult(ep, msgId, AQH_MSGTYPE_IPC_DATA_RESULT, AQH_MSG_IPC_ERROR_INVALID);
|
||||||
}
|
}
|
||||||
free(data);
|
free(data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DBG_ERROR(AQH_LOGDOMAIN, "No data");
|
DBG_ERROR(NULL, "No data");
|
||||||
AQH_IpcEndpoint_SendResponseResult(ep, msgId, AQH_MSGTYPE_IPC_DATA_RESULT, AQH_MSG_IPC_ERROR_NODATA);
|
AQH_IpcEndpoint_SendResponseResult(ep, msgId, AQH_MSGTYPE_IPC_DATA_RESULT, AQH_MSG_IPC_ERROR_NODATA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DBG_ERROR(AQH_LOGDOMAIN, "No var name");
|
DBG_ERROR(NULL, "No var name");
|
||||||
AQH_IpcEndpoint_SendResponseResult(ep, msgId, AQH_MSGTYPE_IPC_DATA_RESULT, AQH_MSG_IPC_ERROR_NODATA);
|
AQH_IpcEndpoint_SendResponseResult(ep, msgId, AQH_MSGTYPE_IPC_DATA_RESULT, AQH_MSG_IPC_ERROR_NODATA);
|
||||||
}
|
}
|
||||||
AQH_Value_free(value);
|
AQH_Value_free(value);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DBG_ERROR(AQH_LOGDOMAIN, "Could not read value from message");
|
DBG_ERROR(NULL, "Could not read value from message");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DBG_ERROR(AQH_LOGDOMAIN, "TTY endpoint not connected");
|
DBG_ERROR(NULL, "TTY endpoint not connected");
|
||||||
AQH_IpcEndpoint_SendResponseResult(ep, msgId, AQH_MSGTYPE_IPC_DATA_RESULT, AQH_MSG_IPC_ERROR_IO);
|
AQH_IpcEndpoint_SendResponseResult(ep, msgId, AQH_MSGTYPE_IPC_DATA_RESULT, AQH_MSG_IPC_ERROR_IO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -195,7 +195,7 @@ void _rqSubRequestFinished(GWEN_MSG_REQUEST *rq, GWEN_MSG_REQUEST *subRq, int re
|
|||||||
uint32_t refMsgId;
|
uint32_t refMsgId;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
DBG_ERROR(NULL, "SubRequest finished (reason: %d)", reason);
|
DBG_INFO(NULL, "SubRequest finished (reason: %d)", reason);
|
||||||
refMsgId=GWEN_MsgRequest_GetRequestMsgId(rq);
|
refMsgId=GWEN_MsgRequest_GetRequestMsgId(rq);
|
||||||
ep=GWEN_MsgRequest_GetEndpoint(rq);
|
ep=GWEN_MsgRequest_GetEndpoint(rq);
|
||||||
result=GWEN_MsgRequest_GetResult(subRq);
|
result=GWEN_MsgRequest_GetResult(subRq);
|
||||||
@@ -211,7 +211,7 @@ void _rqSubRequestFinished(GWEN_MSG_REQUEST *rq, GWEN_MSG_REQUEST *subRq, int re
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void _rqAbort(GWEN_MSG_REQUEST *rq)
|
void _rqAbort(GWEN_MSG_REQUEST *rq, int reason)
|
||||||
{
|
{
|
||||||
GWEN_MSG_ENDPOINT *ep;
|
GWEN_MSG_ENDPOINT *ep;
|
||||||
uint32_t refMsgId;
|
uint32_t refMsgId;
|
||||||
@@ -225,7 +225,7 @@ void _rqAbort(GWEN_MSG_REQUEST *rq)
|
|||||||
|
|
||||||
rqParent=GWEN_MsgRequest_Tree2_GetParent(rq);
|
rqParent=GWEN_MsgRequest_Tree2_GetParent(rq);
|
||||||
if (rqParent)
|
if (rqParent)
|
||||||
GWEN_MsgRequest_SubRequestFinished(rqParent, rq, GWEN_MSG_REQUEST_REASON_ABORTED);
|
GWEN_MsgRequest_SubRequestFinished(rqParent, rq, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -268,7 +268,7 @@ int _subRqHandleResponse(GWEN_MSG_REQUEST *rq, GWEN_MSG *msg)
|
|||||||
AQHOMED *aqh;
|
AQHOMED *aqh;
|
||||||
uint8_t destAddr;
|
uint8_t destAddr;
|
||||||
|
|
||||||
DBG_ERROR(NULL, "Checking message from %02x", AQH_NodeMsg_GetSourceAddress(msg));
|
DBG_DEBUG(NULL, "Checking message from %02x", AQH_NodeMsg_GetSourceAddress(msg));
|
||||||
aqh=(AQHOMED*)GWEN_MsgRequest_GetPrivateData(rq);
|
aqh=(AQHOMED*)GWEN_MsgRequest_GetPrivateData(rq);
|
||||||
|
|
||||||
destAddr=AQH_NodeMsg_GetDestAddress(msg);
|
destAddr=AQH_NodeMsg_GetDestAddress(msg);
|
||||||
@@ -283,9 +283,9 @@ int _subRqHandleResponse(GWEN_MSG_REQUEST *rq, GWEN_MSG *msg)
|
|||||||
if (msgId==GWEN_MsgRequest_GetRequestMsgId(rq)) {
|
if (msgId==GWEN_MsgRequest_GetRequestMsgId(rq)) {
|
||||||
GWEN_MSG_REQUEST *rqParent;
|
GWEN_MSG_REQUEST *rqParent;
|
||||||
|
|
||||||
DBG_ERROR(NULL,
|
DBG_INFO(NULL,
|
||||||
"Received response (%02x) for msg id %04x from %02x",
|
"Received response (%02x) for msg id %04x from %02x",
|
||||||
msgCode, msgId, AQH_NodeMsg_GetSourceAddress(msg));
|
msgCode, msgId, AQH_NodeMsg_GetSourceAddress(msg));
|
||||||
GWEN_MsgRequest_SetResult(rq, (msgCode==AQH_MSG_TYPE_VALUE_SET_ACK)?AQH_MSG_IPC_SUCCESS:AQH_MSG_IPC_ERROR_GENERIC);
|
GWEN_MsgRequest_SetResult(rq, (msgCode==AQH_MSG_TYPE_VALUE_SET_ACK)?AQH_MSG_IPC_SUCCESS:AQH_MSG_IPC_ERROR_GENERIC);
|
||||||
GWEN_MsgRequest_SetState(rq, GWEN_MSG_REQUEST_STATE_DONE);
|
GWEN_MsgRequest_SetState(rq, GWEN_MSG_REQUEST_STATE_DONE);
|
||||||
rqParent=GWEN_MsgRequest_Tree2_GetParent(rq);
|
rqParent=GWEN_MsgRequest_Tree2_GetParent(rq);
|
||||||
@@ -294,11 +294,11 @@ int _subRqHandleResponse(GWEN_MSG_REQUEST *rq, GWEN_MSG *msg)
|
|||||||
return GWEN_MSG_REQUEST_RESULT_HANDLED;
|
return GWEN_MSG_REQUEST_RESULT_HANDLED;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DBG_ERROR(NULL, " Non-matching message id");
|
DBG_INFO(NULL, " Non-matching message id");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DBG_ERROR(NULL, " Non-matching message code");
|
DBG_INFO(NULL, " Non-matching message code");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return GWEN_MSG_REQUEST_RESULT_NOT_HANDLED;
|
return GWEN_MSG_REQUEST_RESULT_NOT_HANDLED;
|
||||||
@@ -306,18 +306,18 @@ int _subRqHandleResponse(GWEN_MSG_REQUEST *rq, GWEN_MSG *msg)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void _subRqAbort(GWEN_MSG_REQUEST *rq)
|
void _subRqAbort(GWEN_MSG_REQUEST *rq, int reason)
|
||||||
{
|
{
|
||||||
GWEN_MSG_REQUEST *rqParent;
|
GWEN_MSG_REQUEST *rqParent;
|
||||||
|
|
||||||
DBG_ERROR(NULL, "Aborting request");
|
DBG_INFO(NULL, "Aborting request");
|
||||||
|
|
||||||
GWEN_MsgRequest_SetResult(rq, AQH_MSG_IPC_ERROR_GENERIC);
|
GWEN_MsgRequest_SetResult(rq, AQH_MSG_IPC_ERROR_GENERIC);
|
||||||
GWEN_MsgRequest_SetState(rq, GWEN_MSG_REQUEST_STATE_DONE);
|
GWEN_MsgRequest_SetState(rq, GWEN_MSG_REQUEST_STATE_DONE);
|
||||||
|
|
||||||
rqParent=GWEN_MsgRequest_Tree2_GetParent(rq);
|
rqParent=GWEN_MsgRequest_Tree2_GetParent(rq);
|
||||||
if (rqParent)
|
if (rqParent)
|
||||||
GWEN_MsgRequest_SubRequestFinished(rqParent, rq, GWEN_MSG_REQUEST_REASON_ABORTED);
|
GWEN_MsgRequest_SubRequestFinished(rqParent, rq, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -333,7 +333,7 @@ AQH_NODE_INFO *_getNodeInfoFromValue(AQHOMED *aqh, const AQH_VALUE *value)
|
|||||||
|
|
||||||
ni=AQH_NodeDb_GetNodeInfoByUid(aqh->nodeDb, uid);
|
ni=AQH_NodeDb_GetNodeInfoByUid(aqh->nodeDb, uid);
|
||||||
if (ni==NULL) {
|
if (ni==NULL) {
|
||||||
DBG_INFO(AQH_LOGDOMAIN, "Node \"%08lx\" not found", uid);
|
DBG_ERROR(NULL, "Node \"%08lx\" not found", uid);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return ni;
|
return ni;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "./requests.h"
|
#include "./requests.h"
|
||||||
|
|
||||||
#include <gwenhywfar/debug.h>
|
#include <gwenhywfar/debug.h>
|
||||||
|
#include <gwenhywfar/msg_ipc.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -42,7 +43,7 @@ void AQH_Requests_CheckTimeouts(GWEN_MSG_REQUEST *requestTreeRoot)
|
|||||||
if (GWEN_Timestamp_Compare(now, ts)>=0) {
|
if (GWEN_Timestamp_Compare(now, ts)>=0) {
|
||||||
/* timeout */
|
/* timeout */
|
||||||
DBG_INFO(NULL, "Request timed out, aborting");
|
DBG_INFO(NULL, "Request timed out, aborting");
|
||||||
GWEN_MsgRequest_Abort(rq);
|
GWEN_MsgRequest_Abort(rq, GWEN_MSG_REQUEST_REASON_TIMEOUT);
|
||||||
}
|
}
|
||||||
rq=GWEN_MsgRequest_Tree2_GetBelow(rq);
|
rq=GWEN_MsgRequest_Tree2_GetBelow(rq);
|
||||||
}
|
}
|
||||||
@@ -132,7 +133,7 @@ void _freeFinishedRequests(GWEN_MSG_REQUEST *rq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (GWEN_MsgRequest_GetState(rq)==GWEN_MSG_REQUEST_STATE_DONE) {
|
if (GWEN_MsgRequest_GetState(rq)==GWEN_MSG_REQUEST_STATE_DONE) {
|
||||||
DBG_ERROR(NULL, "Deleting request");
|
DBG_INFO(NULL, "Deleting request");
|
||||||
GWEN_MsgRequest_free(rq);
|
GWEN_MsgRequest_free(rq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user