From 281c071ba5606e8654aef3d84b7f8e7e240edd8a Mon Sep 17 00:00:00 2001 From: Piotr Dobrowolski Date: Mon, 12 Jun 2017 17:40:23 +0200 Subject: [PATCH] Update to current Sming master --- spejsiot/Endpoint.h | 2 +- spejsiot/SpejsNode.h | 9 +++++---- spejsiot/endpoints/DHTEndpoint.cpp | 7 ------- spejsiot/endpoints/ImplementationEndpoint.cpp | 2 +- spejsiot/endpoints/OutputEndpoint.cpp | 7 ------- switch/Makefile-user.mk | 2 +- switch/app/application.cpp | 1 + 7 files changed, 9 insertions(+), 21 deletions(-) diff --git a/spejsiot/Endpoint.h b/spejsiot/Endpoint.h index be8b7f9..2a3bb09 100644 --- a/spejsiot/Endpoint.h +++ b/spejsiot/Endpoint.h @@ -33,7 +33,7 @@ public: return 400; } - void onConnected(); + virtual void onConnected(); }; template class ValueEndpoint : public Endpoint { diff --git a/spejsiot/SpejsNode.h b/spejsiot/SpejsNode.h index f4da607..3c6eb1e 100644 --- a/spejsiot/SpejsNode.h +++ b/spejsiot/SpejsNode.h @@ -18,14 +18,10 @@ class SpejsNode { protected: - MqttClient mqtt; - HttpServer http; - Timer keepaliveTimer; HashMap endpoints; - void onConnected(); void keepAliveHandler(); void initializeMDNS(); @@ -37,6 +33,9 @@ protected: void httpIndex(HttpRequest &request, HttpResponse &response); void httpMetadata(HttpRequest &request, HttpResponse &response); public: + MqttClient mqtt; + HttpServer http; + String deviceID; String deviceType; @@ -46,6 +45,8 @@ public: mqtt(MQTT_BROKER, MQTT_PORT, MqttStringSubscriptionCallback(&SpejsNode::mqttCallback, this)), deviceType(_deviceType) {}; + void onConnected(); + void init(); bool notify(String key, String value); diff --git a/spejsiot/endpoints/DHTEndpoint.cpp b/spejsiot/endpoints/DHTEndpoint.cpp index 3f58ce7..b3e1abb 100644 --- a/spejsiot/endpoints/DHTEndpoint.cpp +++ b/spejsiot/endpoints/DHTEndpoint.cpp @@ -20,10 +20,3 @@ void DHTEndpoint::sample() { Serial.print(sensor.getLastError()); } } - -DECLARE_ENDPOINT( - kolejnypapiez, - *[]() { - return (Endpoint*) new DHTEndpoint(5); - } -); diff --git a/spejsiot/endpoints/ImplementationEndpoint.cpp b/spejsiot/endpoints/ImplementationEndpoint.cpp index 4e30ab1..613c278 100644 --- a/spejsiot/endpoints/ImplementationEndpoint.cpp +++ b/spejsiot/endpoints/ImplementationEndpoint.cpp @@ -41,7 +41,7 @@ void ImplementationEndpoint::startOTA() { } #endif - otaUpdater->setCallback(otaUpdateDelegate(&ImplementationEndpoint::otaUpdateCallback, this)); + otaUpdater->setCallback(OtaUpdateDelegate(&ImplementationEndpoint::otaUpdateCallback, this)); otaUpdater->start(); notify("ota", "started"); diff --git a/spejsiot/endpoints/OutputEndpoint.cpp b/spejsiot/endpoints/OutputEndpoint.cpp index 6cf95d6..1c9e26a 100644 --- a/spejsiot/endpoints/OutputEndpoint.cpp +++ b/spejsiot/endpoints/OutputEndpoint.cpp @@ -13,10 +13,3 @@ EndpointResult OutputEndpoint::onValue(String property, String value) { notify("on", currentValue ? "true" : "false"); return 200; } - -DECLARE_ENDPOINT( - papiezpedofilxD, - *[]() { - return (Endpoint*) new OutputEndpoint(5); - } -); diff --git a/switch/Makefile-user.mk b/switch/Makefile-user.mk index c59b2dc..49366d4 100644 --- a/switch/Makefile-user.mk +++ b/switch/Makefile-user.mk @@ -1,4 +1,4 @@ -MODULES = app ../spejsiot +MODULES = app ../spejsiot ../spejsiot/endpoints DISABLE_SPIFFS = 1 USER_CFLAGS = -I../common #ENABLE_SSL = 1 diff --git a/switch/app/application.cpp b/switch/app/application.cpp index c45adc0..c6d9612 100644 --- a/switch/app/application.cpp +++ b/switch/app/application.cpp @@ -1,4 +1,5 @@ #include +#include SpejsNode node("switch");