Compare commits
3 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
0497ba436d | |
|
|
7555635e51 | |
|
|
89869031c8 |
|
|
@ -31,14 +31,14 @@ class Actuador: public DomoEspSensorReceiver
|
|||
activador[i].sen=NULL;
|
||||
}
|
||||
}
|
||||
void set(char* topic_id, char* topic_id_out, char* _valSend)
|
||||
void set(const char* topic_id, const char* topic_id_out, const char* _valSend)
|
||||
{
|
||||
val=0;
|
||||
strcpy(valSend, _valSend);
|
||||
strcpy(topic, topic_id);
|
||||
strcpy(topicOut, topic_id_out);
|
||||
}
|
||||
void setId(char* st)
|
||||
void setId(const char* st)
|
||||
{
|
||||
strcpy(id, st);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class AutomatismoPulsador//automatismo para encender luz con interruptor o pulsa
|
|||
{
|
||||
inicia(man, tp_pul->topic, tpOut->topic, bloqueo);
|
||||
}
|
||||
void inicia(ISensorManager* man, char* tp_pul, char* tpOut, DomoEspSensorReceiver* bloqueo=NULL )
|
||||
void inicia(ISensorManager* man, const char* tp_pul, const char* tpOut, DomoEspSensorReceiver* bloqueo=NULL )
|
||||
{
|
||||
pulsador.set(tp_pul, tpOut, "X");
|
||||
pulsador.setId("Pulsa");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,78 @@
|
|||
#ifndef DomoEspApiConexionDef
|
||||
#define DomoEspApiConexionDef 1
|
||||
#include "defines.h"
|
||||
#ifdef ESP8266
|
||||
#include <ESP8266HTTPClient.h>
|
||||
//sensor Replica, sensor interno que se setea con get y no se publica
|
||||
class DomoEspApiConexion //hay que arreglar compatibilidad con esp32
|
||||
{
|
||||
public:
|
||||
DomoEspApiConexion()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool send(char *topic, char*payload)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool getDataPendiente(char * idArduino, char *topic, char *payloadOut)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool sendPost(char * buff, char* srv, char* datos)
|
||||
{
|
||||
HTTPClient http;
|
||||
WiFiClient client;
|
||||
int httpCode =-1;
|
||||
if(buff)
|
||||
*buff=0;
|
||||
if(http.begin(client, srv))
|
||||
{
|
||||
http.addHeader("Content-Type", "application/json"); // O el tipo de contenido adecuado
|
||||
//String httpRequestData = "{\"dato1\":\"valor1\", \"dato2\":\"valor2\"}"; // Datos en formato JSON
|
||||
httpCode = http.POST(datos);
|
||||
|
||||
if (httpCode > 0) {
|
||||
String payload = http.getString();
|
||||
if(buff)
|
||||
strcpy( buff, payload.c_str());
|
||||
|
||||
}
|
||||
http.end();
|
||||
}
|
||||
return httpCode==200;
|
||||
}
|
||||
bool sendGet(char * buff, char* srv, char* datos)
|
||||
{
|
||||
HTTPClient http;
|
||||
WiFiClient client;
|
||||
int httpCode =-1;
|
||||
if(buff)
|
||||
*buff=0;
|
||||
if(http.begin(client, srv))
|
||||
{
|
||||
http.addHeader("Content-Type", "application/json"); // O el tipo de contenido adecuado
|
||||
//String httpRequestData = "{\"dato1\":\"valor1\", \"dato2\":\"valor2\"}"; // Datos en formato JSON
|
||||
if(datos)
|
||||
httpCode = http.sendRequest("GET",datos);
|
||||
else
|
||||
httpCode = http.GET();
|
||||
|
||||
|
||||
if (httpCode == HTTP_CODE_OK ) {
|
||||
String payload = http.getString();
|
||||
if(buff)
|
||||
strcpy( buff, payload.c_str());
|
||||
|
||||
}
|
||||
http.end();
|
||||
}
|
||||
return httpCode==200;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -9,7 +9,9 @@ class DomoEspConfig
|
|||
char ssidWifi[24];//nombre wifi al que conectar
|
||||
char keyWifi[32];//key wifi a conectar
|
||||
char ideEsp[32];//identificador unico por esp
|
||||
char hostMQTT[16];
|
||||
char hostMQTT[32];//ip o url al host
|
||||
char keyhost[32];//key para conectar al host
|
||||
bool conexionPorApi;
|
||||
int portMQTT;
|
||||
|
||||
int velocidadPortSerie;
|
||||
|
|
@ -19,6 +21,8 @@ class DomoEspConfig
|
|||
|
||||
DomoEspConfig()
|
||||
{
|
||||
conexionPorApi=false;
|
||||
keyhost[0]=0;
|
||||
velocidadPortSerie=115200;
|
||||
strcpy(ssidWifi,"Idhun");//nombre wifi
|
||||
strcpy(keyWifi,"Ardileorca1234.");//key wifi
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
#include "DomoEspSensorManager.h"
|
||||
#include "configuracionActual.h"
|
||||
DomoEspManager manager;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ DomoEspManager::DomoEspManager()
|
|||
tiempo=0;
|
||||
suscrito=false;
|
||||
SetTimeRefres(15);
|
||||
tNoConexion.set(300);
|
||||
tNomqtt.set(300);
|
||||
}
|
||||
void DomoEspManager::SetTimeRefres(int seg)
|
||||
{
|
||||
|
|
@ -20,7 +22,7 @@ void DomoEspManager::inicia(DomoEspConfig* cnf)
|
|||
conf=cnf;
|
||||
#ifdef DEBUG_PS
|
||||
Serial.begin(conf->velocidadPortSerie);
|
||||
delay(100);
|
||||
delay(1000);
|
||||
Serial.println("");
|
||||
Serial.println("Iniciando");
|
||||
#endif
|
||||
|
|
@ -31,7 +33,14 @@ void DomoEspManager::inicia(DomoEspConfig* cnf)
|
|||
#ifdef DEBUG_PS
|
||||
Serial.println("Inicia Mqtt");
|
||||
#endif
|
||||
mqtt.inicia(&clienteMqtt,conf->ideEsp, conf->hostMQTT, conf->portMQTT, this);
|
||||
if(conf->conexionPorApi)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
mqtt.inicia(&clienteMqtt,conf->ideEsp, conf->hostMQTT, conf->portMQTT, this);
|
||||
//loguea------------
|
||||
MqttSend("casa/log", conf->ideEsp);
|
||||
|
||||
#ifdef DEBUG_PS
|
||||
Serial.println("Configura Sensores");
|
||||
|
|
@ -49,17 +58,43 @@ void DomoEspManager::inicia(DomoEspConfig* cnf)
|
|||
void DomoEspManager::loop()
|
||||
{
|
||||
if(!wifi.loop())
|
||||
{
|
||||
{
|
||||
suscrito=false;
|
||||
return;
|
||||
}
|
||||
|
||||
if(!wifi.conecta())
|
||||
{
|
||||
if(tNoConexion.onTimer())
|
||||
{
|
||||
#if defined(ESP8266)
|
||||
ESP.reset();
|
||||
#elif defined(ESP32) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ESP32C3)
|
||||
ESP.restart();
|
||||
#else
|
||||
#error "Placa no soportada"
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
tNoConexion.inicia();
|
||||
if(!mqtt.loop())
|
||||
{
|
||||
suscrito=false;
|
||||
return;
|
||||
if(tNomqtt.onTimer())
|
||||
{
|
||||
#if defined(ESP8266)
|
||||
ESP.reset();
|
||||
#elif defined(ESP32) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ESP32C3)
|
||||
ESP.restart();
|
||||
#else
|
||||
#error "Placa no soportada"
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
tNomqtt.inicia();
|
||||
if(!suscrito)
|
||||
{
|
||||
for(int i=0; i<n; i++)
|
||||
|
|
@ -71,7 +106,19 @@ void DomoEspManager::loop()
|
|||
int tiempoAux=0;
|
||||
if(timer.onTimerReset())
|
||||
{
|
||||
#ifdef ESP8266
|
||||
if(conf->conexionPorApi)
|
||||
{
|
||||
|
||||
char topic_aux[32];
|
||||
char payload_aux[128];
|
||||
|
||||
while(api.getDataPendiente(conf->ideEsp,topic_aux, payload_aux))
|
||||
{
|
||||
OnMqtt(topic_aux, payload_aux);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
tiempo=(tiempo+1)%2;
|
||||
tiempoAux=tiempo+1;
|
||||
#ifdef DEBUG_PS
|
||||
|
|
@ -137,11 +184,26 @@ void DomoEspManager::SubscribeMqtt(PubSubClient *client_mqtt)
|
|||
|
||||
void DomoEspManager::MqttSend(char* topic, char* payload)
|
||||
{
|
||||
clienteMqtt.publish(topic, payload);
|
||||
if(conf->conexionPorApi)
|
||||
{
|
||||
#ifdef ESP8266
|
||||
api.send(topic, payload);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if(suscrito);
|
||||
clienteMqtt.publish(topic, payload);
|
||||
}
|
||||
}
|
||||
void DomoEspManager::MqttSubs(char* topic)
|
||||
{
|
||||
clienteMqtt.subscribe(topic);
|
||||
if(conf->conexionPorApi)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
clienteMqtt.subscribe(topic);
|
||||
}
|
||||
|
||||
void DomoEspManager::Add(DomoEspSensorReceiver* sensor)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,18 @@
|
|||
#ifndef DomoEspManagerDef
|
||||
#define DomoEspManagerDef 1
|
||||
|
||||
|
||||
#include <PubSubClient.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
#if defined(ESP8266)
|
||||
#include <ESP8266WiFi.h>
|
||||
#elif defined(ESP32) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ESP32C3)
|
||||
#include <WiFi.h>
|
||||
#else
|
||||
#error "Placa no soportada"
|
||||
#endif
|
||||
|
||||
#include "utiles.h"
|
||||
#include "DomoEspApiConexion.h"
|
||||
class DomoEspConfig;
|
||||
class IDomoEspLisener
|
||||
{
|
||||
|
|
@ -21,13 +31,18 @@ class DomoEspManager: public MqttReceiver, public IMqttManager, public ISensorMa
|
|||
WiFiClient espClient;
|
||||
PubSubClient clienteMqtt;
|
||||
MqttManager mqtt;
|
||||
#ifdef ESP8266
|
||||
DomoEspApiConexion api;
|
||||
#endif
|
||||
|
||||
|
||||
DomoEspSensorReceiver* sensores[MAXSENS];
|
||||
int n;
|
||||
int tiempo;
|
||||
bool suscrito;
|
||||
Ctimer timer;
|
||||
|
||||
Ctimer tNoConexion;
|
||||
Ctimer tNomqtt;
|
||||
public:
|
||||
|
||||
DomoEspManager();
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class SensorAin: public DomoEspSensorReceiver
|
|||
return val;
|
||||
}
|
||||
SensorAin(){}
|
||||
void set(uint8_t _pin, char* topic_id, bool _negado, float _dif)
|
||||
void set(uint8_t _pin,const char* topic_id, bool _negado, float _dif)
|
||||
{
|
||||
timer.inicia();
|
||||
timer.set(1);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class SensorBMP180: public DomoEspSensorReceiver
|
|||
t=p=a=0;
|
||||
topic[0]=0;
|
||||
}
|
||||
void set(char* topic_id, int _sda, int _scl)
|
||||
void set(const char* topic_id, int _sda, int _scl)
|
||||
{
|
||||
sda=_sda;
|
||||
scl=_scl;
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ class SensorBuzzer: public DomoEspSensorReceiver
|
|||
val=0;
|
||||
topic[0]=0;
|
||||
}
|
||||
void setMelodia(int i, char* melodia)
|
||||
void setMelodia(int i, const char* melodia)
|
||||
{
|
||||
buz.Set(i, melodia);
|
||||
}
|
||||
void set(char* topic_id, int _pin)
|
||||
void set(const char* topic_id, int _pin)
|
||||
{
|
||||
val=0;
|
||||
strcpy(topic, topic_id);
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ class SensorDHT: public DomoEspSensorReceiver
|
|||
t=h=0;
|
||||
topic[0]=0;
|
||||
}
|
||||
void set(uint8_t _pin, char* topic_id)
|
||||
void set(uint8_t _pin, const char* topic_id)
|
||||
{
|
||||
pin=_pin;
|
||||
t=h=0;
|
||||
t=h=9.99998;
|
||||
strcpy(topic, topic_id);
|
||||
}
|
||||
virtual void procesa(IMqttManager * man, int tiempo)
|
||||
|
|
@ -43,8 +43,17 @@ class SensorDHT: public DomoEspSensorReceiver
|
|||
}
|
||||
else
|
||||
{
|
||||
t=ta;
|
||||
h=ha;
|
||||
/*if(t==h && t==9.99998)
|
||||
{*/
|
||||
t=ta;
|
||||
h=ha;
|
||||
/*}
|
||||
else
|
||||
{
|
||||
t=(t+ta)/2;
|
||||
h=(h+ha)/2;
|
||||
}*/
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class SensorDin: public DomoEspSensorReceiver
|
|||
SensorDin(){
|
||||
logTiempo2=true;
|
||||
}
|
||||
void set(uint8_t _pin, char* topic_id, bool _logTiempo2=true)
|
||||
void set(uint8_t _pin, const char* topic_id, bool _logTiempo2=true)
|
||||
{
|
||||
logTiempo2=_logTiempo2;
|
||||
pin=_pin;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ bool negado;
|
|||
topic[0]=0;
|
||||
negado=false;
|
||||
}
|
||||
void set(uint8_t _pin, char* topic_id, bool valdef,bool _negado=false)
|
||||
void set(uint8_t _pin, const char* topic_id, bool valdef,bool _negado=false)
|
||||
{
|
||||
pin=_pin;
|
||||
val=valdef;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public:
|
|||
apan=0;
|
||||
|
||||
}
|
||||
void set(char* topic_id, LiquidCrystal * _lcd, int _nchar, int lineas, int seg)
|
||||
void set(const char* topic_id, LiquidCrystal * _lcd, int _nchar, int lineas, int seg)
|
||||
{
|
||||
val = 0;
|
||||
strcpy(topic, topic_id);
|
||||
|
|
@ -49,7 +49,7 @@ public:
|
|||
nlin = lineas;
|
||||
|
||||
}
|
||||
void AddPan(char* msg, DomoEspSensorReceiver *sen1=0, DomoEspSensorReceiver *sen2=0)
|
||||
void AddPan(const char* msg, DomoEspSensorReceiver *sen1=0, DomoEspSensorReceiver *sen2=0)
|
||||
{
|
||||
if(npan<MAX_PAN_LCD)
|
||||
{
|
||||
|
|
@ -126,7 +126,7 @@ private:
|
|||
Muestra(msg);
|
||||
|
||||
}
|
||||
void Muestra(char * txt)
|
||||
void Muestra(const char * txt)
|
||||
{
|
||||
#ifdef DEBUG_PS
|
||||
Serial.println("SenLcd muestra: ");
|
||||
|
|
@ -134,7 +134,7 @@ private:
|
|||
#endif
|
||||
int linea=0;
|
||||
int i=0;
|
||||
char* ini=txt;
|
||||
const char* ini=txt;
|
||||
bool sigue=true;
|
||||
while(sigue && linea<nlin)
|
||||
{
|
||||
|
|
@ -166,7 +166,7 @@ private:
|
|||
|
||||
|
||||
}
|
||||
void Muestra(char * txt,int nStr, int linea)
|
||||
void Muestra(const char * txt,int nStr, int linea)
|
||||
{
|
||||
char buf[MAXTOPICVAR];
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ bool negado;
|
|||
initDS1803();
|
||||
}
|
||||
|
||||
void set( char* topic_id, int valdef,bool _negado=false)
|
||||
void set( const char* topic_id, int valdef,bool _negado=false)
|
||||
{
|
||||
val=valdef;
|
||||
negado=_negado;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class SensorPulsante: public DomoEspSensorReceiver
|
|||
espera=false;
|
||||
timer.setmilis(500);
|
||||
}
|
||||
void set(uint8_t _pin, char* topic_id, bool _valDef)
|
||||
void set(uint8_t _pin, const char* topic_id, bool _valDef)
|
||||
{
|
||||
pin=_pin;
|
||||
valDef=_valDef;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class SensorRF: public DomoEspSensorReceiver
|
|||
val=0;
|
||||
topic[0]=0;
|
||||
}
|
||||
void set(char* topic_id,bool _negado=0, float valdef=0)
|
||||
void set(const char* topic_id,bool _negado=0, float valdef=0)
|
||||
{
|
||||
negado=_negado;
|
||||
val=valdef;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class SensorSplitter: public DomoEspSensorReceiver
|
|||
for(int i=0; i<MAX_ACTIVADORES; i++)
|
||||
sensorSend[i].sen=0;
|
||||
}
|
||||
void set(char* topic_id, float =0)
|
||||
void set(const char* topic_id, float =0)
|
||||
{
|
||||
val=0;
|
||||
strcpy(topic, topic_id);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class SensorTimer: public DomoEspSensorReceiver
|
|||
val=0;
|
||||
topic[0]=0;
|
||||
}
|
||||
void set(char* topic_id, bool _valdef, int segTime)
|
||||
void set(const char* topic_id, bool _valdef, int segTime)
|
||||
{
|
||||
t.set(segTime);
|
||||
valDef=_valdef;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class SensorVF: public DomoEspSensorReceiver
|
|||
val=0;
|
||||
topic[0]=0;
|
||||
}
|
||||
void set(char* topic_id, float valdef=0)
|
||||
void set(const char* topic_id, float valdef=0)
|
||||
{
|
||||
val=valdef;
|
||||
strcpy(topic, topic_id);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
#include <Arduino.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
|
||||
#if defined(ESP8266)
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
#elif defined(ESP32) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ESP32C3)
|
||||
#include <WiFi.h>
|
||||
#else
|
||||
#error "Placa no soportada"
|
||||
#endif
|
||||
|
||||
#include <WiFiUdp.h>
|
||||
#include <ArduinoOTA.h>
|
||||
#include <PubSubClient.h>
|
||||
|
|
@ -11,7 +19,15 @@
|
|||
//**************************************************************************************************************************************************
|
||||
void MqttUtiles::resetFunc()
|
||||
{
|
||||
ESP.wdtEnable(1);
|
||||
|
||||
#if defined(ESP32) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ESP32C3)
|
||||
ESP.restart();
|
||||
#elif defined(ESP8266)
|
||||
ESP.wdtEnable(1);
|
||||
#else
|
||||
#error "Placa no soportada"
|
||||
#endif
|
||||
|
||||
while(1){};
|
||||
}
|
||||
//**************************************************************************************************************************************************
|
||||
|
|
@ -168,9 +184,9 @@ bool WifiManager::loop()
|
|||
return true;
|
||||
}
|
||||
#ifdef DEBUG_PS
|
||||
Serial.println("Fallo de conexion, se reinicia arduino");
|
||||
Serial.println("Fallo de conexion wifi");
|
||||
#endif
|
||||
ESP.reset();
|
||||
//ESP.reset();
|
||||
return false;
|
||||
}
|
||||
//**************************************************************************************************************************************************
|
||||
|
|
@ -207,9 +223,9 @@ bool MqttManager::loop()
|
|||
|
||||
}
|
||||
#ifdef DEBUG_PS
|
||||
Serial.println("Fallo de conexion, se reinicia arduino");
|
||||
Serial.println("Fallo de conexion a mqtt broker");
|
||||
#endif
|
||||
ESP.reset();
|
||||
//ESP.reset();
|
||||
return false;
|
||||
}
|
||||
void MqttManager::subscribe_mqtt()
|
||||
|
|
@ -340,7 +356,7 @@ void SonidoBuzzer::Toca(int pin, int imel)
|
|||
mel[imel].Toca(pin);
|
||||
}
|
||||
|
||||
void SonidoBuzzer::Set(int i, char* melo)
|
||||
void SonidoBuzzer::Set(int i, const char* melo)
|
||||
{
|
||||
if(i<MAX_MELODIAS)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
#define UtilesDef 1
|
||||
#include "defines.h"
|
||||
class PubSubClient;
|
||||
#ifdef ESP8266
|
||||
class WiFiClient;
|
||||
|
||||
#endif
|
||||
class MqttUtiles
|
||||
{
|
||||
public:
|
||||
|
|
@ -97,7 +98,7 @@ class SonidoBuzzer
|
|||
int n;
|
||||
SonidoBuzzer();
|
||||
void Toca(int pin, int melodia);
|
||||
void Set(int i, char* melo);
|
||||
void Set(int i, const char* melo);
|
||||
char* getMelSubSt(char* orig, char caracter, int lim, char* bufOut);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,29 @@
|
|||
|
||||
|
||||
//configuraciones-----------------------------------------------------
|
||||
|
||||
class PruebaConexiones: public DomoEspConfig
|
||||
{
|
||||
SensorDHT dht;
|
||||
SensorDout led;
|
||||
public:
|
||||
PruebaConexiones()
|
||||
{
|
||||
strcpy(hostMQTT,"192.168.2.115");//servidor mqttBroker
|
||||
strcpy(ssidWifi,"IdhunDesa");//nombre wifi
|
||||
strcpy(ideEsp,"Esp8266_PCon");//idenitificador del esp (sera único)
|
||||
dht.set(D1,"casa/PCon");
|
||||
led.set(D4, "casa/PCon/led",0,0);
|
||||
}
|
||||
virtual void inicia(ISensorManager* man)
|
||||
{
|
||||
man->Add(&dht);
|
||||
man->Add(&led);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class ConfAutomatismos: public DomoEspConfig
|
||||
{
|
||||
SensorRF presencia;
|
||||
|
|
@ -391,10 +414,10 @@ class ConfigAltavozCocina: public DomoEspConfig
|
|||
{
|
||||
|
||||
strcpy(ssidWifi,"IdhunAux");//nombre wifi
|
||||
strcpy(ideEsp,"Esp8266_Av_cocian");//idenitificador del esp (sera único)
|
||||
strcpy(ideEsp,"Esp8266_Av_cocina");//idenitificador del esp (sera único)
|
||||
|
||||
ampli.set(D4,"casa/cocina/aux",0,1);
|
||||
altavoz.set(D3,"casa/cocina/alt",0,1);
|
||||
ampli.set(D4,"casa/cocina/alt",0,1);
|
||||
altavoz.set(D3,"casa/cocina/blue",0,1);
|
||||
radio.set(D5,"casa/cocina/arad",0);
|
||||
poten.set("casa/cocina/volu",50, 0);
|
||||
pulso.set("casa/cocina/rad",1,1);
|
||||
|
|
@ -438,7 +461,116 @@ class ConfLamSalon: public DomoEspConfig
|
|||
}
|
||||
|
||||
};
|
||||
class ConfHabitacionPrincipal: public DomoEspConfig
|
||||
{
|
||||
SensorDHT dht;
|
||||
SensorDout radio;
|
||||
public:
|
||||
ConfHabitacionPrincipal()
|
||||
{
|
||||
strcpy(ssidWifi,"Idhun");//nombre wifi
|
||||
strcpy(ideEsp,"Esp8266_HP");//idenitificador del esp (sera único)
|
||||
dht.set(D4,"casa/habPrin");
|
||||
radio.set(D0, "casa/habPrin/rad",0,0);
|
||||
}
|
||||
virtual void inicia(ISensorManager* man)
|
||||
{
|
||||
man->Add(&dht);
|
||||
man->Add(&radio);
|
||||
|
||||
ConfigAltavozCocina ConfiguracionActual;
|
||||
}
|
||||
|
||||
};
|
||||
class ConfHabitacionNinas: public DomoEspConfig
|
||||
{
|
||||
SensorDHT dht;
|
||||
SensorDout cartel;
|
||||
SensorDin interruptor;
|
||||
AutomatismoPulsador actuadorPul;
|
||||
public:
|
||||
ConfHabitacionNinas()
|
||||
{
|
||||
strcpy(ssidWifi,"IdhunAux");//nombre wifi
|
||||
strcpy(ideEsp,"Esp8266_HN");//idenitificador del esp (sera único)
|
||||
|
||||
|
||||
/*
|
||||
int cociMov= vars->AddInternalVarInt( "casa/cocina/mov");
|
||||
int cociLuz= vars->AddInternalVarInt( "casa/cocina/luz");
|
||||
int cociLam= vars->AddInternalVarInt( "casa/cocina/lam");
|
||||
int cociAuto= vars->AddInternalVarInt("casa/cocina/luzAuto");
|
||||
*/
|
||||
dht.set(D0,"casa/habNin");
|
||||
cartel.set(D2, "casa/habNin/cartel",0,0);
|
||||
interruptor.set( D1, "casa/habNin/inter", false);
|
||||
}
|
||||
virtual void inicia(ISensorManager* man)
|
||||
{
|
||||
man->Add(&dht);
|
||||
man->Add(&cartel);
|
||||
man->Add(&interruptor);
|
||||
actuadorPul.inicia(man, &interruptor, &cartel);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
class ConfPruebaDHT: public DomoEspConfig
|
||||
{
|
||||
SensorDHT dht;
|
||||
|
||||
public:
|
||||
ConfPruebaDHT()
|
||||
{
|
||||
strcpy(ssidWifi,"IdhunAux");//nombre wifi
|
||||
strcpy(ideEsp,"Esp8266_dht");//idenitificador del esp (sera único)
|
||||
dht.set(D0, "casa/pruebas/dht");
|
||||
}
|
||||
virtual void inicia(ISensorManager* man)
|
||||
{
|
||||
man->Add(&dht);
|
||||
}
|
||||
|
||||
};
|
||||
class ConfSonofPrueba: public DomoEspConfig
|
||||
{
|
||||
SensorDout luz;
|
||||
SensorDin interruptor;
|
||||
AutomatismoPulsador actuadorInterrup;
|
||||
//SensorPulsante pul;
|
||||
//Actuador actpon;
|
||||
//Actuador actpoff;
|
||||
public:
|
||||
ConfSonofPrueba()
|
||||
{
|
||||
strcpy(ssidWifi,"IdhunDesa");//nombre wifi
|
||||
strcpy(ideEsp,"Esp32c3_soff2");//idenitificador del esp (sera único)
|
||||
luz.set(4, "casa/sonoff2/luz",0,0);
|
||||
interruptor.set( 18, "casa/sonoff2/inter", false);
|
||||
|
||||
|
||||
|
||||
|
||||
//pul.set(19,"casa/sonoff/pul",1);
|
||||
|
||||
//actpon.set("casa/sonoff/pul","casa/sonoff/luz","0");
|
||||
//actpoff.set("casa/sonoff/pul","casa/sonoff/luz","1");
|
||||
//actpon.AddActivador(&luz, '>', 0);
|
||||
//actpoff.AddActivador(&luz, '<', 1);
|
||||
}
|
||||
virtual void inicia(ISensorManager* man)
|
||||
{
|
||||
man->Add(&luz);
|
||||
man->Add(&interruptor);
|
||||
//man->Add(&pul);
|
||||
//man->Add(&actpon);
|
||||
//man->Add(&actpoff);
|
||||
|
||||
actuadorInterrup.inicia(man, &interruptor, &luz);
|
||||
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
ConfSonofPrueba ConfiguracionActual;
|
||||
|
||||
#endif
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
#define DefinesDef 1
|
||||
|
||||
#define DEBUG_PS 1
|
||||
|
||||
#define MAXTOPICVAR 32//maximo de caracteres de los topic de las variables
|
||||
#define MAX_CHAR_PAN_LCD 35//MAXIMO DE CARACTRES POR PANTALLA LCD
|
||||
#define MAX_PAN_LCD 3//MAXIMO DE PANTALLAS POR SENSOR LCD
|
||||
|
|
|
|||
Loading…
Reference in New Issue