mqtt.h 968 Bytes
#ifndef __MQTT_H_
#define __MQTT_H_

#include <MQTT.h>
#include "sonar.h"
#include "queue.h"

const char *mqtt_server = "sokoban.fritz.box";
const char *device_id = "kompost";
MQTT mqttClient(device_id, mqtt_server, 1883);

#define PREAMBLE         "home/compost/"
#define T_RDIST          "rawdistance"
#define T_SDIST          "waterlevel"
#define T_PUMPSOURCE     "pumpsource"
#define T_PUMPSTATE      "pumpstate"
#define T_PUMPLEVEL      "pumplevel"
#define T_PUMPDURATION   "pumpduration"
#define T_PUMPABORT      "pumpabort"

#define T_FILL   "fill/"
#define T_ROTATE   "rotate/"
#define T_FERTILIZE   "fertilize/"

#define TS_DURATION   "duration"
#define TS_LEVEL   "level"

#define C_FILL_DURATION      0
#define C_ROTATE_DURATION    1
#define C_FERTILIZE_DURATION 2

long stringToLong(String s);
void setup_mqtt();
void mqttSubscribe();
void mqttPublished();
void mqttConnected();
void mqttDisconnected();
void mqttData(String& topic, String& data);

#endif