ESP32-PaxCounter/include/mqttclient.h

38 lines
1.1 KiB
C
Raw Normal View History

2020-05-16 23:49:34 +02:00
#ifndef _MQTTCLIENT_H
#define _MQTTCLIENT_H
#include "globals.h"
#include "rcommand.h"
2020-06-20 15:04:03 +02:00
#include <MQTT.h>
2020-07-19 16:03:15 +02:00
#include <ETH.h>
2020-05-16 23:49:34 +02:00
2020-07-19 16:03:15 +02:00
#define MQTT_ETHERNET 0 // set to 0 to run on Wifi
#define MQTT_INTOPIC "paxin"
#define MQTT_OUTTOPIC "paxout"
2020-05-16 23:49:34 +02:00
#define MQTT_PORT 1883
2020-06-20 15:04:03 +02:00
#define MQTT_SERVER "broker.shiftr.io"
//#define MQTT_CLIENTNAME "arduino"
#define MQTT_USER "try"
#define MQTT_PASSWD "try"
2020-06-16 20:29:49 +02:00
#define MQTT_RETRYSEC 20 // retry reconnect every 20 seconds
2020-06-20 15:04:03 +02:00
#define MQTT_KEEPALIVE 10 // keep alive interval in seconds
#define MQTT_TIMEOUT 1000 // timeout for all mqtt commands in milliseconds
#ifndef MQTT_CLIENTNAME
#define MQTT_CLIENTNAME clientId.c_str()
#endif
2020-05-16 23:49:34 +02:00
extern TaskHandle_t mqttTask;
void mqtt_enqueuedata(MessageBuffer_t *message);
void mqtt_queuereset(void);
void setMqttIRQ(void);
2020-06-16 20:29:49 +02:00
void mqtt_loop(void);
2020-05-16 23:49:34 +02:00
void mqtt_client_task(void *param);
2020-05-20 18:29:07 +02:00
int mqtt_connect(const char *my_host, const uint16_t my_port);
2020-06-20 15:04:03 +02:00
void mqtt_callback(MQTTClient *client, char topic[], char payload[],
int length);
2020-05-20 12:40:37 +02:00
void NetworkEvent(WiFiEvent_t event);
2020-05-16 23:49:34 +02:00
esp_err_t mqtt_init(void);
#endif // _MQTTCLIENT_H