/****************************************************************************
 * This file is part of the project AqHome.
 * AqHome (c) by 2025 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 SERVER_P_H
#define SERVER_P_H


#include "./server.h"
#include "aqhome-nodes/types/device.h"

#include "aqhome/ipc2/msgrequest.h"

#include <termios.h>


/* default values */
#define AQHOME_MQTT_DEFAULT_PIDFILE           "/var/run/aqhome-mqtt.pid"
#define AQHOME_MQTT_DEFAULT_DATADIR           "/var/lib/aqhome-mqtt"
#define AQHOME_MQTT_DEFAULT_DEVICEFILE        "mqttlog/registereddevices.xml"

#define AQHOME_MQTT_DEFAULT_BROKER_PORT       1899
#define AQHOME_MQTT_DEFAULT_BROKER_CLIENTID   "mqtt"



typedef struct AQH_MQTTLOG_SERVER AQH_MQTTLOG_SERVER;
struct AQH_MQTTLOG_SERVER {
  AQH_OBJECT *mqttEndpoint;
  AQH_OBJECT *brokerEndpoint;

  GWEN_DB_NODE *dbArgs;

  AQHMQTT_DEVICE_LIST *availableDeviceList;
  AQHMQTT_DEVICE_LIST *registeredDeviceList;

  char *deviceFile;
  char *pidFile;

  int timeout;   /* timeout for run e.g. inside valgrind */

  char *mqttAddress;
  int mqttPort;
  char *mqttClientId;
  int mqttKeepAlive;

  char *brokerAddress;
  int brokerPort;
  char *brokerClientId;

  time_t timestampMqttDown;
  time_t timestampBrokerDown;

  int timeoutInSeconds;

};


AQH_MQTTLOG_SERVER *AQH_MqttLogServer_GetServerData(const AQH_OBJECT *o);


#endif

