
#ifndef DomoEspManagerDef
#define DomoEspManagerDef 1

//#include <ESP8266WiFi.h>//este para esp8266
//#include <PubSubClient.h>
#include <SPI.h>
#include <LiquidCrystal.h>
/*
#include <SimpleDHT.h>
#include <Wire.h>
#include <Adafruit_BMP085.h>
*/
#include "MqttVarManager.h"
#include "MqttUtiles.h"
#include "MqttSensManager.h"
#include "MqttDesencadenadorManager.h"
#include "LcdMQTTViewer.h"

#if CON_LCD
//configuracion del lcd--------------------------
#include <LiquidCrystal.h>


#include "LcdMQTTViewer.h"

#endif


class PubSubClient;
class WiFiClient;
class MqttSensManager;
/*
 * clase principal
 */
class DomoLcdConfig
{
  public:
  //pines
   byte rs;
   byte en;//eneable
   byte d0;
   byte d1;
   byte d2;
   byte d3;

   byte colum;
   byte lines;
};

class DomoConfig
{
  public:
   DomoLcdConfig lcd;
  
  
  
  char ssidWifi[32];
  char keyWifi[32];
  char ideEsp[32];//identificador unico por esp
  char hostMQTT[16];
  int portMQTT;

  int velocidadPortSerie;
  int refresTimeVars;//tiempo de refresco en segundos de las variables
  
  int refresTimeSens;//tiempo de refresco en segundos de los sensores
  
  virtual void ConfigGen(MqttSensManager* sens, MqttVarManager* vars, LcdMQTTViewer *lcd, MqttDesencadenadorManager *des)=0;

  
};
//TODO falta funcion en configuracion para añadir sensores y variables
class DomoEspManager: public MqttReceiver
{
  public:


  
  //variables-------------
  //MqttVarArray avar;
  //MqttTopicAttay topics;

  MqttVarManager vars;
  MqttSensManager sens;

  WifiManager wifi;
  MqttManager mqtt;

 MqttDesencadenadorManager des;
 LcdMQTTViewer lcdm;
  bool suscrito;
  
  //PubSubClient client_qqtt(WifiManager::espClient);
  DomoEspManager();
  //PubSubClient client_qqtt(espClient);
  void inicia( LiquidCrystal *lcd,PubSubClient *mqttClient, WiFiClient* espClient, DomoConfig* conf);
  void loop();
  
  //funciones auxiliares
  virtual void OnMqtt(char* topic, char* payload);
  virtual void SubscribeMqtt(PubSubClient *client_mqtt);
  
};
#endif
