Domotique/WifiControlSensor/MQTT.h

61 lines
2.8 KiB
C
Raw Normal View History

2016-04-14 01:37:28 +02:00
#pragma once
//FEED have the following formats /feeds/USER/DEVICE_NAME/....
#define TEMPERATURE_FEED_FORMAT "/feeds/%s/%s/temperature"
#define PRESSURE_FEED_FORMAT "/feeds/%s/%s/pressure"
#define TEMPERATURE_DHT_FEED_FORMAT "/feeds/%s/%s/dht/temperature"
#define HUMIDITY_DHT_FEED_FORMAT "/feeds/%s/%s/dht/humidity"
#define DRY_FEED_FORMAT "/feeds/%s/%s/dry"
#define GPIO_FEED_FORMAT "/feeds/%s/%s/gpio/%d"
#define GPIO_SET_FEED_FORMAT "/feeds/%s/%s/gpio/%d/set"
#define PWM_FEED_FORMAT "/feeds/%s/%s/gpio/%d"
#define PWM_SET_FEED_FORMAT "/feeds/%s/%s/gpio/%d/set"
#define IP_FEED_FORMAT "/feeds/%s/%s/configuration/ip/addr"
2020-02-27 00:07:30 +01:00
#define BME680_TEMPERATURE_FEED_FORMAT "/feeds/%s/%s/bme680/temperature"
#define BME680_PRESSURE_FEED_FORMAT "/feeds/%s/%s/bme680/pressure"
#define BME680_HUMIDITY_FEED_FORMAT "/feeds/%s/%s/bme680/humidity"
#define BME680_GAZ_FEED_FORMAT "/feeds/%s/%s/bme680/gaz"
#define BME680_ALT_FEED_FORMAT "/feeds/%s/%s/bme680/alt"
2020-07-28 19:37:19 +02:00
#define BME680_IAQ_FEED_FORMAT "/feeds/%s/%s/bme680/iaq"
#define BME680_IAQ_ACC_FEED_FORMAT "/feeds/%s/%s/bme680/iaqAcc"
2021-02-18 00:25:45 +01:00
#define TELEINFO_IINST_FEED_FORMAT "/feeds/%s/%s/teleinfo/iinst"
#define TELEINFO_PAPP_FEED_FORMAT "/feeds/%s/%s/teleinfo/papp"
2016-10-28 18:04:30 +02:00
#ifndef CONFIG_DISABLE_MQTT
2016-04-14 01:37:28 +02:00
#include "Adafruit_MQTT.h"
2016-12-14 00:08:47 +01:00
typedef struct {uint8_t updated; int value;} gpioInfo;
struct mqttInfo {
float value;
2020-02-28 17:16:39 +01:00
const char *topic;
uint8_t retain;
uint8_t qos;
};
int MqttBatchPublish(std::vector<struct mqttInfo> tab, ...);
Adafruit_MQTT_Publish *MqttCreatePublisher(uint8_t qos, uint8_t retain, const char *fmt, ...);
2016-04-14 01:37:28 +02:00
int MqttConnect();
int MqttIsConnected();
2020-03-09 22:38:43 +01:00
int MqttSetup(const char *server, const char *user, const char *passwd, int port, const char * hostname);
template<typename T> int MqttPublish(Adafruit_MQTT_Publish *publisher, T value);
int MqttPublishIp(const String &ip);
2016-04-14 01:37:28 +02:00
void MqttCheckSubscription();
2016-12-14 00:08:47 +01:00
void MqttCheckIRQ();
2016-04-14 01:37:28 +02:00
void MqttChangeGpioValue(int gpio, int value);
2016-09-28 15:45:45 +02:00
void MqttChangePWMValue(int gpio, int value);
2016-12-14 00:08:47 +01:00
void MqttNofityIRQ(uint8_t gpio, int value);
void MqttNofity(int gpio, int value);
2016-10-28 18:04:30 +02:00
#else
int MqttBatchPublish(std::vector<struct mqttInfo> tab, ...){return 0;}
2016-10-28 18:04:30 +02:00
int MqttConnect(){return 0;}
int MqttIsConnected(){return 0;}
2020-03-09 22:38:43 +01:00
int MqttSetup(const char *server, const char *user, const char *passwd, int port, const char * hostname){return 0;}
template<typename T> int MqttPublish(Adafruit_MQTT_Publish *publisher, T value){return 0;}
int MqttPublishIP(const String &ip){return 0;}
2016-10-28 18:04:30 +02:00
void MqttCheckSubscription(){}
2016-12-14 00:08:47 +01:00
void MqttCheckIRQ(){}
2016-10-28 18:04:30 +02:00
void MqttChangeGpioValue(int gpio, int value){}
void MqttChangePWMValue(int gpio, int value){}
2016-12-14 00:08:47 +01:00
void MqttNofityIRQ(uint8_t gpio, int value){}
void MqttNofity(int gpio, int value){}
2016-10-28 18:04:30 +02:00
#endif