Cleanup
parent
6ee1650381
commit
e264d9279e
|
@ -43,14 +43,14 @@ void SpejsNode::loadJSON(std::vector<EndpointInitializer> 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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue