From 0497ba436dcb68bc4403babc7f8f31291baf5c74 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 27 Nov 2025 23:09:28 +0100 Subject: [PATCH] quitar warnings y defines segun placas --- DomoEspSensor/Actuador.h | 4 ++-- DomoEspSensor/Automatismos.h | 2 +- DomoEspSensor/DomoEspApiConexion.h | 4 ++-- DomoEspSensor/DomoEspSensor.ino | 2 +- DomoEspSensor/DomoEspSensorManager.cpp | 21 ++++++++++--------- DomoEspSensor/DomoEspSensorManager.h | 15 +++++++------- DomoEspSensor/SensorAin.h | 2 +- DomoEspSensor/SensorBMP180.h | 2 +- DomoEspSensor/SensorBuzzer.h | 4 ++-- DomoEspSensor/SensorDHT.h | 2 +- DomoEspSensor/SensorDin.h | 2 +- DomoEspSensor/SensorDout.h | 2 +- DomoEspSensor/SensorLcd.h | 10 ++++----- DomoEspSensor/SensorPotenI2c.h | 2 +- DomoEspSensor/SensorPulsante.h | 2 +- DomoEspSensor/SensorRF.h | 2 +- DomoEspSensor/SensorSplitter.h | 2 +- DomoEspSensor/SensorTimer.h | 2 +- DomoEspSensor/SensorVF.h | 2 +- DomoEspSensor/Utiles.cpp | 28 ++++++++++++++------------ DomoEspSensor/Utiles.h | 5 ++--- DomoEspSensor/defines.h | 4 ---- 22 files changed, 60 insertions(+), 61 deletions(-) diff --git a/DomoEspSensor/Actuador.h b/DomoEspSensor/Actuador.h index c4ef80c..c961591 100644 --- a/DomoEspSensor/Actuador.h +++ b/DomoEspSensor/Actuador.h @@ -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); } diff --git a/DomoEspSensor/Automatismos.h b/DomoEspSensor/Automatismos.h index 9ee3470..b37c084 100644 --- a/DomoEspSensor/Automatismos.h +++ b/DomoEspSensor/Automatismos.h @@ -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"); diff --git a/DomoEspSensor/DomoEspApiConexion.h b/DomoEspSensor/DomoEspApiConexion.h index ee1ab12..aa16c46 100644 --- a/DomoEspSensor/DomoEspApiConexion.h +++ b/DomoEspSensor/DomoEspApiConexion.h @@ -1,10 +1,10 @@ #ifndef DomoEspApiConexionDef #define DomoEspApiConexionDef 1 #include "defines.h" -#ifndef ESP32_DEF +#ifdef ESP8266 #include //sensor Replica, sensor interno que se setea con get y no se publica -class DomoEspApiConexion +class DomoEspApiConexion //hay que arreglar compatibilidad con esp32 { public: DomoEspApiConexion() diff --git a/DomoEspSensor/DomoEspSensor.ino b/DomoEspSensor/DomoEspSensor.ino index 654ef02..2727022 100644 --- a/DomoEspSensor/DomoEspSensor.ino +++ b/DomoEspSensor/DomoEspSensor.ino @@ -1,4 +1,4 @@ -#define ESP32_DEF 1 + #include "DomoEspSensorManager.h" #include "configuracionActual.h" DomoEspManager manager; diff --git a/DomoEspSensor/DomoEspSensorManager.cpp b/DomoEspSensor/DomoEspSensorManager.cpp index 000a63a..0c7f72a 100644 --- a/DomoEspSensor/DomoEspSensorManager.cpp +++ b/DomoEspSensor/DomoEspSensorManager.cpp @@ -64,10 +64,12 @@ void DomoEspManager::loop() { if(tNoConexion.onTimer()) { - #ifndef ESP32_DEF + #if defined(ESP8266) ESP.reset(); + #elif defined(ESP32) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ESP32C3) + ESP.restart(); #else - ESP.restart(); + #error "Placa no soportada" #endif return; @@ -80,10 +82,12 @@ void DomoEspManager::loop() suscrito=false; if(tNomqtt.onTimer()) { - #ifndef ESP32_DEF + #if defined(ESP8266) ESP.reset(); + #elif defined(ESP32) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ESP32C3) + ESP.restart(); #else - ESP.restart(); + #error "Placa no soportada" #endif return; @@ -102,12 +106,10 @@ void DomoEspManager::loop() int tiempoAux=0; if(timer.onTimerReset()) { - #ifndef ESP32_DEF + #ifdef ESP8266 if(conf->conexionPorApi) { - #ifndef ESP32_DEF - - + char topic_aux[32]; char payload_aux[128]; @@ -115,7 +117,6 @@ void DomoEspManager::loop() { OnMqtt(topic_aux, payload_aux); } - #endif } #endif tiempo=(tiempo+1)%2; @@ -185,7 +186,7 @@ void DomoEspManager::MqttSend(char* topic, char* payload) { if(conf->conexionPorApi) { - #ifndef ESP32_DEF + #ifdef ESP8266 api.send(topic, payload); #endif } diff --git a/DomoEspSensor/DomoEspSensorManager.h b/DomoEspSensor/DomoEspSensorManager.h index e5d3f4c..1ffb413 100644 --- a/DomoEspSensor/DomoEspSensorManager.h +++ b/DomoEspSensor/DomoEspSensorManager.h @@ -3,11 +3,12 @@ #include -#ifndef ESP32_DEF -#include -#endif -#ifdef ESP32_DEF -#include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ESP32C3) + #include +#else + #error "Placa no soportada" #endif #include "utiles.h" @@ -30,8 +31,8 @@ class DomoEspManager: public MqttReceiver, public IMqttManager, public ISensorMa WiFiClient espClient; PubSubClient clienteMqtt; MqttManager mqtt; - #ifndef ESP32_DEF - DomoEspApiConexion api; + #ifdef ESP8266 + DomoEspApiConexion api; #endif diff --git a/DomoEspSensor/SensorAin.h b/DomoEspSensor/SensorAin.h index 39cb51e..dc1e72b 100644 --- a/DomoEspSensor/SensorAin.h +++ b/DomoEspSensor/SensorAin.h @@ -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); diff --git a/DomoEspSensor/SensorBMP180.h b/DomoEspSensor/SensorBMP180.h index c495103..3a3b538 100644 --- a/DomoEspSensor/SensorBMP180.h +++ b/DomoEspSensor/SensorBMP180.h @@ -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; diff --git a/DomoEspSensor/SensorBuzzer.h b/DomoEspSensor/SensorBuzzer.h index b4817f4..82fa566 100644 --- a/DomoEspSensor/SensorBuzzer.h +++ b/DomoEspSensor/SensorBuzzer.h @@ -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); diff --git a/DomoEspSensor/SensorDHT.h b/DomoEspSensor/SensorDHT.h index 5657ea0..4cac338 100644 --- a/DomoEspSensor/SensorDHT.h +++ b/DomoEspSensor/SensorDHT.h @@ -20,7 +20,7 @@ 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=9.99998; diff --git a/DomoEspSensor/SensorDin.h b/DomoEspSensor/SensorDin.h index 02fa45d..797590c 100644 --- a/DomoEspSensor/SensorDin.h +++ b/DomoEspSensor/SensorDin.h @@ -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; diff --git a/DomoEspSensor/SensorDout.h b/DomoEspSensor/SensorDout.h index e026275..be25561 100644 --- a/DomoEspSensor/SensorDout.h +++ b/DomoEspSensor/SensorDout.h @@ -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; diff --git a/DomoEspSensor/SensorLcd.h b/DomoEspSensor/SensorLcd.h index c2bb35b..92b1a8b 100644 --- a/DomoEspSensor/SensorLcd.h +++ b/DomoEspSensor/SensorLcd.h @@ -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 -#define ESP32_DEF 1 -#ifndef ESP32_DEF -#include -#include -#endif -#ifdef ESP32_DEF -#include + +#if defined(ESP8266) + #include + #include +#elif defined(ESP32) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ESP32C3) + #include +#else + #error "Placa no soportada" #endif #include @@ -19,11 +20,12 @@ void MqttUtiles::resetFunc() { - #ifdef ESP32_DEF - ESP.restart(); - #endif - #ifndef ESP32_DEF - 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){}; @@ -354,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