From e264d9279ee740f49bbe8c30e8fa8151c0f05a59 Mon Sep 17 00:00:00 2001 From: Piotr Dobrowolski Date: Mon, 2 Oct 2017 13:08:59 +0200 Subject: [PATCH] Cleanup --- spejsiot/SpejsNode.cpp | 48 ++++++------------------------------------ spejsiot/SpejsNode.h | 1 - 2 files changed, 6 insertions(+), 43 deletions(-) diff --git a/spejsiot/SpejsNode.cpp b/spejsiot/SpejsNode.cpp index fbdcb76..947f069 100644 --- a/spejsiot/SpejsNode.cpp +++ b/spejsiot/SpejsNode.cpp @@ -43,14 +43,14 @@ void SpejsNode::loadJSON(std::vector initializers) { spiffs_mount_manual(0x100000, SPIFF_SIZE); #endif - DynamicJsonBuffer jsonBuffer; - if (fileExist(CONFIG_FILE)) { + DynamicJsonBuffer jsonBuffer; + if (fileExist(CONFIG_FILE)) { Serial.println("Found config file"); - int size = fileGetSize(CONFIG_FILE); + int size = fileGetSize(CONFIG_FILE); Serial.printf("%d bytes\n", size); - char* jsonString = new char[size + 1]; - fileGetContent(CONFIG_FILE, jsonString, size + 1); - JsonObject& root = jsonBuffer.parseObject(jsonString); + char* jsonString = new char[size + 1]; + fileGetContent(CONFIG_FILE, jsonString, size + 1); + JsonObject& root = jsonBuffer.parseObject(jsonString); if (root.containsKey("name")) deviceType = (root["name"]).asString(); @@ -163,8 +163,6 @@ void SpejsNode::onConnected() { http.addPath("/", HttpPathDelegate(&SpejsNode::httpIndex, this)); http.setDefaultHandler(HttpPathDelegate(&SpejsNode::httpFile, this)); - // mDNS initialization - initializeMDNS(); } void SpejsNode::httpFile(HttpRequest &request, HttpResponse &response) @@ -191,30 +189,6 @@ void SpejsNode::httpFile(HttpRequest &request, HttpResponse &response) } } - -void SpejsNode::initializeMDNS() { - /* - static struct mdns_info *info = (struct mdns_info *)os_zalloc(sizeof(struct mdns_info)); - char tmp_name[32]; - ("iot-" + deviceID).toCharArray(tmp_name, 32); - info->host_name = tmp_name; // You can replace test with your own host name - info->ipAddr = WifiStation.getIP(); - info->server_name = (char *) "spejsiot"; - info->server_port = 80; - - char tmp_version[32] = "version="; - int prefix_len = strlen(tmp_version); - strncat(tmp_version, BUILD_ID, 32); - info->txt_data[0] = tmp_version; - - char tmp_type[32]; - ("type=" + deviceType).toCharArray(tmp_type, 32); - info->txt_data[1] = tmp_type; - - espconn_mdns_init(info); - */ -} - /* * Publish on device-specific topic */ @@ -240,16 +214,6 @@ void SpejsNode::registerEndpoint(String key, Endpoint* endpoint) { } void SpejsNode::mqttCallback(String origtopic, String value) { - /*int propPos = origtopic.indexOf("/", devicePrefix.length()); - String endpoint = origtopic.substring(devicePrefix.length(), propPos); - String property = origtopic.substring(propPos+1, origtopic.indexOf("/", propPos+1)); - - if(endpoints.contains(endpoint)) { - Serial.printf("%s - %s response: %d\n", endpoint.c_str(), property.c_str(), endpoints[endpoint]->onValue(property, value).status); - } else { - Serial.println("unknown topic? " + endpoint); - }*/ - for(unsigned int i = 0 ; i < endpoints.count() ; i++) { endpoints.valueAt(i)->onMessage(origtopic, value); } diff --git a/spejsiot/SpejsNode.h b/spejsiot/SpejsNode.h index a5cfec2..bd79f6c 100644 --- a/spejsiot/SpejsNode.h +++ b/spejsiot/SpejsNode.h @@ -69,7 +69,6 @@ protected: void otaUpdateCallback(bool result); void httpFile(HttpRequest &request, HttpResponse &response); void httpIndex(HttpRequest &request, HttpResponse &response); - void httpMetadata(HttpRequest &request, HttpResponse &response); public: MqttClient mqtt; HttpServer http;