/****************************************************************************
 * 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_CONNECT_H
#define AQH_MSG_MQTT_CONNECT_H


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

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



#define AQH_MQTTMSG_CONNECT_FLAGS_USERNAME      0x80u
#define AQH_MQTTMSG_CONNECT_FLAGS_PASSWD        0x40u
#define AQH_MQTTMSG_CONNECT_FLAGS_WILL_RETAIN   0x20u
#define AQH_MQTTMSG_CONNECT_FLAGS_WILL_QOS2     0x10u
#define AQH_MQTTMSG_CONNECT_FLAGS_WILL_QOS1     0x08u
#define AQH_MQTTMSG_CONNECT_FLAGS_WILL_FLAG     0x04u
#define AQH_MQTTMSG_CONNECT_FLAGS_CLEAN_SESSION 0x01u




/**
 * order in payload:
 * - client id
 * - will topic
 * - will message
 * - user name
 * - password
 */
AQHOME_API GWEN_MSG *GWEN_ConnectMqttMsg_new(const char *protoName,  /* "MQTT" */
                                             uint8_t protoLevel,     /* 0x04 for MQTT 3.1.1 */
                                             uint8_t connectFlags,
                                             uint16_t keepAliveTime,
                                             const char *clientId,
                                             const char *userName,
                                             const char *password);

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




#endif
