fix indentation

This commit is contained in:
Ronald Schaten 2016-02-24 07:43:01 +01:00
parent 3d7a089e0e
commit bf61e4c937

View File

@ -19,16 +19,16 @@ extern "C" {
//#define DHTTYPE DHT21 // DHT21 (AM2301) //#define DHTTYPE DHT21 // DHT21 (AM2301)
#define DHTTYPE DHT22 // DHT22 (AM2302) #define DHTTYPE DHT22 // DHT22 (AM2302)
//define your default values here, if there are different values in config.json, they are overwritten. // define your default values here, if there are different values in config.json, they are overwritten.
char mqtt_server[40]; char mqtt_server[40];
char mqtt_port[6] = "1883"; char mqtt_port[6] = "1883";
char mqtt_topic[34] = "OutTopic"; char mqtt_topic[34] = "OutTopic";
//flag for saving data // flag for saving data
bool shouldSaveConfig = false; bool shouldSaveConfig = false;
//callback notifying us of the need to save config // callback notifying us of the need to save config
void saveConfigCallback () { void saveConfigCallback() {
Serial.println("Should save config"); Serial.println("Should save config");
shouldSaveConfig = true; shouldSaveConfig = true;
} }
@ -170,7 +170,7 @@ void reconnect() {
} }
} }
int stringToNumber(String thisString) { int stringToNumber(String thisString) {
int i, value, length; int i, value, length;
length = thisString.length(); length = thisString.length();
char blah[(length + 1)]; char blah[(length + 1)];
@ -180,7 +180,7 @@ void reconnect() {
blah[i] = 0; blah[i] = 0;
value = atoi(blah); value = atoi(blah);
return value; return value;
} }
void setup() { void setup() {
// put your setup code here, to run once: // put your setup code here, to run once:
@ -191,7 +191,6 @@ void setup() {
// start ticker with 0.5 because we start in AP mode and try to connect // start ticker with 0.5 because we start in AP mode and try to connect
ticker.attach(0.6, toggle_led); ticker.attach(0.6, toggle_led);
//clean FS, for testing //clean FS, for testing
//SPIFFS.format(); //SPIFFS.format();
@ -209,18 +208,15 @@ void setup() {
size_t size = configFile.size(); size_t size = configFile.size();
// Allocate a buffer to store contents of the file. // Allocate a buffer to store contents of the file.
std::unique_ptr<char[]> buf(new char[size]); std::unique_ptr<char[]> buf(new char[size]);
configFile.readBytes(buf.get(), size); configFile.readBytes(buf.get(), size);
DynamicJsonBuffer jsonBuffer; DynamicJsonBuffer jsonBuffer;
JsonObject& json = jsonBuffer.parseObject(buf.get()); JsonObject& json = jsonBuffer.parseObject(buf.get());
json.printTo(Serial); json.printTo(Serial);
if (json.success()) { if (json.success()) {
Serial.println("\nparsed json"); Serial.println("\nparsed json");
strcpy(mqtt_server, json["mqtt_server"]); strcpy(mqtt_server, json["mqtt_server"]);
strcpy(mqtt_port, json["mqtt_port"]); strcpy(mqtt_port, json["mqtt_port"]);
strcpy(mqtt_topic, json["mqtt_topic"]); strcpy(mqtt_topic, json["mqtt_topic"]);
} else { } else {
Serial.println("failed to load json config"); Serial.println("failed to load json config");
} }