fix indentation
This commit is contained in:
parent
3d7a089e0e
commit
bf61e4c937
16
things.ino
16
things.ino
@ -19,16 +19,16 @@ extern "C" {
|
||||
//#define DHTTYPE DHT21 // DHT21 (AM2301)
|
||||
#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_port[6] = "1883";
|
||||
char mqtt_topic[34] = "OutTopic";
|
||||
|
||||
//flag for saving data
|
||||
// flag for saving data
|
||||
bool shouldSaveConfig = false;
|
||||
|
||||
//callback notifying us of the need to save config
|
||||
void saveConfigCallback () {
|
||||
// callback notifying us of the need to save config
|
||||
void saveConfigCallback() {
|
||||
Serial.println("Should save config");
|
||||
shouldSaveConfig = true;
|
||||
}
|
||||
@ -170,7 +170,7 @@ void reconnect() {
|
||||
}
|
||||
}
|
||||
|
||||
int stringToNumber(String thisString) {
|
||||
int stringToNumber(String thisString) {
|
||||
int i, value, length;
|
||||
length = thisString.length();
|
||||
char blah[(length + 1)];
|
||||
@ -180,7 +180,7 @@ void reconnect() {
|
||||
blah[i] = 0;
|
||||
value = atoi(blah);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// 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
|
||||
ticker.attach(0.6, toggle_led);
|
||||
|
||||
|
||||
//clean FS, for testing
|
||||
//SPIFFS.format();
|
||||
|
||||
@ -209,18 +208,15 @@ void setup() {
|
||||
size_t size = configFile.size();
|
||||
// Allocate a buffer to store contents of the file.
|
||||
std::unique_ptr<char[]> buf(new char[size]);
|
||||
|
||||
configFile.readBytes(buf.get(), size);
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
JsonObject& json = jsonBuffer.parseObject(buf.get());
|
||||
json.printTo(Serial);
|
||||
if (json.success()) {
|
||||
Serial.println("\nparsed json");
|
||||
|
||||
strcpy(mqtt_server, json["mqtt_server"]);
|
||||
strcpy(mqtt_port, json["mqtt_port"]);
|
||||
strcpy(mqtt_topic, json["mqtt_topic"]);
|
||||
|
||||
} else {
|
||||
Serial.println("failed to load json config");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user