/* Serializes a 0-length packet into the supplied buffer, ready for writing to a socket  */
int mqtt_serialize_zero(unsigned char *buf, int buflen, unsigned char packettype)
/* Serializes a 0-length packet into the supplied buffer, ready for writing to a socket  */
int mqtt_serialize_zero(unsigned char *buf, int buflen, unsigned char packettype)
{
	mqtt_header_t header = {0};
	int rc = -1;
	unsigned char *ptr = buf;
	FUNC_ENTRY;
	if (buflen < 2)
	{
		rc = MQTTPACKET_BUFFER_TOO_SHORT;
		goto exit;
	}
	header.byte = 0;
	header.bits.type = packettype;
	mqtt_write_char(&ptr, header.byte);
	ptr += mqtt_packet_encode(ptr, 0);
	rc = ptr - buf;
exit:
	FUNC_EXIT_RC(rc);
	return rc;
}