Correct mqtt simplification
This commit is contained in:
parent
8101e7bd36
commit
3eb9298cb1
12
WifiControlSensor/MQTT.h
Normal file
12
WifiControlSensor/MQTT.h
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include "Adafruit_MQTT.h"
|
||||
|
||||
Adafruit_MQTT_Publish *MqttCreatePublisher(const char *fmt, ...);
|
||||
int MqttConnect();
|
||||
int MqttIsConnected();
|
||||
int MqttSetup(char *server, char *user, char *passwd, int port, char * hostname);
|
||||
int MqttPublish(double temp, double pressure);
|
||||
int MqttDhtPublish(float temp, float humidity);
|
||||
void MqttCheckSubscription();
|
||||
void MqttChangeGpioValue(int gpio, int value);
|
||||
bool MqttIsConfigured();
|
@ -41,8 +41,10 @@ int MqttSetup(char *server, char *user, char *passwd, int port, char * hostname)
|
||||
return 0;
|
||||
|
||||
mqtt = new Adafruit_MQTT_Client(&client, server, port, user, passwd);
|
||||
mqtt_dht_temp = MqttCreatePublisher("/feeds/%s/dht/temperature", mqttId);
|
||||
mqtt_dht_humidity = MqttCreatePublisher("/feeds/%s/dht/humidity", mqttId);
|
||||
mqtt_dht_temp = MqttCreatePublisher(TEMPERATURE_DHT_FEED_FORMAT, mqttId);
|
||||
mqtt_dht_humidity = MqttCreatePublisher(HUMIDITY_DHT_FEED_FORMAT, mqttId);
|
||||
mqtt_temp = MqttCreatePublisher(TEMPERATURE_FEED_FORMAT, mqttId);
|
||||
mqtt_pressure = MqttCreatePublisher(PRESSURE_FEED_FORMAT, mqttId);
|
||||
|
||||
for (uint i = 0 ; i < NB_ELEMENTS(gpioWatched) && i < MAXSUBSCRIPTIONS; i++) {
|
||||
snprintf(GPIO_FEED[i], FEED_MAX_SIZE, GPIO_FEED_FORMAT, mqttId, gpioWatched[i]);
|
||||
|
Loading…
Reference in New Issue
Block a user