Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,7 @@ paket-files/

# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
*.pyc


Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment for why this is added

tmp/*
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 Tim van den Essen
Copyright (c) 2018 Tim van den Essen, 2019 Gerd Langer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# ConfigTool
ESP32 and ESP8266 Arduino library for easy saving and storing config variables.

Arduino or ESP8266 libraryy for easy saving and storing config variables.
Also has a handler to edit them via a webserver.

See [this example](https://github.com/Tvde1/ConfigTool/blob/master/examples/ConfigTool/ConfigTool.ino).
Handler to edit config via a webserver added in simple layout.
Each config variables can be hidden fully or its value.
106 changes: 106 additions & 0 deletions examples/WebConfig/WebConfig.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/**
* WebServer for ConfigTool.
*/

#include <ConfigTool.h>

#if defined(ARDUINO_ARCH_ESP8266) //ESP8266
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#define MDNS_NAME "esp8266"
#elif defined(ARDUINO_ARCH_ESP32) //ESP32
#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <ESPmDNS.h>
#define MDNS_NAME "esp32"
#endif

const char* ssid = "<ssid>";
const char* password = "<pwd>";

String config_String_1 = "Default";
String config_String_2 = "Test";
int config_int_1 = 100;
int config_int_2 = 200;
bool config_bool_F = false;
bool config_bool_T = true;
IPAddress config_IP_1 = IPAddress(192,168,1,99);

ConfigTool configTool;
WebServer server(80);

void initVariables() {
configTool.addVariable("String1", &config_String_1);
configTool.addVariable("String2", &config_String_2, false, true);
configTool.addVariable("int___1", &config_int_1);
configTool.addVariable("int___2", &config_int_2, true);
configTool.addVariable("bool__F", &config_bool_F);
configTool.addVariable("bool__T", &config_bool_T);
configTool.addVariable("bool__X", &config_bool_T, false, true);
configTool.addVariable("IP____1", &config_IP_1);
}


void handleRoot() {
server.send(200, "text/plain", "hello from esp!");
}

void handleNotFound() {
String message = "File Not Found\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET) ? "GET" : "POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i = 0; i < server.args(); i++) {
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
}

void setup(){
Serial.begin(115200);
Serial.println("Setup begin");

initVariables();
configTool.load();

WiFi.mode(WIFI_STA);
Serial.print("MAC: ");
Serial.println(WiFi.macAddress());

WiFi.begin(ssid, password);
Serial.println("");

// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());

if (MDNS.begin(MDNS_NAME)) {
Serial.println("MDNS responder started");
}

server.on("/", handleRoot);

server.on("/config", configTool.getWebHandler(&server));

server.onNotFound(handleNotFound);

server.begin();
Serial.println("HTTP server started");
}

void loop(void) {
server.handleClient();
}
13 changes: 13 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# main class
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This for an IDE?

ConfigTool KEYWORD1

# structs for variables
BaseVar KEYWORD3
ConfigVar KEYWORD3

# public functions of ConfigTool
load KEYWORD2
save KEYWORD2
reset KEYWORD2
addVariable KEYWORD2
getWebHandler KEYWORD2
11 changes: 6 additions & 5 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name=ConfigTool
version=1.0
author=Tvde1
maintainer=Tvde1
version=1.1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
version=1.1
version=2.0

It's quite a big change. Maybe use 2.0

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also noticed the version is 1.1 already. If 2.0 doesn't sound good then go with 1.2.

author=Tvde1,gerdlanger
maintainer=gerdlanger
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
maintainer=gerdlanger
maintainer=Tvde1

I very much appreciate the effort you have put in so it's very fair you are listed as author but I think that I should still be listed as the maintainer. I promise I'm not gonna abandon this library anytime soon :)

sentence=Save config variable and edit them online.
paragraph=No more hardcoding. This library will save and load config variables and you can edit them at an endpoint you choose.
category=Data Storage
url=https://github.com/Tvde1/ConfigTool
includes=ConfigTool.h
url=https://github.com/gerdlanger/ConfigTool
includes=ConfigTool.h
architectures=esp32,esp8266
Loading