/* Serializes a 0-length packet into the supplied buffer, ready for writing to a socket  */
int MQTTSerialize_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 MQTTSerialize_zero(unsigned char *buf, int buflen, unsigned char packettype)
{
    MQTTHeader 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;
    writeChar(&ptr, header.byte);
    ptr += MQTTPacket_encode(ptr, 0);
    rc = ptr - buf;
exit:
    FUNC_EXIT_RC(rc);
    return rc;
}