aqhome: added service definitions, started implementing HTTP service.

This commit is contained in:
Martin Preuss
2023-07-24 21:49:17 +02:00
parent db5d6cb980
commit 16ce958964
33 changed files with 2346 additions and 7 deletions

View File

@@ -395,7 +395,8 @@ int _distributeBufferInHeaderMode(GWEN_MSG_ENDPOINT *ep, const uint8_t *bufferPt
}
else {
xep->currentBodyPos=GWEN_Buffer_GetPos(xep->currentReadBuffer);
xep->currentBodySize=contentLength;
xep->currentBodySize=contentLength;
xep->remainingBodySize=contentLength;
xep->readMode=AQH_EndpointHttpd_ReadMode_Body;
}
}
@@ -411,16 +412,16 @@ int _distributeBufferInBodyMode(GWEN_MSG_ENDPOINT *ep, const uint8_t *bufferPtr,
AQH_ENDPOINT_HTTP *xep;
xep=GWEN_INHERIT_GETDATA(GWEN_MSG_ENDPOINT, AQH_ENDPOINT_HTTP, ep);
if (xep->currentBodySize>0) {
if (xep->remainingBodySize>0) {
int len;
len=bufferLen;
if (len>xep->currentBodySize)
len=xep->currentBodySize;
if (len>xep->remainingBodySize)
len=xep->remainingBodySize;
if (len) {
GWEN_Buffer_AppendBytes(xep->currentReadBuffer, (const char*) bufferPtr, len);
xep->currentBodySize-=len;
if (xep->currentBodySize==0) {
xep->remainingBodySize-=len;
if (xep->remainingBodySize==0) {
DBG_INFO(AQH_LOGDOMAIN, "Body completely received");
_finishMessageAndStartNext(ep);
}
@@ -475,6 +476,10 @@ void _finishMessageAndStartNext(GWEN_MSG_ENDPOINT *ep)
xep=GWEN_INHERIT_GETDATA(GWEN_MSG_ENDPOINT, AQH_ENDPOINT_HTTP, ep);
msg=GWEN_Msg_fromBytes((const uint8_t*)GWEN_Buffer_GetStart(xep->currentReadBuffer), GWEN_Buffer_GetUsedBytes(xep->currentReadBuffer));
if (xep->currentBodySize) {
GWEN_Msg_SetParsedPayloadOffset(msg, xep->currentBodyPos);
GWEN_Msg_SetParsedPayloadSize(msg, xep->currentBodySize);
}
dbParsedData=GWEN_DB_Group_new("parsedData");
if (xep->dbCurrentReadCommand)
GWEN_DB_AddGroup(dbParsedData, xep->dbCurrentReadCommand);
@@ -488,6 +493,7 @@ void _finishMessageAndStartNext(GWEN_MSG_ENDPOINT *ep)
xep->currentHeaderPos=0;
xep->currentBodyPos=0;
xep->currentBodySize=0;
xep->remainingBodySize=0;
xep->lastLineStartPos=0;
xep->dbCurrentReadCommand=NULL;
xep->dbCurrentReadHeader=NULL;
@@ -511,6 +517,7 @@ void _abortMessage(GWEN_MSG_ENDPOINT *ep)
xep->currentHeaderPos=0;
xep->currentBodyPos=0;
xep->currentBodySize=0;
xep->remainingBodySize=0;
xep->lastLineStartPos=0;
if (xep->dbCurrentReadCommand)
GWEN_DB_Group_free(xep->dbCurrentReadCommand);