2016-09-18 08:30:34 +00:00
|
|
|
#ifndef SPEJSNODE_H
|
|
|
|
#define SPEJSNODE_H
|
|
|
|
|
2016-06-29 15:00:22 +00:00
|
|
|
#include <user_config.h>
|
|
|
|
#include <common_config.h>
|
|
|
|
#include <SmingCore/SmingCore.h>
|
2016-09-18 08:30:34 +00:00
|
|
|
#include <Endpoint.h>
|
2016-06-29 15:00:22 +00:00
|
|
|
|
|
|
|
class SpejsNode {
|
|
|
|
protected:
|
|
|
|
String deviceID;
|
|
|
|
String deviceType;
|
2016-08-30 19:24:34 +00:00
|
|
|
|
|
|
|
MqttClient mqtt;
|
2016-09-17 22:46:40 +00:00
|
|
|
HttpServer http;
|
2016-08-30 19:24:34 +00:00
|
|
|
|
2016-06-29 15:00:22 +00:00
|
|
|
Timer keepaliveTimer;
|
|
|
|
|
2016-08-30 19:24:34 +00:00
|
|
|
rBootHttpUpdate* otaUpdater = 0;
|
|
|
|
|
2016-09-18 08:30:34 +00:00
|
|
|
HashMap<String, Endpoint*> endpoints;
|
2016-06-29 15:00:22 +00:00
|
|
|
|
|
|
|
void onConnected();
|
|
|
|
void startOTA();
|
|
|
|
void keepAliveHandler();
|
|
|
|
|
2016-08-30 19:24:34 +00:00
|
|
|
uint8_t currentSlot;
|
2016-09-18 08:30:34 +00:00
|
|
|
|
2016-06-29 15:00:22 +00:00
|
|
|
public:
|
|
|
|
SpejsNode(String _deviceType) :
|
|
|
|
mqtt(MQTT_BROKER, MQTT_PORT, MqttStringSubscriptionCallback(&SpejsNode::mqttCallback, this)),
|
|
|
|
deviceType(_deviceType)
|
|
|
|
{};
|
|
|
|
|
|
|
|
void init();
|
|
|
|
|
|
|
|
bool notify(String key, String value);
|
2016-09-18 08:30:34 +00:00
|
|
|
void registerEndpoint(String key, Endpoint* cb);
|
2016-06-29 15:00:22 +00:00
|
|
|
void mqttCallback(String, String);
|
2016-08-30 19:24:34 +00:00
|
|
|
void controlHandler(String, String);
|
2016-09-10 23:46:42 +00:00
|
|
|
void otaUpdateCallback(rBootHttpUpdate& updater, bool result);
|
2016-09-17 22:46:40 +00:00
|
|
|
void httpFile(HttpRequest &request, HttpResponse &response);
|
|
|
|
void httpIndex(HttpRequest &request, HttpResponse &response);
|
|
|
|
void httpMetadata(HttpRequest &request, HttpResponse &response);
|
2016-06-29 15:00:22 +00:00
|
|
|
};
|
2016-09-18 08:30:34 +00:00
|
|
|
|
|
|
|
#endif
|