compatibilidad con esp32
parent
89869031c8
commit
7555635e51
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef DomoEspApiConexionDef
|
||||
#define DomoEspApiConexionDef 1
|
||||
#include "defines.h"
|
||||
#ifndef ESP32_DEF
|
||||
#include <ESP8266HTTPClient.h>
|
||||
//sensor Replica, sensor interno que se setea con get y no se publica
|
||||
class DomoEspApiConexion
|
||||
|
|
@ -73,4 +74,5 @@ class DomoEspApiConexion
|
|||
return httpCode==200;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
#define ESP32_DEF 1
|
||||
#include "DomoEspSensorManager.h"
|
||||
#include "configuracionActual.h"
|
||||
DomoEspManager manager;
|
||||
|
|
|
|||
|
|
@ -63,8 +63,15 @@ void DomoEspManager::loop()
|
|||
if(!wifi.conecta())
|
||||
{
|
||||
if(tNoConexion.onTimer())
|
||||
ESP.reset();
|
||||
return;
|
||||
{
|
||||
#ifndef ESP32_DEF
|
||||
ESP.reset();
|
||||
#else
|
||||
ESP.restart();
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
tNoConexion.inicia();
|
||||
|
|
@ -72,7 +79,15 @@ void DomoEspManager::loop()
|
|||
{
|
||||
suscrito=false;
|
||||
if(tNomqtt.onTimer())
|
||||
ESP.reset();
|
||||
{
|
||||
#ifndef ESP32_DEF
|
||||
ESP.reset();
|
||||
#else
|
||||
ESP.restart();
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
tNomqtt.inicia();
|
||||
|
|
@ -87,16 +102,22 @@ void DomoEspManager::loop()
|
|||
int tiempoAux=0;
|
||||
if(timer.onTimerReset())
|
||||
{
|
||||
if(conf->conexionPorApi)
|
||||
{
|
||||
char topic_aux[32];
|
||||
char payload_aux[128];
|
||||
|
||||
while(api.getDataPendiente(conf->ideEsp,topic_aux, payload_aux))
|
||||
#ifndef ESP32_DEF
|
||||
if(conf->conexionPorApi)
|
||||
{
|
||||
OnMqtt(topic_aux, payload_aux);
|
||||
#ifndef ESP32_DEF
|
||||
|
||||
|
||||
char topic_aux[32];
|
||||
char payload_aux[128];
|
||||
|
||||
while(api.getDataPendiente(conf->ideEsp,topic_aux, payload_aux))
|
||||
{
|
||||
OnMqtt(topic_aux, payload_aux);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
tiempo=(tiempo+1)%2;
|
||||
tiempoAux=tiempo+1;
|
||||
#ifdef DEBUG_PS
|
||||
|
|
@ -163,7 +184,11 @@ void DomoEspManager::SubscribeMqtt(PubSubClient *client_mqtt)
|
|||
void DomoEspManager::MqttSend(char* topic, char* payload)
|
||||
{
|
||||
if(conf->conexionPorApi)
|
||||
api.send(topic, payload);
|
||||
{
|
||||
#ifndef ESP32_DEF
|
||||
api.send(topic, payload);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if(suscrito);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,15 @@
|
|||
#ifndef DomoEspManagerDef
|
||||
#define DomoEspManagerDef 1
|
||||
|
||||
|
||||
#include <PubSubClient.h>
|
||||
#ifndef ESP32_DEF
|
||||
#include <ESP8266WiFi.h>
|
||||
#endif
|
||||
#ifdef ESP32_DEF
|
||||
#include <WiFi.h>
|
||||
#endif
|
||||
|
||||
#include "utiles.h"
|
||||
#include "DomoEspApiConexion.h"
|
||||
class DomoEspConfig;
|
||||
|
|
@ -22,7 +30,10 @@ class DomoEspManager: public MqttReceiver, public IMqttManager, public ISensorMa
|
|||
WiFiClient espClient;
|
||||
PubSubClient clienteMqtt;
|
||||
MqttManager mqtt;
|
||||
#ifndef ESP32_DEF
|
||||
DomoEspApiConexion api;
|
||||
#endif
|
||||
|
||||
|
||||
DomoEspSensorReceiver* sensores[MAXSENS];
|
||||
int n;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,13 @@
|
|||
#include <Arduino.h>
|
||||
#define ESP32_DEF 1
|
||||
#ifndef ESP32_DEF
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
#endif
|
||||
#ifdef ESP32_DEF
|
||||
#include <WiFi.h>
|
||||
#endif
|
||||
|
||||
#include <WiFiUdp.h>
|
||||
#include <ArduinoOTA.h>
|
||||
#include <PubSubClient.h>
|
||||
|
|
@ -11,7 +18,14 @@
|
|||
//**************************************************************************************************************************************************
|
||||
void MqttUtiles::resetFunc()
|
||||
{
|
||||
|
||||
#ifdef ESP32_DEF
|
||||
ESP.restart();
|
||||
#endif
|
||||
#ifndef ESP32_DEF
|
||||
ESP.wdtEnable(1);
|
||||
#endif
|
||||
|
||||
while(1){};
|
||||
}
|
||||
//**************************************************************************************************************************************************
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@
|
|||
#define UtilesDef 1
|
||||
#include "defines.h"
|
||||
class PubSubClient;
|
||||
class WiFiClient;
|
||||
|
||||
#ifndef ESP32_DEF
|
||||
class WiFiClient;
|
||||
#endif
|
||||
class MqttUtiles
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -468,7 +468,7 @@ class ConfHabitacionPrincipal: public DomoEspConfig
|
|||
public:
|
||||
ConfHabitacionPrincipal()
|
||||
{
|
||||
strcpy(ssidWifi,"IdhunAux");//nombre wifi
|
||||
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);
|
||||
|
|
@ -531,7 +531,46 @@ class ConfPruebaDHT: public DomoEspConfig
|
|||
}
|
||||
|
||||
};
|
||||
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);
|
||||
|
||||
PruebaConexiones ConfiguracionActual;
|
||||
|
||||
|
||||
|
||||
//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
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
#ifndef DefinesDef
|
||||
|
||||
#define ESP32_DEF 1
|
||||
|
||||
#define DefinesDef 1
|
||||
|
||||
#define DEBUG_PS 1
|
||||
|
|
|
|||
Loading…
Reference in New Issue