/****************************************************************************
 * This file is part of the project AqHome.
 * AqHome (c) by 2023 Martin Preuss, all rights reserved.
 *
 * The license for this file can be found in the file COPYING which you
 * should have received along with this file.
 ****************************************************************************/

#ifndef AQH_MSG_MQTT_CONNACK_H
#define AQH_MSG_MQTT_CONNACK_H


#include <aqhome/api.h>
#include <aqhome/mqtt/msg_mqtt.h>

#include <gwenhywfar/msg.h>
#include <gwenhywfar/buffer.h>



#define AQH_MQTTMSG_CONNACK_FLAGS_HAVE_SESSION     0x01u

#define AQH_MQTTMSG_CONNACK_RESULT_ACCEPTED        0x00u
#define AQH_MQTTMSG_CONNACK_RESULT_BAD_PROTO       0x01u
#define AQH_MQTTMSG_CONNACK_RESULT_BAD_CLIENTID    0x02u
#define AQH_MQTTMSG_CONNACK_RESULT_UNAVAILABLE     0x03u
#define AQH_MQTTMSG_CONNACK_RESULT_BAD_CREDENTIALS 0x04u
#define AQH_MQTTMSG_CONNACK_RESULT_UNAUTHORIZED    0x05u





AQHOME_API GWEN_MSG *GWEN_ConnAckMqttMsg_new(uint8_t flags, uint8_t result);

AQHOME_API int AQH_ConnAckMqttMsg_GetResultFlags(const GWEN_MSG *msg);
AQHOME_API int AQH_ConnAckMqttMsg_GetResultCode(const GWEN_MSG *msg);

AQHOME_API void AQH_ConnAckMqttMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);




#endif
