aqhome: fixed mqtt message handling

PUBLISH: the message itself is NOT preceeded by size
This commit is contained in:
Martin Preuss
2023-05-24 23:07:45 +02:00
parent 1751170940
commit f0917064af
5 changed files with 152 additions and 12 deletions

View File

@@ -474,6 +474,7 @@ int _calcAndSetPayloadSizeAndOffset(GWEN_MSG *msg)
if (remainingBytesInBuffer>1) {
const uint8_t *ptr;
int idx;
int shift=0;
ptr=GWEN_Msg_GetConstBuffer(msg);
idx=1;
@@ -482,8 +483,7 @@ int _calcAndSetPayloadSizeAndOffset(GWEN_MSG *msg)
uint8_t len;
len=ptr[idx];
mqttRemainingLength<<=8;
mqttRemainingLength+=(len & 0x7f);
mqttRemainingLength+=(len & 0x7f)<<shift;
if (!(len & 0x80)) {
/* last byte of size */
GWEN_Msg_SetParsedPayloadSize(msg, mqttRemainingLength);
@@ -491,6 +491,9 @@ int _calcAndSetPayloadSizeAndOffset(GWEN_MSG *msg)
GWEN_Msg_AddFlags(msg, GWEN_MSG_FLAGS_PAYLOADINFO_SET);
return 1; /* size successfully determined */
}
shift+=7;
idx++;
remainingBytesInBuffer--;
}
}
return 0;