Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
tomoaki
2018-08-15 07:11:43 +09:00
parent 42886b70f0
commit ee15a21ff3
2 changed files with 18 additions and 0 deletions

View File

@@ -274,4 +274,20 @@ exit:
return rc;
}
int MQTTSNPacket_read_nb(unsigned char* buf, int buflen)
{
int rc = MQTTSNPACKET_READ_ERROR;
int len = buflen; /* the length of the whole packet including length field */
int lenlen = 0;
int datalen = 0;
/* 2. read the length. This is variable in itself */
lenlen = MQTTSNPacket_decode(buf, len, &datalen);
if (datalen != len)
goto exit; /* there was an error */
rc = buf[lenlen]; /* return the packet type */
exit:
return rc;
}