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-12-23 16:31:31 +01:00
|
|
|
#define MQTT_ETHERNET 0 // select PHY: set 0 for Wifi, 1 for ethernet
|
2020-07-19 16:03:15 +02:00
|
|
|
#define MQTT_INTOPIC "paxin"
|
|
|
|
#define MQTT_OUTTOPIC "paxout"
|
2020-05-16 23:49:34 +02:00
|
|
|
#define MQTT_PORT 1883
|
2020-12-23 16:31:31 +01:00
|
|
|
#define MQTT_SERVER "paxcounter.cloud.shiftr.io"
|
|
|
|
#define MQTT_USER "public"
|
|
|
|
#define MQTT_PASSWD "public"
|
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
|
|
|
|
|
|
|
|
#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);
|
2020-12-10 15:10:28 +01:00
|
|
|
uint32_t mqtt_queuewaiting(void);
|
2020-05-16 23:49:34 +02:00
|
|
|
void mqtt_queuereset(void);
|
|
|
|
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);
|
2020-12-23 16:31:31 +01:00
|
|
|
void mqtt_deinit(void);
|
2020-05-16 23:49:34 +02:00
|
|
|
|
|
|
|
#endif // _MQTTCLIENT_H
|