Ver mensajes en display
parent
e1dde4e137
commit
c07b299e21
|
|
@ -7,11 +7,11 @@ DomoEspManager::DomoEspManager()
|
|||
//vars.AddListenner(&des);
|
||||
sens.Config(&vars);
|
||||
suscrito=false;
|
||||
|
||||
}
|
||||
|
||||
void DomoEspManager::inicia( LiquidCrystal *lcd, PubSubClient *mqttClient, WiFiClient* espClient, DomoConfig* conf)
|
||||
{
|
||||
mqttclient=mqttClient;
|
||||
#ifdef DEBUG_PS
|
||||
Serial.println("Inicia Wifi");
|
||||
#endif
|
||||
|
|
@ -68,6 +68,9 @@ void DomoEspManager::loop()
|
|||
if(!suscrito)
|
||||
{
|
||||
vars.Suscribe();
|
||||
#if CON_LCD
|
||||
lcdm.suscribe(mqttclient);
|
||||
#endif
|
||||
suscrito=true;
|
||||
}
|
||||
|
||||
|
|
@ -83,9 +86,13 @@ void DomoEspManager::OnMqtt(char* topic, char* payload)
|
|||
{
|
||||
vars.OnMqtt(topic, payload);
|
||||
des.OnMqtt(topic, payload);
|
||||
#ifdef DEBUG_PS
|
||||
Serial.println("OnMqtt fin");
|
||||
#endif
|
||||
#if CON_LCD
|
||||
lcdm.OnMqtt(topic, payload);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_PS
|
||||
Serial.println("OnMqtt fin");
|
||||
#endif
|
||||
}
|
||||
|
||||
void DomoEspManager::SubscribeMqtt(PubSubClient *client_mqtt)
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ class DomoEspManager: public MqttReceiver
|
|||
|
||||
|
||||
|
||||
PubSubClient *mqttclient;
|
||||
//variables-------------
|
||||
//MqttVarArray avar;
|
||||
//MqttTopicAttay topics;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <SPI.h>
|
||||
#include <LiquidCrystal.h>
|
||||
|
||||
#include <PubSubClient.h>
|
||||
#include "MqttDefines.h"
|
||||
#include "MqttUtiles.h"
|
||||
#include "MqttVarManager.h"
|
||||
|
|
@ -21,6 +21,7 @@ void LcdMQTTViewer::envia(char* txt, int pos, int line)
|
|||
}
|
||||
LcdMQTTViewer::LcdMQTTViewer()
|
||||
{
|
||||
topic[0]=0;
|
||||
maxpan = 0;
|
||||
tiempo = 0;
|
||||
incre_t = 10 * 1000;
|
||||
|
|
@ -101,3 +102,38 @@ void LcdMQTTViewer::add(byte ivar, char* formatLCD, int line, int pan)
|
|||
if (maxpan < pan)
|
||||
maxpan = pan;
|
||||
}
|
||||
|
||||
int LcdMQTTViewer::OnMqtt(char* top, char* payload)
|
||||
{
|
||||
if(strcmp(top,topic))
|
||||
return -1;
|
||||
|
||||
int i=0;
|
||||
int lin=0;
|
||||
int n=0;
|
||||
char buf[64];
|
||||
while(payload[i])
|
||||
{
|
||||
if(payload[i]=='\n')
|
||||
{
|
||||
i++;
|
||||
buf[n]=0;
|
||||
envia(buf,0,lin);
|
||||
lin++;
|
||||
n=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[n++]=payload[i++];
|
||||
}
|
||||
}
|
||||
buf[n]=0;
|
||||
envia(buf,0,lin);
|
||||
tiempo=millis();
|
||||
}
|
||||
void LcdMQTTViewer::suscribe(PubSubClient *client_qqtt)
|
||||
{
|
||||
if(!topic[0])
|
||||
return;
|
||||
client_qqtt->subscribe(topic);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public:
|
|||
int panActual = 0;
|
||||
unsigned long tiempo;
|
||||
unsigned long incre_t;
|
||||
|
||||
char topic[MAXSTR];//topic de mqtt Alarma
|
||||
|
||||
MqttVarManager* vars;
|
||||
|
||||
|
|
@ -40,7 +40,8 @@ public:
|
|||
|
||||
void inicia(MqttVarManager *vars, LiquidCrystal* lcdEx, int digi, int lines);
|
||||
void loop();//publica datos variables
|
||||
|
||||
int OnMqtt(char* topic, char* payload);
|
||||
void suscribe(PubSubClient *client_qqtt);
|
||||
//auxiliares----------------------------------------------------------
|
||||
void add(byte ivar, char* formatLCD, int line, int pan);
|
||||
void setTimer(int seg);
|
||||
|
|
|
|||
|
|
@ -255,6 +255,7 @@ class DespachoDomoConfig: public DomoConfig
|
|||
lcd->add(hcocina,"H coci: %s",1,1);
|
||||
lcd->add(temExt,"T Ext: %s",0,2);
|
||||
lcd->add(hExt,"H Ext: %s",1,2);
|
||||
strcpy(lcd->topic,"casa/desp/msg");
|
||||
}
|
||||
};
|
||||
class CocinaDomoConfig: public DomoConfig
|
||||
|
|
|
|||
Loading…
Reference in New Issue