aqhome: adapted server aqhome-mqttlog to events2 api.
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
|
||||
#define AQH_MSGREADER_SKIPTIME_IN_MS 20
|
||||
|
||||
#define AQH_MSGREADER_FLAGS_SKIP 0x0001
|
||||
#define AQH_MSGREADER_FLAGS_SKIP 0x80000000
|
||||
|
||||
|
||||
|
||||
@@ -109,8 +109,10 @@ void AQH_MsgReader_SetFlags(AQH_OBJECT *o, uint32_t f)
|
||||
AQH_MSG_READER *xo;
|
||||
|
||||
xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_MSG_READER, o);
|
||||
if (xo)
|
||||
if (xo) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Set flags: %08x", f);
|
||||
xo->flags=f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,8 +122,10 @@ void AQH_MsgReader_AddFlags(AQH_OBJECT *o, uint32_t f)
|
||||
AQH_MSG_READER *xo;
|
||||
|
||||
xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_MSG_READER, o);
|
||||
if (xo)
|
||||
if (xo) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Adding flags: %08x", f);
|
||||
xo->flags|=f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -131,8 +135,10 @@ void AQH_MsgReader_SubFlags(AQH_OBJECT *o, uint32_t f)
|
||||
AQH_MSG_READER *xo;
|
||||
|
||||
xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_MSG_READER, o);
|
||||
if (xo)
|
||||
if (xo) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Clearing flags: %08x", f);
|
||||
xo->flags&=~f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -339,35 +345,45 @@ int AQH_MsgReader_ReadRemainderFromRingbuffer(AQH_OBJECT *o)
|
||||
|
||||
xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_MSG_READER, o);
|
||||
if (xo) {
|
||||
uint32_t bytesInRingBuffer;
|
||||
uint32_t bytesToRead;
|
||||
int rv;
|
||||
if (xo->bytesLeft==0) {
|
||||
/* msg finished */
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Message complete");
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
uint32_t bytesInRingBuffer;
|
||||
uint32_t bytesToRead;
|
||||
int rv;
|
||||
|
||||
bytesInRingBuffer=GWEN_RingBuffer_GetUsedBytes(xo->ringBuffer);
|
||||
|
||||
/* still reading header */
|
||||
bytesToRead=xo->bytesLeft;
|
||||
if (bytesInRingBuffer<bytesToRead)
|
||||
bytesToRead=bytesInRingBuffer;
|
||||
if (bytesToRead) {
|
||||
uint32_t xferSize;
|
||||
|
||||
xferSize=bytesToRead;
|
||||
rv=GWEN_RingBuffer_ReadBytes(xo->ringBuffer, (char*) (xo->currentMsgBuf+xo->bytesReceived), &xferSize);
|
||||
if (rv<0) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Ringbuffer empty");
|
||||
return 0;
|
||||
bytesInRingBuffer=GWEN_RingBuffer_GetUsedBytes(xo->ringBuffer);
|
||||
|
||||
/* still reading header */
|
||||
bytesToRead=xo->bytesLeft;
|
||||
if (bytesInRingBuffer<bytesToRead)
|
||||
bytesToRead=bytesInRingBuffer;
|
||||
if (bytesToRead) {
|
||||
uint32_t xferSize;
|
||||
|
||||
xferSize=bytesToRead;
|
||||
rv=GWEN_RingBuffer_ReadBytes(xo->ringBuffer, (char*) (xo->currentMsgBuf+xo->bytesReceived), &xferSize);
|
||||
if (rv<0) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Ringbuffer empty");
|
||||
return 0;
|
||||
}
|
||||
if (xferSize<bytesToRead) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Read fewer bytes than available?");
|
||||
return GWEN_ERROR_GENERIC;
|
||||
}
|
||||
xo->bytesReceived+=xferSize;
|
||||
xo->bytesLeft-=xferSize;
|
||||
if (xo->bytesLeft==0) {
|
||||
/* msg finished */
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Message complete");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (xferSize<bytesToRead) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Read fewer bytes than available?");
|
||||
return GWEN_ERROR_GENERIC;
|
||||
}
|
||||
xo->bytesReceived+=xferSize;
|
||||
xo->bytesLeft-=xferSize;
|
||||
if (xo->bytesLeft==0) {
|
||||
/* msg finished */
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Message complete");
|
||||
return 1;
|
||||
else {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Nothing to read??");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user