refactoring

This commit is contained in:
livello
2018-10-08 18:23:10 +03:00
parent ebc7c57fd6
commit b83badcff8

View File

@@ -178,7 +178,6 @@ void mqttCallback(char *topic, byte *payload, unsigned int length) {
return; return;
} }
//Check if topic = Command topic
short intopic = 0; short intopic = 0;
{ {
char buf[MQTT_TOPIC_LENGTH + 1]; char buf[MQTT_TOPIC_LENGTH + 1];
@@ -1063,9 +1062,7 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
httpClient.begin(fullURI); httpClient.begin(fullURI);
int httpResponseCode = httpClient.GET(); int httpResponseCode = httpClient.GET();
if (httpResponseCode > 0) { if (httpResponseCode > 0) {
// HTTP header has been send and Server response header has been handled
debugSerial.printf("[HTTP] GET... code: %d\n", httpResponseCode); debugSerial.printf("[HTTP] GET... code: %d\n", httpResponseCode);
// file found at server
if (httpResponseCode == HTTP_CODE_OK) { if (httpResponseCode == HTTP_CODE_OK) {
String response = httpClient.getString(); String response = httpClient.getString();
debugSerial.println(response); debugSerial.println(response);
@@ -1073,7 +1070,7 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
root = aJson.parse((char *) response.c_str()); root = aJson.parse((char *) response.c_str());
if (!root) { if (!root) {
debugSerial.println(F("Config parsing failed")); debugSerial.println(F("Config parsing failed"));
return READ_RE_CONFIG;//-11; //Load from NVRAM return READ_RE_CONFIG;
} else { } else {
debugSerial.println(F("Config OK, Applying")); debugSerial.println(F("Config OK, Applying"));
applyConfig(); applyConfig();
@@ -1082,12 +1079,12 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
} else { } else {
debugSerial.printf("[HTTP] GET... failed, error: %s\n", httpClient.errorToString(httpResponseCode).c_str()); debugSerial.printf("[HTTP] GET... failed, error: %s\n", httpClient.errorToString(httpResponseCode).c_str());
httpClient.end(); httpClient.end();
return READ_RE_CONFIG;//-11; //Load from NVRAM return READ_RE_CONFIG;
} }
httpClient.end(); httpClient.end();
#endif #endif
return IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;//2; return IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;
} }
void preTransmission() { void preTransmission() {